@@ -17,7 +17,7 @@ under the creative commons CC-BY-SA license.
1717This Rust implementation is a line-by-line port of Ulf Adams' implementation in
1818C, [ https://github.com/ulfjack/ryu ] [ upstream ] .
1919
20- * Requirements: this crate supports any compiler version back to rustc 1.31 ; it
20+ * Requirements: this crate supports any compiler version back to rustc 1.36 ; it
2121uses nothing from the Rust standard library so is usable from no_std crates.*
2222
2323[ paper ] : https://dl.acm.org/citation.cfm?id=3192369
@@ -28,6 +28,8 @@ uses nothing from the Rust standard library so is usable from no_std crates.*
2828ryu-js = " 0.2"
2929```
3030
31+ <br >
32+
3133## Example
3234
3335``` rust
@@ -38,7 +40,27 @@ fn main() {
3840}
3941```
4042
41- ## Performance
43+ <br >
44+
45+ ## Performance (lower is better)
46+
47+ ![ performance] ( https://raw.githubusercontent.com/boa-dev/ryu-js/master/performance.png )
48+
49+ You can run upstream's benchmarks with:
50+
51+ ``` console
52+ $ git clone https://github.com/ulfjack/ryu c-ryu
53+ $ cd c-ryu
54+ $ bazel run -c opt //ryu/benchmark:ryu_benchmark --
55+ ```
56+
57+ And the same benchmark against our implementation with:
58+
59+ ``` console
60+ $ git clone https://github.com/boa-dev/ryu-js rust-ryu
61+ $ cd rust-ryu
62+ $ cargo run --example upstream_benchmark --release
63+ ```
4264
4365The benchmarks measure the average time to print a 32-bit float and average
4466time to print a 64-bit float, where the inputs are distributed as uniform random
@@ -55,20 +77,10 @@ standard library which you can run with:
5577$ cargo bench
5678```
5779
58- The benchmark shows Ryū approximately 4-10x faster than the standard library
80+ The benchmark shows Ryū approximately 2-5x faster than the standard library
5981across a range of f32 and f64 inputs. Measurements are in nanoseconds per
6082iteration; smaller is better.
6183
62- | type=f32 | 0.0 | 0.1234 | 2.718281828459045 | f32::MAX |
63- | :--------:| :----:| :------:| :-----------------:| :--------:|
64- | RYU | 3ns | 28ns | 23ns | 22ns |
65- | STD | 40ns | 106ns | 128ns | 110ns |
66-
67- | type=f64 | 0.0 | 0.1234 | 2.718281828459045 | f64::MAX |
68- | :--------:| :----:| :------:| :-----------------:| :--------:|
69- | RYU | 3ns | 50ns | 35ns | 32ns |
70- | STD | 39ns | 105ns | 128ns | 202ns |
71-
7284## Formatting
7385
7486This library tends to produce more human-readable output than the standard
0 commit comments