From 2779adf99066408d7e9c998cfdc378a1c2d7923f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sun, 29 Sep 2024 15:11:42 +0200 Subject: [PATCH] chore: update benchmarks --- README.md | 221 +++++++++++++++++++++++++++--------------------------- 1 file changed, 111 insertions(+), 110 deletions(-) diff --git a/README.md b/README.md index d6dadf7..ad21817 100644 --- a/README.md +++ b/README.md @@ -20,126 +20,127 @@ _Version requirement: rustc 1.64+_ ## Performance -This crate's performance is comparable with [`faster-hex`], but the latter only -provides specialized implementations for `x86`/`x86-64`. +This crate offers performance comparable to [`faster-hex`] on `x86`/`x86-64` +architectures but outperforms it on other platforms, as [`faster-hex`] is +only optimized for `x86`/`x86-64`. This crate is 10 to 50 times faster than [`hex`] in encoding and decoding, and 100+ times faster than `libstd` in formatting. The following benchmarks were ran on an AMD Ryzen 9 7950X, compiled with -`1.80.0-nightly (bdbbb6c6a 2024-05-26)` on `x86_64-unknown-linux-gnu`. +`1.83.0-nightly (9e394f551 2024-09-25)` on `x86_64-unknown-linux-gnu`. You can run these benchmarks with `cargo bench --features std` on a nightly compiler. ```log -test check::const_hex::bench1_32b ... bench: 9.79 ns/iter (+/- 2.22) -test check::const_hex::bench2_256b ... bench: 20.22 ns/iter (+/- 6.41) -test check::const_hex::bench3_2k ... bench: 124.57 ns/iter (+/- 9.68) -test check::const_hex::bench4_16k ... bench: 927.53 ns/iter (+/- 81.94) -test check::const_hex::bench5_128k ... bench: 7,300.16 ns/iter (+/- 153.57) -test check::const_hex::bench6_1m ... bench: 59,886.62 ns/iter (+/- 1,312.15) -test check::faster_hex::bench1_32b ... bench: 2.93 ns/iter (+/- 0.20) -test check::faster_hex::bench2_256b ... bench: 15.54 ns/iter (+/- 0.77) -test check::faster_hex::bench3_2k ... bench: 121.17 ns/iter (+/- 0.70) -test check::faster_hex::bench4_16k ... bench: 945.17 ns/iter (+/- 12.48) -test check::faster_hex::bench5_128k ... bench: 7,632.07 ns/iter (+/- 172.68) -test check::faster_hex::bench6_1m ... bench: 61,427.03 ns/iter (+/- 732.21) -test check::naive::bench1_32b ... bench: 26.15 ns/iter (+/- 1.04) -test check::naive::bench2_256b ... bench: 225.69 ns/iter (+/- 9.02) -test check::naive::bench3_2k ... bench: 1,952.05 ns/iter (+/- 20.46) -test check::naive::bench4_16k ... bench: 20,329.63 ns/iter (+/- 455.31) -test check::naive::bench5_128k ... bench: 503,460.10 ns/iter (+/- 8,930.00) -test check::naive::bench6_1m ... bench: 4,252,331.00 ns/iter (+/- 191,519.79) - -test decode::const_hex::bench1_32b ... bench: 19.49 ns/iter (+/- 0.82) -test decode::const_hex::bench2_256b ... bench: 41.47 ns/iter (+/- 1.45) -test decode::const_hex::bench3_2k ... bench: 236.69 ns/iter (+/- 2.75) -test decode::const_hex::bench4_16k ... bench: 1,682.25 ns/iter (+/- 18.07) -test decode::const_hex::bench5_128k ... bench: 13,096.94 ns/iter (+/- 138.05) -test decode::const_hex::bench6_1m ... bench: 105,360.67 ns/iter (+/- 2,771.85) -test decode::faster_hex::bench1_32b ... bench: 16.49 ns/iter (+/- 0.12) -test decode::faster_hex::bench2_256b ... bench: 54.92 ns/iter (+/- 1.74) -test decode::faster_hex::bench3_2k ... bench: 246.11 ns/iter (+/- 3.25) -test decode::faster_hex::bench4_16k ... bench: 1,839.88 ns/iter (+/- 22.36) -test decode::faster_hex::bench5_128k ... bench: 14,376.52 ns/iter (+/- 203.97) -test decode::faster_hex::bench6_1m ... bench: 116,345.50 ns/iter (+/- 1,377.06) -test decode::hex::bench1_32b ... bench: 101.38 ns/iter (+/- 3.41) -test decode::hex::bench2_256b ... bench: 655.85 ns/iter (+/- 17.69) -test decode::hex::bench3_2k ... bench: 4,830.90 ns/iter (+/- 73.58) -test decode::hex::bench4_16k ... bench: 37,976.46 ns/iter (+/- 443.65) -test decode::hex::bench5_128k ... bench: 734,983.30 ns/iter (+/- 4,297.49) -test decode::hex::bench6_1m ... bench: 5,901,860.30 ns/iter (+/- 22,806.40) - -test decode_to_slice::const_hex::bench1_32b ... bench: 11.03 ns/iter (+/- 0.50) -test decode_to_slice::const_hex::bench2_256b ... bench: 28.93 ns/iter (+/- 1.38) -test decode_to_slice::const_hex::bench3_2k ... bench: 210.49 ns/iter (+/- 5.65) -test decode_to_slice::const_hex::bench4_16k ... bench: 1,670.55 ns/iter (+/- 17.87) -test decode_to_slice::const_hex::bench5_128k ... bench: 13,094.65 ns/iter (+/- 115.89) -test decode_to_slice::const_hex::bench6_1m ... bench: 105,036.12 ns/iter (+/- 1,722.56) -test decode_to_slice::faster_hex::bench1_32b ... bench: 6.26 ns/iter (+/- 0.10) -test decode_to_slice::faster_hex::bench2_256b ... bench: 28.73 ns/iter (+/- 0.55) -test decode_to_slice::faster_hex::bench3_2k ... bench: 213.70 ns/iter (+/- 2.83) -test decode_to_slice::faster_hex::bench4_16k ... bench: 1,718.21 ns/iter (+/- 23.97) -test decode_to_slice::faster_hex::bench5_128k ... bench: 13,530.96 ns/iter (+/- 97.41) -test decode_to_slice::faster_hex::bench6_1m ... bench: 107,708.79 ns/iter (+/- 1,425.58) -test decode_to_slice::hex::bench1_32b ... bench: 39.07 ns/iter (+/- 1.85) -test decode_to_slice::hex::bench2_256b ... bench: 311.73 ns/iter (+/- 10.92) -test decode_to_slice::hex::bench3_2k ... bench: 2,515.69 ns/iter (+/- 63.09) -test decode_to_slice::hex::bench4_16k ... bench: 20,899.92 ns/iter (+/- 442.95) -test decode_to_slice::hex::bench5_128k ... bench: 634,859.00 ns/iter (+/- 6,609.09) -test decode_to_slice::hex::bench6_1m ... bench: 5,338,354.20 ns/iter (+/- 51,493.30) - -test encode::const_hex::bench1_32b ... bench: 6.92 ns/iter (+/- 0.11) -test encode::const_hex::bench2_256b ... bench: 11.41 ns/iter (+/- 0.14) -test encode::const_hex::bench3_2k ... bench: 73.59 ns/iter (+/- 1.52) -test encode::const_hex::bench4_16k ... bench: 461.00 ns/iter (+/- 5.17) -test encode::const_hex::bench5_128k ... bench: 3,527.28 ns/iter (+/- 46.86) -test encode::const_hex::bench6_1m ... bench: 29,402.78 ns/iter (+/- 1,032.91) -test encode::faster_hex::bench1_32b ... bench: 17.30 ns/iter (+/- 0.30) -test encode::faster_hex::bench2_256b ... bench: 39.07 ns/iter (+/- 0.73) -test encode::faster_hex::bench3_2k ... bench: 102.93 ns/iter (+/- 1.92) -test encode::faster_hex::bench4_16k ... bench: 651.65 ns/iter (+/- 1.55) -test encode::faster_hex::bench5_128k ... bench: 5,074.50 ns/iter (+/- 22.97) -test encode::faster_hex::bench6_1m ... bench: 46,227.11 ns/iter (+/- 945.52) -test encode::hex::bench1_32b ... bench: 100.46 ns/iter (+/- 0.93) -test encode::hex::bench2_256b ... bench: 717.75 ns/iter (+/- 5.91) -test encode::hex::bench3_2k ... bench: 5,660.67 ns/iter (+/- 246.73) -test encode::hex::bench4_16k ... bench: 44,981.79 ns/iter (+/- 340.51) -test encode::hex::bench5_128k ... bench: 359,401.72 ns/iter (+/- 1,689.97) -test encode::hex::bench6_1m ... bench: 2,966,947.20 ns/iter (+/- 165,738.51) - -test encode_to_slice::const_hex::bench1_32b ... bench: 1.55 ns/iter (+/- 0.04) -test encode_to_slice::const_hex::bench2_256b ... bench: 6.73 ns/iter (+/- 0.08) -test encode_to_slice::const_hex::bench3_2k ... bench: 54.23 ns/iter (+/- 2.06) -test encode_to_slice::const_hex::bench4_16k ... bench: 471.90 ns/iter (+/- 21.13) -test encode_to_slice::const_hex::bench5_128k ... bench: 3,730.44 ns/iter (+/- 113.80) -test encode_to_slice::const_hex::bench6_1m ... bench: 29,247.93 ns/iter (+/- 926.38) -test encode_to_slice::faster_hex::bench1_32b ... bench: 3.95 ns/iter (+/- 0.26) -test encode_to_slice::faster_hex::bench2_256b ... bench: 7.49 ns/iter (+/- 0.47) -test encode_to_slice::faster_hex::bench3_2k ... bench: 48.56 ns/iter (+/- 1.95) -test encode_to_slice::faster_hex::bench4_16k ... bench: 424.65 ns/iter (+/- 11.39) -test encode_to_slice::faster_hex::bench5_128k ... bench: 3,317.47 ns/iter (+/- 103.44) -test encode_to_slice::faster_hex::bench6_1m ... bench: 26,079.18 ns/iter (+/- 889.52) -test encode_to_slice::hex::bench1_32b ... bench: 11.99 ns/iter (+/- 0.30) -test encode_to_slice::hex::bench2_256b ... bench: 119.07 ns/iter (+/- 2.85) -test encode_to_slice::hex::bench3_2k ... bench: 999.68 ns/iter (+/- 26.35) -test encode_to_slice::hex::bench4_16k ... bench: 8,049.82 ns/iter (+/- 105.51) -test encode_to_slice::hex::bench5_128k ... bench: 65,186.25 ns/iter (+/- 758.98) -test encode_to_slice::hex::bench6_1m ... bench: 511,447.00 ns/iter (+/- 4,866.41) - -test format::const_hex::bench1_32b ... bench: 9.84 ns/iter (+/- 0.21) -test format::const_hex::bench2_256b ... bench: 17.90 ns/iter (+/- 0.55) -test format::const_hex::bench3_2k ... bench: 119.47 ns/iter (+/- 3.87) -test format::const_hex::bench4_16k ... bench: 1,161.94 ns/iter (+/- 20.11) -test format::const_hex::bench5_128k ... bench: 9,580.23 ns/iter (+/- 188.10) -test format::const_hex::bench6_1m ... bench: 84,316.47 ns/iter (+/- 1,407.10) -test format::std::bench1_32b ... bench: 371.37 ns/iter (+/- 3.63) -test format::std::bench2_256b ... bench: 2,987.01 ns/iter (+/- 41.26) -test format::std::bench3_2k ... bench: 23,989.24 ns/iter (+/- 373.84) -test format::std::bench4_16k ... bench: 192,881.92 ns/iter (+/- 9,266.64) -test format::std::bench5_128k ... bench: 1,554,062.80 ns/iter (+/- 10,998.30) -test format::std::bench6_1m ... bench: 12,378,548.00 ns/iter (+/- 247,626.30) +test check::const_hex::bench1_32b ... bench: 7.36 ns/iter (+/- 0.34) +test check::const_hex::bench2_256b ... bench: 19.39 ns/iter (+/- 0.27) +test check::const_hex::bench3_2k ... bench: 121.85 ns/iter (+/- 15.13) +test check::const_hex::bench4_16k ... bench: 903.95 ns/iter (+/- 13.53) +test check::const_hex::bench5_128k ... bench: 7,121.20 ns/iter (+/- 57.48) +test check::const_hex::bench6_1m ... bench: 57,834.53 ns/iter (+/- 1,000.67) +test check::faster_hex::bench1_32b ... bench: 2.75 ns/iter (+/- 0.03) +test check::faster_hex::bench2_256b ... bench: 14.95 ns/iter (+/- 0.45) +test check::faster_hex::bench3_2k ... bench: 123.08 ns/iter (+/- 4.92) +test check::faster_hex::bench4_16k ... bench: 983.89 ns/iter (+/- 18.29) +test check::faster_hex::bench5_128k ... bench: 7,806.75 ns/iter (+/- 234.99) +test check::faster_hex::bench6_1m ... bench: 64,115.09 ns/iter (+/- 754.27) +test check::naive::bench1_32b ... bench: 18.52 ns/iter (+/- 3.59) +test check::naive::bench2_256b ... bench: 187.49 ns/iter (+/- 6.94) +test check::naive::bench3_2k ... bench: 1,953.95 ns/iter (+/- 52.85) +test check::naive::bench4_16k ... bench: 17,243.26 ns/iter (+/- 3,391.35) +test check::naive::bench5_128k ... bench: 493,272.86 ns/iter (+/- 11,374.41) +test check::naive::bench6_1m ... bench: 4,193,959.30 ns/iter (+/- 180,118.90) + +test decode::const_hex::bench1_32b ... bench: 19.77 ns/iter (+/- 0.80) +test decode::const_hex::bench2_256b ... bench: 41.15 ns/iter (+/- 1.48) +test decode::const_hex::bench3_2k ... bench: 235.43 ns/iter (+/- 2.39) +test decode::const_hex::bench4_16k ... bench: 1,703.37 ns/iter (+/- 5.44) +test decode::const_hex::bench5_128k ... bench: 13,097.29 ns/iter (+/- 54.88) +test decode::const_hex::bench6_1m ... bench: 105,834.33 ns/iter (+/- 1,860.67) +test decode::faster_hex::bench1_32b ... bench: 17.09 ns/iter (+/- 0.26) +test decode::faster_hex::bench2_256b ... bench: 55.30 ns/iter (+/- 0.56) +test decode::faster_hex::bench3_2k ... bench: 249.42 ns/iter (+/- 7.53) +test decode::faster_hex::bench4_16k ... bench: 1,867.34 ns/iter (+/- 12.68) +test decode::faster_hex::bench5_128k ... bench: 14,542.82 ns/iter (+/- 114.09) +test decode::faster_hex::bench6_1m ... bench: 118,627.86 ns/iter (+/- 2,471.00) +test decode::hex::bench1_32b ... bench: 111.69 ns/iter (+/- 7.82) +test decode::hex::bench2_256b ... bench: 728.81 ns/iter (+/- 18.34) +test decode::hex::bench3_2k ... bench: 5,263.46 ns/iter (+/- 87.04) +test decode::hex::bench4_16k ... bench: 42,284.40 ns/iter (+/- 2,312.96) +test decode::hex::bench5_128k ... bench: 800,810.80 ns/iter (+/- 7,695.87) +test decode::hex::bench6_1m ... bench: 6,442,642.10 ns/iter (+/- 38,417.90) + +test decode_to_slice::const_hex::bench1_32b ... bench: 9.90 ns/iter (+/- 2.75) +test decode_to_slice::const_hex::bench2_256b ... bench: 29.02 ns/iter (+/- 1.99) +test decode_to_slice::const_hex::bench3_2k ... bench: 210.05 ns/iter (+/- 8.65) +test decode_to_slice::const_hex::bench4_16k ... bench: 1,667.70 ns/iter (+/- 12.13) +test decode_to_slice::const_hex::bench5_128k ... bench: 13,083.20 ns/iter (+/- 96.53) +test decode_to_slice::const_hex::bench6_1m ... bench: 108,756.59 ns/iter (+/- 2,321.92) +test decode_to_slice::faster_hex::bench1_32b ... bench: 6.67 ns/iter (+/- 0.26) +test decode_to_slice::faster_hex::bench2_256b ... bench: 29.25 ns/iter (+/- 0.46) +test decode_to_slice::faster_hex::bench3_2k ... bench: 218.65 ns/iter (+/- 2.40) +test decode_to_slice::faster_hex::bench4_16k ... bench: 1,743.88 ns/iter (+/- 18.52) +test decode_to_slice::faster_hex::bench5_128k ... bench: 13,694.73 ns/iter (+/- 36.07) +test decode_to_slice::faster_hex::bench6_1m ... bench: 110,733.30 ns/iter (+/- 1,679.82) +test decode_to_slice::hex::bench1_32b ... bench: 37.57 ns/iter (+/- 0.85) +test decode_to_slice::hex::bench2_256b ... bench: 287.52 ns/iter (+/- 23.10) +test decode_to_slice::hex::bench3_2k ... bench: 2,705.00 ns/iter (+/- 26.99) +test decode_to_slice::hex::bench4_16k ... bench: 21,850.53 ns/iter (+/- 191.97) +test decode_to_slice::hex::bench5_128k ... bench: 614,217.67 ns/iter (+/- 2,237.99) +test decode_to_slice::hex::bench6_1m ... bench: 5,357,921.20 ns/iter (+/- 240,508.79) + +test encode::const_hex::bench1_32b ... bench: 7.00 ns/iter (+/- 0.37) +test encode::const_hex::bench2_256b ... bench: 11.83 ns/iter (+/- 0.05) +test encode::const_hex::bench3_2k ... bench: 73.28 ns/iter (+/- 0.30) +test encode::const_hex::bench4_16k ... bench: 467.14 ns/iter (+/- 26.32) +test encode::const_hex::bench5_128k ... bench: 3,760.74 ns/iter (+/- 69.40) +test encode::const_hex::bench6_1m ... bench: 29,080.93 ns/iter (+/- 532.47) +test encode::faster_hex::bench1_32b ... bench: 17.25 ns/iter (+/- 0.17) +test encode::faster_hex::bench2_256b ... bench: 39.03 ns/iter (+/- 0.77) +test encode::faster_hex::bench3_2k ... bench: 102.46 ns/iter (+/- 1.27) +test encode::faster_hex::bench4_16k ... bench: 655.39 ns/iter (+/- 2.28) +test encode::faster_hex::bench5_128k ... bench: 5,233.70 ns/iter (+/- 11.75) +test encode::faster_hex::bench6_1m ... bench: 43,802.73 ns/iter (+/- 1,115.53) +test encode::hex::bench1_32b ... bench: 102.98 ns/iter (+/- 0.75) +test encode::hex::bench2_256b ... bench: 721.27 ns/iter (+/- 4.31) +test encode::hex::bench3_2k ... bench: 5,659.67 ns/iter (+/- 18.84) +test encode::hex::bench4_16k ... bench: 45,138.29 ns/iter (+/- 352.13) +test encode::hex::bench5_128k ... bench: 361,400.70 ns/iter (+/- 1,472.30) +test encode::hex::bench6_1m ... bench: 3,210,824.02 ns/iter (+/- 207,640.35) + +test encode_to_slice::const_hex::bench1_32b ... bench: 1.56 ns/iter (+/- 0.00) +test encode_to_slice::const_hex::bench2_256b ... bench: 6.72 ns/iter (+/- 0.03) +test encode_to_slice::const_hex::bench3_2k ... bench: 58.79 ns/iter (+/- 1.45) +test encode_to_slice::const_hex::bench4_16k ... bench: 510.57 ns/iter (+/- 11.70) +test encode_to_slice::const_hex::bench5_128k ... bench: 4,030.22 ns/iter (+/- 76.92) +test encode_to_slice::const_hex::bench6_1m ... bench: 35,273.20 ns/iter (+/- 583.54) +test encode_to_slice::faster_hex::bench1_32b ... bench: 4.52 ns/iter (+/- 0.03) +test encode_to_slice::faster_hex::bench2_256b ... bench: 8.09 ns/iter (+/- 0.02) +test encode_to_slice::faster_hex::bench3_2k ... bench: 53.83 ns/iter (+/- 1.28) +test encode_to_slice::faster_hex::bench4_16k ... bench: 450.39 ns/iter (+/- 6.73) +test encode_to_slice::faster_hex::bench5_128k ... bench: 3,444.01 ns/iter (+/- 17.74) +test encode_to_slice::faster_hex::bench6_1m ... bench: 29,645.36 ns/iter (+/- 535.00) +test encode_to_slice::hex::bench1_32b ... bench: 12.08 ns/iter (+/- 0.11) +test encode_to_slice::hex::bench2_256b ... bench: 119.24 ns/iter (+/- 0.48) +test encode_to_slice::hex::bench3_2k ... bench: 988.01 ns/iter (+/- 11.35) +test encode_to_slice::hex::bench4_16k ... bench: 8,044.36 ns/iter (+/- 54.57) +test encode_to_slice::hex::bench5_128k ... bench: 64,068.07 ns/iter (+/- 954.12) +test encode_to_slice::hex::bench6_1m ... bench: 517,206.80 ns/iter (+/- 4,775.29) + +test format::const_hex::bench1_32b ... bench: 10.15 ns/iter (+/- 0.14) +test format::const_hex::bench2_256b ... bench: 17.32 ns/iter (+/- 1.00) +test format::const_hex::bench3_2k ... bench: 116.15 ns/iter (+/- 5.37) +test format::const_hex::bench4_16k ... bench: 1,102.71 ns/iter (+/- 6.87) +test format::const_hex::bench5_128k ... bench: 8,784.66 ns/iter (+/- 108.90) +test format::const_hex::bench6_1m ... bench: 77,741.10 ns/iter (+/- 2,452.30) +test format::std::bench1_32b ... bench: 385.04 ns/iter (+/- 2.50) +test format::std::bench2_256b ... bench: 2,979.01 ns/iter (+/- 226.14) +test format::std::bench3_2k ... bench: 24,019.65 ns/iter (+/- 118.96) +test format::std::bench4_16k ... bench: 200,691.74 ns/iter (+/- 1,243.46) +test format::std::bench5_128k ... bench: 1,565,830.30 ns/iter (+/- 96,284.89) +test format::std::bench6_1m ... bench: 12,532,954.20 ns/iter (+/- 400,001.89) ``` ## Acknowledgements