This PR optimize udivmod_1e19 function based on the algorithm provided in [1]. This optimization dramatically improve performance of formatting u128 type.
Performance
previous results
test bench_itoa_fmt::bench_u128_0 ... bench: 19 ns/iter (+/- 0)
test bench_itoa_fmt::bench_u128_max ... bench: 423 ns/iter (+/- 3)
test bench_itoa_write::bench_u128_0 ... bench: 17 ns/iter (+/- 0)
test bench_itoa_write::bench_u128_max ... bench: 422 ns/iter (+/- 13)
test bench_std_fmt::bench_u128_0 ... bench: 78 ns/iter (+/- 2)
test bench_std_fmt::bench_u128_max ... bench: 514 ns/iter (+/- 9)
new results
test bench_itoa_fmt::bench_u128_0 ... bench: 19 ns/iter (+/- 3)
test bench_itoa_fmt::bench_u128_max ... bench: 75 ns/iter (+/- 3)
test bench_itoa_write::bench_u128_0 ... bench: 17 ns/iter (+/- 1)
test bench_itoa_write::bench_u128_max ... bench: 75 ns/iter (+/- 3)
test bench_std_fmt::bench_u128_0 ... bench: 74 ns/iter (+/- 3)
test bench_std_fmt::bench_u128_max ... bench: 512 ns/iter (+/- 19)
Reference
[1] T. Granlund and P. Montgomery, “Division by Invariant Integers Using Multiplication” in Proc. of the SIGPLAN94 Conference on Programming Language Design and Implementation, 1994, pp. 61–72
This PR optimize
udivmod_1e19
function based on the algorithm provided in [1]. This optimization dramatically improve performance of formattingu128
type.Performance
previous results
new results
Reference
[1] T. Granlund and P. Montgomery, “Division by Invariant Integers Using Multiplication” in Proc. of the SIGPLAN94 Conference on Programming Language Design and Implementation, 1994, pp. 61–72