|
29 | 29 | - type `AsRef<[u8]> -> u64`
|
30 | 30 | - type `AsRef<[u8]> -> u128`
|
31 | 31 | - Convert hex to array
|
32 |
| - - type `AsRef<[u8]> -> [u8; N]`, `N = { [1, 64], 128, 256, 512 }` |
| 32 | + - type `AsRef<[u8]> -> [u8; N]`, `N = { [1, 64], 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536 }` |
33 | 33 | - type `AsRef<[u8]> -> Vec<u8>`
|
34 | 34 |
|
35 | 35 | #### `Hex` trait
|
|
48 | 48 | - type `u128 -> String`
|
49 | 49 | - Convert array to hex
|
50 | 50 | - type `Vec<u8> -> String`
|
51 |
| - - type `[u8; N] -> String`, `N = { [1, 64], 128, 256, 512 }` |
| 51 | + - type `[u8; N] -> String`, `N = { [1, 64], 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536 }` |
52 | 52 | - type `&[u8] -> String`
|
53 | 53 |
|
54 | 54 | #### `slice` prefixed functions
|
|
91 | 91 | - `#[serde(deserialize_with = "array_bytes::hex_deserialize_n_into")]`
|
92 | 92 | - type `S -> T`
|
93 | 93 | - e.g. `"0x..." -> H160`
|
94 |
| -- `#[serde(deserialize_with = "array_bytes::de_hex2num")]` |
95 |
| - - type `S -> Num` |
| 94 | +- `#[serde(deserialize_with = "array_bytes::de_try_from_hex")]` |
| 95 | + - type `S -> impl TryFromHex` |
96 | 96 | - e.g. `"0xA" -> 10_u32`
|
97 |
| -- `#[serde(deserialize_with = "array_bytes::de_hex2bytes")]` |
98 |
| - - type `S -> Vec<u8>` |
| 97 | +- `#[serde(serialize_with = "array_bytes::se_hex")]` |
| 98 | + - type `S -> impl Hex` |
99 | 99 | - e.g. `"0x00" -> vec![0_u8]`
|
100 | 100 |
|
101 | 101 | ## Benchmark results
|
102 | 102 | <div align="right"><sub>Tuesday, January 9th, 2024</sub></div>
|
103 | 103 |
|
104 | 104 | ```rs
|
105 |
| -array_bytes::bytes2hex time: [30.487 µs 30.513 µs 30.543 µs] |
106 |
| - change: [-12.758% -7.1673% -2.3095%] (p = 0.00 < 0.05) |
107 |
| - Performance has improved. |
| 105 | +array_bytes::bytes2hex time: [26.426 µs 26.473 µs 26.518 µs] |
108 | 106 | Found 4 outliers among 100 measurements (4.00%)
|
109 |
| - 3 (3.00%) high mild |
| 107 | + 2 (2.00%) low mild |
| 108 | + 1 (1.00%) high mild |
110 | 109 | 1 (1.00%) high severe
|
111 | 110 |
|
112 |
| -const_hex::encode time: [2.1197 µs 2.2245 µs 2.3208 µs] |
113 |
| - change: [+25.796% +31.010% +36.449%] (p = 0.00 < 0.05) |
114 |
| - Performance has regressed. |
| 111 | +const_hex::encode time: [994.78 ns 1.0084 µs 1.0232 µs] |
115 | 112 |
|
116 |
| -faster_hex::hex_string time: [13.666 µs 13.711 µs 13.754 µs] |
117 |
| - change: [-0.3508% +0.0892% +0.5043%] (p = 0.68 > 0.05) |
118 |
| - No change in performance detected. |
| 113 | +faster_hex::hex_string time: [11.728 µs 11.769 µs 11.815 µs] |
119 | 114 |
|
120 | 115 | faster_hex::hex_encode_fallback
|
121 |
| - time: [13.476 µs 13.519 µs 13.564 µs] |
122 |
| - change: [-0.1799% +0.2323% +0.6560%] (p = 0.27 > 0.05) |
123 |
| - No change in performance detected. |
| 116 | + time: [11.704 µs 11.737 µs 11.773 µs] |
124 | 117 | Found 1 outliers among 100 measurements (1.00%)
|
125 | 118 | 1 (1.00%) high mild
|
126 | 119 |
|
127 |
| -hex::encode time: [133.99 µs 135.65 µs 137.13 µs] |
128 |
| - change: [-1.6763% +0.2181% +2.1203%] (p = 0.82 > 0.05) |
129 |
| - No change in performance detected. |
130 |
| -Found 15 outliers among 100 measurements (15.00%) |
131 |
| - 13 (13.00%) low severe |
132 |
| - 2 (2.00%) low mild |
| 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 |
133 | 126 |
|
134 |
| -rustc_hex::to_hex time: [118.83 µs 124.46 µs 129.51 µs] |
135 |
| - change: [-3.5525% +2.8439% +10.307%] (p = 0.42 > 0.05) |
136 |
| - No change in performance detected. |
| 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 |
137 | 132 |
|
138 |
| -array_bytes::hex2bytes time: [46.892 µs 47.510 µs 48.195 µs] |
139 |
| - change: [-8.2282% -6.5411% -4.6367%] (p = 0.00 < 0.05) |
140 |
| - Performance has improved. |
141 |
| -Found 6 outliers among 100 measurements (6.00%) |
142 |
| - 1 (1.00%) high mild |
143 |
| - 5 (5.00%) high severe |
| 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 |
144 | 138 |
|
145 | 139 | array_bytes::hex2bytes_unchecked
|
146 |
| - time: [73.450 µs 73.842 µs 74.251 µs] |
147 |
| - change: [+0.5740% +1.3693% +2.1806%] (p = 0.00 < 0.05) |
148 |
| - Change within noise threshold. |
149 |
| -Found 17 outliers among 100 measurements (17.00%) |
150 |
| - 11 (11.00%) low mild |
151 |
| - 5 (5.00%) high mild |
152 |
| - 1 (1.00%) high severe |
| 140 | + time: [64.190 µs 65.311 µs 66.359 µs] |
153 | 141 |
|
154 |
| -array_bytes::hex2slice time: [57.825 µs 57.915 µs 58.007 µs] |
155 |
| - change: [-0.9051% -0.6249% -0.3523%] (p = 0.00 < 0.05) |
156 |
| - Change within noise threshold. |
157 |
| -Found 6 outliers among 100 measurements (6.00%) |
158 |
| - 6 (6.00%) high mild |
| 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 |
159 | 147 |
|
160 | 148 | array_bytes::hex2slice_unchecked
|
161 |
| - time: [73.574 µs 73.917 µs 74.281 µs] |
162 |
| - change: [-4.9137% -4.1840% -3.4519%] (p = 0.00 < 0.05) |
163 |
| - Performance has improved. |
164 |
| -Found 13 outliers among 100 measurements (13.00%) |
165 |
| - 8 (8.00%) high mild |
166 |
| - 5 (5.00%) high severe |
| 149 | + time: [62.339 µs 63.317 µs 64.279 µs] |
| 150 | + Performance has regressed. |
167 | 151 |
|
168 |
| -const_hex::decode time: [15.849 µs 15.887 µs 15.924 µs] |
169 |
| - change: [-3.1788% -2.1280% -1.2019%] (p = 0.00 < 0.05) |
| 152 | +const_hex::decode time: [13.601 µs 13.629 µs 13.665 µs] |
170 | 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 |
171 | 157 |
|
172 |
| -faster_hex::hex_decode time: [31.735 µs 31.764 µs 31.800 µs] |
173 |
| - change: [-0.7403% -0.5216% -0.2674%] (p = 0.00 < 0.05) |
174 |
| - Change within noise threshold. |
175 |
| -Found 7 outliers among 100 measurements (7.00%) |
176 |
| - 5 (5.00%) high mild |
177 |
| - 2 (2.00%) high severe |
| 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 |
178 | 162 |
|
179 | 163 | faster_hex::hex_decode_unchecked
|
180 |
| - time: [13.059 µs 13.098 µs 13.145 µs] |
181 |
| - change: [-0.7125% -0.3968% -0.1100%] (p = 0.01 < 0.05) |
182 |
| - Change within noise threshold. |
183 |
| -Found 10 outliers among 100 measurements (10.00%) |
184 |
| - 6 (6.00%) high mild |
185 |
| - 4 (4.00%) high severe |
| 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 |
186 | 168 |
|
187 | 169 | faster_hex::hex_decode_fallback
|
188 |
| - time: [13.074 µs 13.090 µs 13.108 µs] |
189 |
| - change: [-1.9404% -1.5652% -1.1912%] (p = 0.00 < 0.05) |
190 |
| - Performance has improved. |
191 |
| -Found 9 outliers among 100 measurements (9.00%) |
192 |
| - 5 (5.00%) high mild |
193 |
| - 4 (4.00%) high severe |
| 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 |
194 | 175 |
|
195 |
| -hex::decode time: [131.19 µs 132.57 µs 134.26 µs] |
196 |
| - change: [+1.9126% +3.2801% +4.8702%] (p = 0.00 < 0.05) |
197 |
| - Performance has regressed. |
198 |
| -Found 15 outliers among 100 measurements (15.00%) |
199 |
| - 15 (15.00%) high severe |
| 176 | +hex::decode time: [93.055 µs 94.781 µs 96.583 µs] |
200 | 177 |
|
201 |
| -hex::decode_to_slice time: [57.577 µs 58.018 µs 58.447 µs] |
202 |
| - change: [+0.0185% +1.1253% +2.2104%] (p = 0.04 < 0.05) |
203 |
| - Change within noise threshold. |
204 |
| -Found 2 outliers among 100 measurements (2.00%) |
205 |
| - 1 (1.00%) high mild |
206 |
| - 1 (1.00%) high severe |
| 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 |
207 | 182 |
|
208 |
| -rustc_hex::from_hex time: [130.19 µs 130.86 µs 131.48 µs] |
209 |
| - change: [-1.8542% -1.4374% -0.9862%] (p = 0.00 < 0.05) |
210 |
| - Change within noise threshold. |
211 |
| -Found 2 outliers among 100 measurements (2.00%) |
212 |
| - 2 (2.00%) high mild |
| 183 | +rustc_hex::from_hex time: [105.99 µs 108.05 µs 110.11 µs] |
213 | 184 | ```
|
214 | 185 |
|
215 | 186 | <div align="right">
|
|
0 commit comments