Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize performance of writing u128/i128 on 64bit system #26

Closed

Conversation

Kogia-sima
Copy link
Contributor

@Kogia-sima Kogia-sima commented Jul 8, 2020

itoap crate has very fast implementation for writing u128 in decimal format. It is derived from 6502's method, but is optimized for 64-bit system.

I ported that implementation to itoa repository and now performance has dramatically improved.

Before

test bench_itoa_fmt::bench_u128_0     ... bench:          31 ns/iter (+/- 0)
test bench_itoa_fmt::bench_u128_max   ... bench:         433 ns/iter (+/- 2)
test bench_itoa_write::bench_u128_0   ... bench:          31 ns/iter (+/- 0)
test bench_itoa_write::bench_u128_max ... bench:         434 ns/iter (+/- 2)

After

test bench_itoa_fmt::bench_u128_0     ... bench:          30 ns/iter (+/- 0)
test bench_itoa_fmt::bench_u128_max   ... bench:         120 ns/iter (+/- 0)
test bench_itoa_write::bench_u128_0   ... bench:          30 ns/iter (+/- 0)
test bench_itoa_write::bench_u128_max ... bench:         121 ns/iter (+/- 0)

Note that this algorithm passes random tests, random digits tests, and boundary tests. (https://github.com/Kogia-sima/itoap/blob/ae36b332dac2495b4c2ff32977ea8f5080a083b6/src/lib.rs#L297-L421)

@Kogia-sima
Copy link
Contributor Author

Closing in favour of #27

@Kogia-sima Kogia-sima closed this Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant