Skip to content

Commit b6b7d9e

Browse files
committed
Massively enhance performance
1 parent bd88819 commit b6b7d9e

9 files changed

+542
-403
lines changed

Cargo.lock

+20-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ license = "Apache-2.0/GPL-3.0"
1818
name = "array-bytes"
1919
readme = "README.md"
2020
repository = "https://github.com/hack-ink/array-bytes"
21-
version = "7.1.0"
21+
version = "8.0.0"
2222

2323
[profile.ci-dev]
2424
incremental = false
2525
inherits = "dev"
2626

2727
[dependencies]
28-
serde = { version = "1.0", optional = true, default-features = false }
28+
serde = { version = "1.0", optional = true, default-features = false }
29+
smallvec = { version = "1.13" }
2930

3031
[dev-dependencies]
3132
const-hex = { version = "1.13" }

README.md

+23-77
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
- type `AsRef<[u8]> -> u64`
3030
- type `AsRef<[u8]> -> u128`
3131
- Convert hex to array
32-
- type `AsRef<[u8]> -> [u8; N]`, `N = { [1, 64], 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536 }`
32+
- type `AsRef<[u8]> -> [u8; N]`
33+
- type `AsRef<[u8]> -> SmallVec<[u8; 64]>`
3334
- type `AsRef<[u8]> -> Vec<u8>`
3435

3536
#### `Hex` trait
@@ -47,9 +48,11 @@
4748
- type `u64 -> String`
4849
- type `u128 -> String`
4950
- Convert array to hex
50-
- type `Vec<u8> -> String`
51-
- type `[u8; N] -> String`, `N = { [1, 64], 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536 }`
51+
- type `[u8; N] -> String`
52+
- type `&[u8; N] -> String`
5253
- type `&[u8] -> String`
54+
- type `Vec<u8> -> String`
55+
- type `&Vec<u8> -> String`
5356

5457
#### `slice` prefixed functions
5558
- Build fixed length `Array` from `Slice`
@@ -73,7 +76,7 @@
7376
- Transform hex from `Array`
7477
- type `&str -> [u8; N]`
7578
- Convert hex to bytes
76-
- type `AsRef<[u8]> -> Vec<u8>`
79+
- type `AsRef<[u8]> -> SmallVec<[u8; 64]>`
7780
- Convert hex to `Slice`
7881
- type `AsRef<[u8]> -> &[u8]`
7982
- Transform hex to `T`
@@ -102,85 +105,28 @@
102105
<div align="right"><sub>Tuesday, January 9th, 2024</sub></div>
103106

104107
```rs
105-
array_bytes::bytes2hex time: [26.426 µs 26.473 µs 26.518 µs]
106-
Found 4 outliers among 100 measurements (4.00%)
107-
2 (2.00%) low mild
108-
1 (1.00%) high mild
109-
1 (1.00%) high severe
110-
111-
const_hex::encode time: [994.78 ns 1.0084 µs 1.0232 µs]
112-
113-
faster_hex::hex_string time: [11.728 µs 11.769 µs 11.815 µs]
114-
108+
array_bytes::bytes2hex time: [11.175 µs 11.198 µs 11.219 µs]
109+
const_hex::encode time: [1.2195 µs 1.2381 µs 1.2564 µs]
110+
faster_hex::hex_string time: [12.058 µs 12.089 µs 12.123 µs]
115111
faster_hex::hex_encode_fallback
116-
time: [11.704 µs 11.737 µs 11.773 µs]
117-
Found 1 outliers among 100 measurements (1.00%)
118-
1 (1.00%) high mild
119-
120-
hex::encode time: [86.105 µs 86.250 µs 86.433 µs]
121-
Found 14 outliers among 100 measurements (14.00%)
122-
1 (1.00%) low severe
123-
4 (4.00%) low mild
124-
6 (6.00%) high mild
125-
3 (3.00%) high severe
126-
127-
rustc_hex::to_hex time: [44.486 µs 45.538 µs 46.723 µs]
128-
Found 16 outliers among 100 measurements (16.00%)
129-
1 (1.00%) low mild
130-
2 (2.00%) high mild
131-
13 (13.00%) high severe
132-
133-
array_bytes::hex2bytes time: [43.576 µs 44.529 µs 45.404 µs]
134-
Performance has regressed.
135-
Found 11 outliers among 100 measurements (11.00%)
136-
7 (7.00%) low mild
137-
4 (4.00%) high mild
112+
time: [12.055 µs 12.095 µs 12.135 µs]
113+
hex::encode time: [73.787 µs 75.290 µs 76.798 µs]
114+
rustc_hex::to_hex time: [43.948 µs 44.517 µs 45.504 µs]
138115

116+
array_bytes::hex2bytes time: [19.294 µs 19.383 µs 19.500 µs]
139117
array_bytes::hex2bytes_unchecked
140-
time: [64.190 µs 65.311 µs 66.359 µs]
141-
142-
array_bytes::hex2slice time: [45.484 µs 46.988 µs 48.736 µs]
143-
Performance has regressed.
144-
Found 12 outliers among 100 measurements (12.00%)
145-
2 (2.00%) high mild
146-
10 (10.00%) high severe
147-
118+
time: [19.507 µs 19.666 µs 19.850 µs]
119+
array_bytes::hex2slice time: [23.608 µs 24.087 µs 24.598 µs]
148120
array_bytes::hex2slice_unchecked
149-
time: [62.339 µs 63.317 µs 64.279 µs]
150-
Performance has regressed.
151-
152-
const_hex::decode time: [13.601 µs 13.629 µs 13.665 µs]
153-
Performance has improved.
154-
Found 2 outliers among 100 measurements (2.00%)
155-
1 (1.00%) low mild
156-
1 (1.00%) high severe
157-
158-
faster_hex::hex_decode time: [28.015 µs 28.061 µs 28.110 µs]
159-
Performance has improved.
160-
Found 1 outliers among 100 measurements (1.00%)
161-
1 (1.00%) high mild
162-
121+
time: [21.853 µs 22.428 µs 23.048 µs]
122+
const_hex::decode time: [13.999 µs 14.018 µs 14.037 µs]
123+
faster_hex::hex_decode time: [28.983 µs 29.028 µs 29.075 µs]
163124
faster_hex::hex_decode_unchecked
164-
time: [11.782 µs 11.797 µs 11.812 µs]
165-
Found 3 outliers among 100 measurements (3.00%)
166-
2 (2.00%) low severe
167-
1 (1.00%) low mild
168-
125+
time: [11.908 µs 11.926 µs 11.947 µs]
169126
faster_hex::hex_decode_fallback
170-
time: [11.748 µs 11.767 µs 11.785 µs]
171-
Found 7 outliers among 100 measurements (7.00%)
172-
2 (2.00%) low severe
173-
4 (4.00%) low mild
174-
1 (1.00%) high mild
175-
176-
hex::decode time: [93.055 µs 94.781 µs 96.583 µs]
177-
178-
hex::decode_to_slice time: [31.949 µs 33.509 µs 35.285 µs]
179-
Found 13 outliers among 100 measurements (13.00%)
180-
5 (5.00%) high mild
181-
8 (8.00%) high severe
182-
183-
rustc_hex::from_hex time: [105.99 µs 108.05 µs 110.11 µs]
127+
time: [11.909 µs 11.924 µs 11.940 µs]
128+
hex::decode time: [96.566 µs 99.398 µs 102.23 µs]
129+
hex::decode_to_slice time: [41.424 µs 42.312 µs 43.448 µs]
184130
```
185131

186132
<div align="right">

0 commit comments

Comments
 (0)