diff options
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 26 |
1 files changed, 11 insertions, 15 deletions
@@ -15,17 +15,19 @@ under the creative commons CC-BY-SA license. This Rust implementation is a line-by-line port of Ulf Adams' implementation in C, [https://github.com/ulfjack/ryu][upstream]. -*Requirements: this crate supports any compiler version back to rustc 1.31; it +*Requirements: this crate supports any compiler version back to rustc 1.36; it uses nothing from the Rust standard library so is usable from no_std crates.* [paper]: https://dl.acm.org/citation.cfm?id=3192369 -[upstream]: https://github.com/ulfjack/ryu/tree/1c413e127f8d02afd12eb6259bc80163722f1385 +[upstream]: https://github.com/ulfjack/ryu/tree/abf76d252bc97300354857e64e80d4a2bf664291 ```toml [dependencies] ryu = "1.0" ``` +<br> + ## Example ```rust @@ -36,14 +38,18 @@ fn main() { } ``` -## Performance +<br> + +## Performance (lower is better) + +![performance](https://raw.githubusercontent.com/dtolnay/ryu/master/performance.png) You can run upstream's benchmarks with: ```console $ git clone https://github.com/ulfjack/ryu c-ryu $ cd c-ryu -$ bazel run -c opt //ryu/benchmark +$ bazel run -c opt //ryu/benchmark:ryu_benchmark ``` And the same benchmark against our implementation with: @@ -69,20 +75,10 @@ standard library which you can run with: $ cargo bench ``` -The benchmark shows Ryū approximately 4-10x faster than the standard library +The benchmark shows Ryū approximately 2-5x faster than the standard library across a range of f32 and f64 inputs. Measurements are in nanoseconds per iteration; smaller is better. -| type=f32 | 0.0 | 0.1234 | 2.718281828459045 | f32::MAX | -|:--------:|:----:|:------:|:-----------------:|:--------:| -| RYU | 3ns | 28ns | 23ns | 22ns | -| STD | 40ns | 106ns | 128ns | 110ns | - -| type=f64 | 0.0 | 0.1234 | 2.718281828459045 | f64::MAX | -|:--------:|:----:|:------:|:-----------------:|:--------:| -| RYU | 3ns | 50ns | 35ns | 32ns | -| STD | 39ns | 105ns | 128ns | 202ns | - ## Formatting This library tends to produce more human-readable output than the standard |