Skip to content

Commit a6ef805

Browse files
committed
Update benchmarks and descriptions.
Related to #16.
1 parent d217cf5 commit a6ef805

File tree

3 files changed

+29
-56
lines changed

3 files changed

+29
-56
lines changed

README.md

Lines changed: 26 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
fast-float2
2-
===========
1+
# fast-float2
32

43
[![Build](https://github.com/Alexhuszagh/fast-float-rust/workflows/CI/badge.svg)](https://github.com/Alexhuszagh/fast-float-rust/actions?query=branch%3Amaster)
54
[![Latest Version](https://img.shields.io/crates/v/fast-float2.svg)](https://crates.io/crates/fast-float2)
@@ -90,9 +89,6 @@ below (the only exception being the original fast_float C++ library, of course
9089
which is within noise bounds of this crate). On modern machines like Apple M1, parsing throughput
9190
can reach up to 1.5 GB/s.
9291

93-
In particular, it is faster than Rust standard library's `FromStr::from_str()` by a factor of 2-8x
94-
(larger factor for longer float strings), and is typically 2-3x faster than the nearest competitors.
95-
9692
While various details regarding the algorithm can be found in the repository for the original
9793
C++ library, here are few brief notes:
9894

@@ -109,54 +105,31 @@ C++ library, here are few brief notes:
109105
## Benchmarks
110106

111107
Below are tables of best timings in nanoseconds for parsing a single number
112-
into a 64-bit float.
113-
114-
#### Intel i7-4771
115-
116-
Intel i7-4771 3.5GHz, macOS, Rust 1.49.
117-
118-
| | `canada` | `mesh` | `uniform` | `iidi` | `iei` | `rec32` |
119-
| ---------------- | -------- | -------- | --------- | ------ | ------ | ------- |
120-
| fast-float | 21.58 | 10.70 | 19.36 | 40.50 | 26.07 | 29.13 |
121-
| lexical | 65.90 | 23.28 | 54.75 | 75.80 | 52.18 | 75.36 |
122-
| from_str | 174.43 | 22.30 | 99.93 | 227.76 | 111.31 | 204.46 |
123-
| fast_float (C++) | 22.78 | 10.99 | 20.05 | 41.12 | 27.51 | 30.85 |
124-
| abseil (C++) | 42.66 | 32.88 | 46.01 | 50.83 | 46.33 | 49.95 |
125-
| netlib (C) | 57.53 | 24.86 | 64.72 | 56.63 | 36.20 | 67.29 |
126-
| strtod (C) | 286.10 | 31.15 | 258.73 | 295.73 | 205.72 | 315.95 |
127-
128-
#### Apple M1
129-
130-
Apple M1, macOS, Rust 1.49.
131-
132-
| | `canada` | `mesh` | `uniform` | `iidi` | `iei` | `rec32` |
133-
| ---------------- | -------- | -------- | --------- | ------ | ------ | ------- |
134-
| fast-float | 14.84 | 5.98 | 11.24 | 33.24 | 21.30 | 17.86 |
135-
| lexical | 47.09 | 16.51 | 43.46 | 56.06 | 36.68 | 55.48 |
136-
| from_str | 136.00 | 13.84 | 74.64 | 179.87 | 77.91 | 154.53 |
137-
| fast_float (C++) | 13.71 | 7.28 | 11.71 | 32.94 | 20.64 | 18.30 |
138-
| abseil (C++) | 36.55 | 24.20 | 38.48 | 40.86 | 35.46 | 40.09 |
139-
| netlib (C) | 47.19 | 14.12 | 48.85 | 52.28 | 33.70 | 48.79 |
140-
| strtod (C) | 176.13 | 21.48 | 165.43 | 187.98 | 132.19 | 190.63 |
141-
142-
#### AMD Rome
143-
144-
AMD Rome, Linux, Rust 1.49.
145-
146-
| | `canada` | `mesh` | `uniform` | `iidi` | `iei` | `rec32` |
147-
| ---------------- | -------- | -------- | --------- | ------ | ------ | ------- |
148-
| fast-float | 25.90 | 12.12 | 20.54 | 47.01 | 29.23 | 32.36 |
149-
| lexical | 63.18 | 22.13 | 54.78 | 81.23 | 55.06 | 79.14 |
150-
| from_str | 190.06 | 26.10 | 102.44 | 239.87 | 119.04 | 211.73 |
151-
| fast_float (C++) | 21.29 | 10.47 | 18.31 | 42.33 | 24.56 | 29.76 |
152-
| abseil (C++) | 44.54 | 34.13 | 47.38 | 52.64 | 43.77 | 53.03 |
153-
| netlib (C) | 69.43 | 23.31 | 79.98 | 72.17 | 35.81 | 86.91 |
154-
| strtod (C) | 123.37 | 65.68 | 101.58 | 118.36 | 118.61 | 123.72 |
108+
into a 64-bit float (using the median score).
109+
110+
### Intel i7-14700K
111+
112+
Intel i7-14700K 3.40GHz, Linux (WSL2), Rust 1.81.
113+
114+
| | `canada` | `mesh` | `uniform` | `bi` | `iei` | `rec32` |
115+
| ---------------------- | -------- | -------- | --------- | ----- | ------ | ------- |
116+
| fast-float2 | 9.98 | 5.56 | 10.08 | 56.19 | 14.52 | 15.09 |
117+
| fast-float | 9.77 | 5.04 | 9.05 | 57.52 | 14.40 | 14.23 |
118+
| lexical | 10.62 | 4.93 | 9.92 | 26.40 | 12.43 | 14.40 |
119+
| from_str | 11.59 | 5.92 | 11.23 | 35.92 | 14.75 | 16.76 |
120+
| fast_float (C++) | 12.58 | 6.35 | 11.86 | 31.55 | 12.22 | 11.97 |
121+
| abseil (C++) | 25.32 | 15.70 | 25.88 | 43.42 | 23.54 | 26.75 |
122+
| netlib (C) | 35.10 | 10.22 | 37.72 | 68.63 | 23.07 | 38.23 |
123+
| strtod (C) | 52.63 | 26.47 | 46.51 | 88.11 | 33.37 | 53.36 |
124+
| doubleconversion (C++) | 32.50 | 14.69 | 47.80 | 70.01 | 205.72 | 45.66 |
125+
126+
Note that the random number generation seems to differ between C/C++ and Rust, since the Rust implementations are slightly faster for pre-determined datasets like `canada` and `mesh`, but equivalent random number generators are slightly slower. Any performance penalty with `fast-float2` occurred due to fixing the UB in [check_len](https://github.com/aldanor/fast-float-rust/issues/28). The massive performance differences between `fast-float` (Rust) and `fast_float` (C++) are expected due to a faster fallback algorithms ([#96](https://github.com/fastfloat/fast_float/pull/96) and [#104](https://github.com/fastfloat/fast_float/pull/104)) used in these cases.
155127

156128
#### Parsers
157129

158-
- `fast-float` - this very crate
159-
- `lexical``lexical_core`, v0.7 (non-lossy; same performance as lossy)
130+
- `fast-float2` - this very crate
131+
- `fast-float` - the pre-ported variant
132+
- `lexical``lexical_core`, v1.0.05
160133
- `from_str` – Rust standard library, `FromStr` trait
161134
- `fast_float (C++)` – original C++ implementation of 'fast-float' method
162135
- `abseil (C++)` – Abseil C++ Common Libraries
@@ -168,9 +141,9 @@ AMD Rome, Linux, Rust 1.49.
168141
- `canada` – numbers in `canada.txt` file
169142
- `mesh` – numbers in `mesh.txt` file
170143
- `uniform` – uniform random numbers from 0 to 1
171-
- `iidi`random numbers of format `%d%d.%d`
172-
- `iei` – random numbers of format `%de%d`
173-
- `rec32` – reciprocals of random 32-bit integers
144+
- `bi`large, integer-only floats <!-- `big_ints` -- >
145+
- `int_e_int` – random numbers of format `%de%d` <!-- `int_e_int` -->
146+
- `rec32` – reciprocals of random 32-bit integers <!-- `one_over_rand32` -->
174147

175148
#### Notes
176149

extras/simple-bench/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ publish = false
1111
fast-float2 = { path = "../.." }
1212
structopt = "0.3"
1313
anyhow = "1.0"
14-
lexical = "7.0.2"
15-
lexical-core = "1.0.2"
14+
lexical = "7.0.4"
15+
lexical-core = "1.0.5"
1616
fastrand = "2.1.1"
1717
fast-float = "0.2"

extras/simple-bench/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This crate provides a utility for benchmarking the `fast-float2` crate against
44
To run a file-based test:
55

66
```sh
7-
cargo run --release -- file ext/canada.txt
7+
cargo run --release -- file ext/data/canada.txt
88
```
99

1010
There's two files used in benchmarking of the original fast_float C++ library

0 commit comments

Comments
 (0)