diff --git a/Cargo.lock b/Cargo.lock index 926a5f9..9ffef64 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -95,18 +95,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.11" +version = "4.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" +checksum = "33e92c5c1a78c62968ec57dbc2440366a2d6e5a23faf829970ff1585dc6b18e2" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.4.11" +version = "4.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" +checksum = "f4323769dc8a61e2c39ad7dc26f6f2800524691a44d74fe3d1071a5c24db6370" dependencies = [ "anstyle", "clap_lex", @@ -178,36 +178,28 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ - "cfg-if", "crossbeam-epoch", "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" -version = "0.9.15" +version = "0.9.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" dependencies = [ - "autocfg", - "cfg-if", "crossbeam-utils", - "memoffset", - "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.16" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" -dependencies = [ - "cfg-if", -] +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" [[package]] name = "either" @@ -222,7 +214,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] @@ -265,13 +257,13 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "is-terminal" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455" dependencies = [ "hermit-abi", "rustix", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -285,9 +277,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "js-sys" @@ -306,9 +298,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.150" +version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" [[package]] name = "libm" @@ -330,18 +322,9 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "memchr" -version = "2.6.4" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" - -[[package]] -name = "memoffset" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "num-traits" @@ -355,9 +338,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "oorandom" @@ -529,22 +512,22 @@ checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" [[package]] name = "rustix" -version = "0.38.26" +version = "0.38.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9470c4bf8246c8daf25f9598dca807fb6510347b1e1cfa55749113850c79d88a" +checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" dependencies = [ "bitflags", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "same-file" @@ -555,12 +538,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "serde" version = "1.0.195" @@ -736,37 +713,13 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows-targets", ] [[package]] @@ -775,93 +728,51 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_i686_msvc" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[package]] name = "windows_x86_64_gnu" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - [[package]] name = "windows_x86_64_msvc" version = "0.52.0" diff --git a/Cargo.toml b/Cargo.toml index 25cb7e1..eb6d409 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,11 +28,11 @@ inherits = "dev" serde = { version = "1.0", optional = true, default-features = false } [dev-dependencies] +const-hex = { version = "1.10" } criterion = { version = "0.5" } faster-hex = { version = "0.9" } hex = { version = "0.4" } rustc-hex = { version = "2.1" } -const-hex = { version = "1.1" } serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0" } diff --git a/README.md b/README.md index 82891b2..53e3487 100644 --- a/README.md +++ b/README.md @@ -98,111 +98,117 @@ - e.g. `"0x00" -> vec![0_u8]` ## Benchmark results -
Friday, November 26th, 2022
+
Tuesday, January 9th, 2024
```rs -array_bytes::bytes2hex time: [37.241 µs 37.321 µs 37.407 µs] - change: [-2.2373% -1.9757% -1.7126%] (p = 0.00 < 0.05) +array_bytes::bytes2hex time: [30.487 µs 30.513 µs 30.543 µs] + change: [-12.758% -7.1673% -2.3095%] (p = 0.00 < 0.05) Performance has improved. Found 4 outliers among 100 measurements (4.00%) - 4 (4.00%) high mild - -hex::encode time: [132.17 µs 132.42 µs 132.66 µs] - change: [-2.4772% -2.2353% -1.9952%] (p = 0.00 < 0.05) - Performance has improved. -Found 5 outliers among 100 measurements (5.00%) - 4 (4.00%) high mild + 3 (3.00%) high mild 1 (1.00%) high severe -rustc_hex::to_hex time: [77.565 µs 77.885 µs 78.236 µs] - change: [-1.7109% -1.4392% -1.1561%] (p = 0.00 < 0.05) - Performance has improved. -Found 5 outliers among 100 measurements (5.00%) - 4 (4.00%) high mild - 1 (1.00%) high severe +const_hex::encode time: [2.1197 µs 2.2245 µs 2.3208 µs] + change: [+25.796% +31.010% +36.449%] (p = 0.00 < 0.05) + Performance has regressed. -faster_hex::hex_string time: [18.049 µs 18.091 µs 18.140 µs] - change: [-2.1506% -1.7957% -1.3953%] (p = 0.00 < 0.05) - Performance has improved. -Found 7 outliers among 100 measurements (7.00%) - 5 (5.00%) high mild - 2 (2.00%) high severe +faster_hex::hex_string time: [13.666 µs 13.711 µs 13.754 µs] + change: [-0.3508% +0.0892% +0.5043%] (p = 0.68 > 0.05) + No change in performance detected. faster_hex::hex_encode_fallback - time: [17.978 µs 18.018 µs 18.064 µs] - change: [-2.6657% -2.3283% -1.9846%] (p = 0.00 < 0.05) - Performance has improved. -Found 2 outliers among 100 measurements (2.00%) + time: [13.476 µs 13.519 µs 13.564 µs] + change: [-0.1799% +0.2323% +0.6560%] (p = 0.27 > 0.05) + No change in performance detected. +Found 1 outliers among 100 measurements (1.00%) 1 (1.00%) high mild - 1 (1.00%) high severe -array_bytes::hex2bytes time: [119.27 µs 119.54 µs 119.81 µs] - change: [-2.5026% -2.2957% -2.0423%] (p = 0.00 < 0.05) - Performance has improved. -Found 14 outliers among 100 measurements (14.00%) - 11 (11.00%) high mild - 3 (3.00%) high severe +hex::encode time: [133.99 µs 135.65 µs 137.13 µs] + change: [-1.6763% +0.2181% +2.1203%] (p = 0.82 > 0.05) + No change in performance detected. +Found 15 outliers among 100 measurements (15.00%) + 13 (13.00%) low severe + 2 (2.00%) low mild -array_bytes::hex2bytes_unchecked - time: [82.136 µs 82.324 µs 82.531 µs] - change: [-55.176% -53.193% -52.029%] (p = 0.00 < 0.05) +rustc_hex::to_hex time: [118.83 µs 124.46 µs 129.51 µs] + change: [-3.5525% +2.8439% +10.307%] (p = 0.42 > 0.05) + No change in performance detected. + +array_bytes::hex2bytes time: [46.892 µs 47.510 µs 48.195 µs] + change: [-8.2282% -6.5411% -4.6367%] (p = 0.00 < 0.05) Performance has improved. -Found 15 outliers among 100 measurements (15.00%) - 13 (13.00%) high mild - 2 (2.00%) high severe +Found 6 outliers among 100 measurements (6.00%) + 1 (1.00%) high mild + 5 (5.00%) high severe -array_bytes::hex2slice time: [112.94 µs 113.32 µs 113.78 µs] - change: [-1.6410% -1.1545% -0.6772%] (p = 0.00 < 0.05) +array_bytes::hex2bytes_unchecked + time: [73.450 µs 73.842 µs 74.251 µs] + change: [+0.5740% +1.3693% +2.1806%] (p = 0.00 < 0.05) Change within noise threshold. -Found 3 outliers among 100 measurements (3.00%) - 2 (2.00%) high mild +Found 17 outliers among 100 measurements (17.00%) + 11 (11.00%) low mild + 5 (5.00%) high mild 1 (1.00%) high severe +array_bytes::hex2slice time: [57.825 µs 57.915 µs 58.007 µs] + change: [-0.9051% -0.6249% -0.3523%] (p = 0.00 < 0.05) + Change within noise threshold. +Found 6 outliers among 100 measurements (6.00%) + 6 (6.00%) high mild + array_bytes::hex2slice_unchecked - time: [89.416 µs 89.650 µs 89.956 µs] - change: [-22.750% -22.423% -22.099%] (p = 0.00 < 0.05) + time: [73.574 µs 73.917 µs 74.281 µs] + change: [-4.9137% -4.1840% -3.4519%] (p = 0.00 < 0.05) Performance has improved. -Found 14 outliers among 100 measurements (14.00%) +Found 13 outliers among 100 measurements (13.00%) 8 (8.00%) high mild - 6 (6.00%) high severe + 5 (5.00%) high severe -hex::decode time: [239.97 µs 240.64 µs 241.33 µs] - change: [+0.3733% +0.6910% +1.0245%] (p = 0.00 < 0.05) - Change within noise threshold. -Found 1 outliers among 100 measurements (1.00%) - 1 (1.00%) high mild +const_hex::decode time: [15.849 µs 15.887 µs 15.924 µs] + change: [-3.1788% -2.1280% -1.2019%] (p = 0.00 < 0.05) + Performance has improved. -hex::decode_to_slice time: [162.75 µs 163.12 µs 163.61 µs] - change: [-0.4036% -0.0331% +0.3614%] (p = 0.86 > 0.05) - No change in performance detected. +faster_hex::hex_decode time: [31.735 µs 31.764 µs 31.800 µs] + change: [-0.7403% -0.5216% -0.2674%] (p = 0.00 < 0.05) + Change within noise threshold. Found 7 outliers among 100 measurements (7.00%) - 3 (3.00%) high mild + 5 (5.00%) high mild + 2 (2.00%) high severe + +faster_hex::hex_decode_unchecked + time: [13.059 µs 13.098 µs 13.145 µs] + change: [-0.7125% -0.3968% -0.1100%] (p = 0.01 < 0.05) + Change within noise threshold. +Found 10 outliers among 100 measurements (10.00%) + 6 (6.00%) high mild 4 (4.00%) high severe -rustc_hex::from_hex time: [166.34 µs 167.65 µs 169.03 µs] - change: [-1.5255% -0.5122% +0.5735%] (p = 0.33 > 0.05) - No change in performance detected. +faster_hex::hex_decode_fallback + time: [13.074 µs 13.090 µs 13.108 µs] + change: [-1.9404% -1.5652% -1.1912%] (p = 0.00 < 0.05) + Performance has improved. +Found 9 outliers among 100 measurements (9.00%) + 5 (5.00%) high mild + 4 (4.00%) high severe -faster_hex::hex_decode time: [38.419 µs 38.613 µs 38.812 µs] - change: [-0.9090% -0.3666% +0.1714%] (p = 0.19 > 0.05) - No change in performance detected. -Found 4 outliers among 100 measurements (4.00%) - 4 (4.00%) high mild +hex::decode time: [131.19 µs 132.57 µs 134.26 µs] + change: [+1.9126% +3.2801% +4.8702%] (p = 0.00 < 0.05) + Performance has regressed. +Found 15 outliers among 100 measurements (15.00%) + 15 (15.00%) high severe -faster_hex::hex_decode_unchecked - time: [16.122 µs 16.166 µs 16.212 µs] - change: [-0.2496% +0.1886% +0.6435%] (p = 0.41 > 0.05) - No change in performance detected. -Found 1 outliers among 100 measurements (1.00%) +hex::decode_to_slice time: [57.577 µs 58.018 µs 58.447 µs] + change: [+0.0185% +1.1253% +2.2104%] (p = 0.04 < 0.05) + Change within noise threshold. +Found 2 outliers among 100 measurements (2.00%) 1 (1.00%) high mild + 1 (1.00%) high severe -faster_hex::hex_decode_fallback - time: [16.001 µs 16.039 µs 16.081 µs] - change: [-1.1315% -0.7797% -0.4279%] (p = 0.00 < 0.05) +rustc_hex::from_hex time: [130.19 µs 130.86 µs 131.48 µs] + change: [-1.8542% -1.4374% -0.9862%] (p = 0.00 < 0.05) Change within noise threshold. -Found 8 outliers among 100 measurements (8.00%) - 6 (6.00%) high mild - 2 (2.00%) high severe +Found 2 outliers among 100 measurements (2.00%) + 2 (2.00%) high mild ```
diff --git a/benches/bench.rs b/benches/bench.rs index b601194..16d3645 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -10,12 +10,8 @@ const DATA: &[u8] = include_bytes!("../LICENSE-GPL3"); fn bench_encode(c: &mut Criterion) { c.bench_function("array_bytes::bytes2hex", |b| b.iter(|| array_bytes::bytes2hex("", DATA))); - c.bench_function("hex::encode", |b| b.iter(|| hex::encode(DATA))); - c.bench_function("const_hex::encode", |b| b.iter(|| const_hex::encode(DATA))); - c.bench_function("rustc_hex::to_hex", |b| b.iter(|| DATA.to_hex::())); - c.bench_function("faster_hex::hex_string", |b| b.iter(|| faster_hex::hex_string(DATA))); c.bench_function("faster_hex::hex_encode_fallback", |b| { @@ -27,6 +23,10 @@ fn bench_encode(c: &mut Criterion) { dst }) }); + + c.bench_function("hex::encode", |b| b.iter(|| hex::encode(DATA))); + + c.bench_function("rustc_hex::to_hex", |b| b.iter(|| DATA.to_hex::())); } fn bench_decode(c: &mut Criterion) { @@ -35,13 +35,11 @@ fn bench_decode(c: &mut Criterion) { b.iter(|| array_bytes::hex2bytes(&hex).unwrap()) }); - c.bench_function("array_bytes::hex2bytes_unchecked", |b| { let hex = array_bytes::bytes2hex("", DATA); b.iter(|| array_bytes::hex2bytes_unchecked(&hex)) }); - c.bench_function("array_bytes::hex2slice", |b| { let hex = array_bytes::bytes2hex("", DATA); @@ -53,7 +51,6 @@ fn bench_decode(c: &mut Criterion) { v }) }); - c.bench_function("array_bytes::hex2slice_unchecked", |b| { let hex = array_bytes::bytes2hex("", DATA); @@ -72,12 +69,33 @@ fn bench_decode(c: &mut Criterion) { b.iter(|| const_hex::decode(&hex).unwrap()) }); + c.bench_function("faster_hex::hex_decode", move |b| { + let hex = faster_hex::hex_string(DATA); + let len = DATA.len(); + let mut dst = vec![0; len]; + + b.iter(|| faster_hex::hex_decode(hex.as_bytes(), &mut dst).unwrap()) + }); + c.bench_function("faster_hex::hex_decode_unchecked", |b| { + let hex = faster_hex::hex_string(DATA); + let len = DATA.len(); + let mut dst = vec![0; len]; + + b.iter(|| faster_hex::hex_decode_unchecked(hex.as_bytes(), &mut dst)) + }); + c.bench_function("faster_hex::hex_decode_fallback", |b| { + let hex = faster_hex::hex_string(DATA); + let len = DATA.len(); + let mut dst = vec![0; len]; + + b.iter(|| faster_hex::hex_decode_fallback(hex.as_bytes(), &mut dst)) + }); + c.bench_function("hex::decode", |b| { let hex = hex::encode(DATA); b.iter(|| hex::decode(&hex).unwrap()) }); - c.bench_function("hex::decode_to_slice", |b| { let hex = array_bytes::bytes2hex("", DATA); @@ -95,30 +113,6 @@ fn bench_decode(c: &mut Criterion) { b.iter(|| hex.from_hex::>().unwrap()) }); - - c.bench_function("faster_hex::hex_decode", move |b| { - let hex = faster_hex::hex_string(DATA); - let len = DATA.len(); - let mut dst = vec![0; len]; - - b.iter(|| faster_hex::hex_decode(hex.as_bytes(), &mut dst).unwrap()) - }); - - c.bench_function("faster_hex::hex_decode_unchecked", |b| { - let hex = faster_hex::hex_string(DATA); - let len = DATA.len(); - let mut dst = vec![0; len]; - - b.iter(|| faster_hex::hex_decode_unchecked(hex.as_bytes(), &mut dst)) - }); - - c.bench_function("faster_hex::hex_decode_fallback", |b| { - let hex = faster_hex::hex_string(DATA); - let len = DATA.len(); - let mut dst = vec![0; len]; - - b.iter(|| faster_hex::hex_decode_fallback(hex.as_bytes(), &mut dst)) - }); } criterion::criterion_group!(benches, bench_encode, bench_decode);