|
1 | 1 | <div align="center">
|
2 | 2 |
|
3 |
| -<!-- Logo --> |
4 |
| -<!-- ![array-bytes]() --> |
5 |
| - |
6 | 3 | # array-bytes
|
7 | 4 | ### A Collection of Array/Bytes/Hex Utilities.
|
8 | 5 |
|
|
18 | 15 | ## Abilities
|
19 | 16 | #### `TryFromHex` trait
|
20 | 17 | - Convert `Hex` to `Num`
|
21 |
| - - type `&str -> isize` |
22 |
| - - type `&str -> i8` |
23 |
| - - type `&str -> i16` |
24 |
| - - type `&str -> i32` |
25 |
| - - type `&str -> i64` |
26 |
| - - type `&str -> i128` |
27 |
| - - type `&str -> usize` |
28 |
| - - type `&str -> u8` |
29 |
| - - type `&str -> u16` |
30 |
| - - type `&str -> u32` |
31 |
| - - type `&str -> u64` |
32 |
| - - type `&str -> u128` |
| 18 | + - type `AsRef<str> -> isize` |
| 19 | + - type `AsRef<str> -> i8` |
| 20 | + - type `AsRef<str> -> i16` |
| 21 | + - type `AsRef<str> -> i32` |
| 22 | + - type `AsRef<str> -> i64` |
| 23 | + - type `AsRef<str> -> i128` |
| 24 | + - type `AsRef<str> -> usize` |
| 25 | + - type `AsRef<str> -> u8` |
| 26 | + - type `AsRef<str> -> u16` |
| 27 | + - type `AsRef<str> -> u32` |
| 28 | + - type `AsRef<str> -> u64` |
| 29 | + - type `AsRef<str> -> u128` |
33 | 30 |
|
34 | 31 | #### `bytes` prefixed functions
|
35 | 32 | - Convert `Bytes` to `Hex`
|
36 |
| - - type `&[u8] -> String` |
| 33 | + - type `AsRef<[u8]> -> String` |
37 | 34 |
|
38 | 35 | #### `hex` prefixed functions
|
39 | 36 | - Convert `HexBytes` to `Hex`
|
40 | 37 | - type `&[u8] -> &str`
|
41 | 38 | - e.g. `b"0x..." -> "0x..."`
|
42 |
| -- Build fixed length `Array` from `Hex` |
| 39 | +- Transform `Hex` from `Array` |
43 | 40 | - type `&str -> [u8; N]`
|
44 | 41 | - Convert `Hex` to `Bytes`
|
45 |
| - - type `&str -> Vec<u8>` |
| 42 | + - type `AsRef<str> -> Vec<u8>` |
| 43 | +- Convert `Hex` to `Slice` |
| 44 | + - type `AsRef<str> -> &[u8]` |
46 | 45 | - Transform `Hex` to `T`
|
47 |
| - - type `&str -> T` |
| 46 | + - type `AsRef<str> -> T` |
48 | 47 | - e.g. `"0x..." -> [u8; 20] -> H160`
|
49 | 48 |
|
50 | 49 | #### `slice` prefixed functions
|
|
73 | 72 | - e.g. `"0x00" -> vec![0_u8]`
|
74 | 73 |
|
75 | 74 | ## Benchmark results
|
76 |
| -<div align="right"><sub>Friday, September 9, 2022</sub></div> |
| 75 | +<div align="right"><sub>Friday, November 25th, 2022</sub></div> |
77 | 76 |
|
78 | 77 | ```rs
|
79 |
| -array_bytes::bytes2hex time: [37.577 µs 37.755 µs 37.914 µs] |
80 |
| - change: [+0.1343% +0.9208% +1.7020%] (p = 0.03 < 0.05) |
81 |
| - Change within noise threshold. |
| 78 | +array_bytes::bytes2hex time: [38.078 µs 38.126 µs 38.177 µs] |
| 79 | + change: [-0.5147% -0.2140% +0.1154%] (p = 0.18 > 0.05) |
| 80 | + No change in performance detected. |
| 81 | +Found 14 outliers among 100 measurements (14.00%) |
| 82 | + 1 (1.00%) low severe |
| 83 | + 2 (2.00%) high mild |
| 84 | + 11 (11.00%) high severe |
82 | 85 |
|
83 |
| -hex::encode time: [56.832 µs 57.056 µs 57.258 µs] |
84 |
| - change: [-0.3311% +0.1929% +0.7251%] (p = 0.47 > 0.05) |
| 86 | +hex::encode time: [136.19 µs 136.65 µs 137.14 µs] |
| 87 | + change: [-0.3002% -0.0359% +0.2459%] (p = 0.81 > 0.05) |
85 | 88 | No change in performance detected.
|
86 |
| -Found 1 outliers among 100 measurements (1.00%) |
87 |
| - 1 (1.00%) low mild |
| 89 | +Found 9 outliers among 100 measurements (9.00%) |
| 90 | + 2 (2.00%) low mild |
| 91 | + 6 (6.00%) high mild |
| 92 | + 1 (1.00%) high severe |
88 | 93 |
|
89 |
| -rustc_hex::to_hex time: [33.522 µs 33.611 µs 33.690 µs] |
90 |
| - change: [+0.0534% +0.4709% +0.9031%] (p = 0.03 < 0.05) |
| 94 | +rustc_hex::to_hex time: [79.155 µs 79.268 µs 79.398 µs] |
| 95 | + change: [-2.9058% -1.8791% -0.9713%] (p = 0.00 < 0.05) |
91 | 96 | Change within noise threshold.
|
92 |
| -Found 10 outliers among 100 measurements (10.00%) |
93 |
| - 10 (10.00%) low mild |
| 97 | +Found 5 outliers among 100 measurements (5.00%) |
| 98 | + 4 (4.00%) high mild |
| 99 | + 1 (1.00%) high severe |
94 | 100 |
|
95 |
| -faster_hex::hex_string time: [7.7683 µs 7.8169 µs 7.8819 µs] |
96 |
| - change: [+3.7564% +4.6695% +5.6205%] (p = 0.00 < 0.05) |
97 |
| - Performance has regressed. |
98 |
| -Found 14 outliers among 100 measurements (14.00%) |
99 |
| - 5 (5.00%) low severe |
100 |
| - 5 (5.00%) low mild |
101 |
| - 1 (1.00%) high mild |
102 |
| - 3 (3.00%) high severe |
| 101 | +faster_hex::hex_string time: [18.483 µs 18.524 µs 18.565 µs] |
| 102 | + change: [-0.6456% -0.3159% -0.0313%] (p = 0.04 < 0.05) |
| 103 | + Change within noise threshold. |
| 104 | +Found 11 outliers among 100 measurements (11.00%) |
| 105 | + 1 (1.00%) low mild |
| 106 | + 8 (8.00%) high mild |
| 107 | + 2 (2.00%) high severe |
103 | 108 |
|
104 | 109 | faster_hex::hex_encode_fallback
|
105 |
| - time: [7.7536 µs 7.7740 µs 7.7936 µs] |
106 |
| - change: [+1.3656% +1.9964% +2.6314%] (p = 0.00 < 0.05) |
107 |
| - Performance has regressed. |
108 |
| -Found 2 outliers among 100 measurements (2.00%) |
109 |
| - 2 (2.00%) low mild |
| 110 | + time: [18.497 µs 18.528 µs 18.561 µs] |
| 111 | + change: [-11.257% -4.9349% -0.9424%] (p = 0.08 > 0.05) |
| 112 | + No change in performance detected. |
| 113 | +Found 8 outliers among 100 measurements (8.00%) |
| 114 | + 6 (6.00%) high mild |
| 115 | + 2 (2.00%) high severe |
110 | 116 |
|
111 |
| -array_bytes::hex2bytes time: [136.78 µs 137.66 µs 138.57 µs] |
112 |
| - change: [+0.1075% +0.8175% +1.5436%] (p = 0.02 < 0.05) |
| 117 | +array_bytes::hex2bytes time: [224.34 µs 224.59 µs 224.86 µs] |
| 118 | + change: [-1.7703% -1.2368% -0.7744%] (p = 0.00 < 0.05) |
113 | 119 | Change within noise threshold.
|
114 |
| -Found 6 outliers among 100 measurements (6.00%) |
115 |
| - 5 (5.00%) low mild |
| 120 | +Found 4 outliers among 100 measurements (4.00%) |
| 121 | + 3 (3.00%) high mild |
116 | 122 | 1 (1.00%) high severe
|
117 | 123 |
|
118 | 124 | array_bytes::hex2bytes_unchecked
|
119 |
| - time: [103.12 µs 103.49 µs 103.82 µs] |
120 |
| - change: [-0.7568% -0.2119% +0.3349%] (p = 0.44 > 0.05) |
| 125 | + time: [222.78 µs 223.07 µs 223.39 µs] |
| 126 | + change: [-0.5184% -0.1710% +0.1429%] (p = 0.32 > 0.05) |
121 | 127 | No change in performance detected.
|
| 128 | +Found 9 outliers among 100 measurements (9.00%) |
| 129 | + 7 (7.00%) high mild |
| 130 | + 2 (2.00%) high severe |
| 131 | + |
| 132 | +array_bytes::hex2slice time: [211.37 µs 211.49 µs 211.62 µs] |
| 133 | + change: [-3.1739% -2.1127% -1.2688%] (p = 0.00 < 0.05) |
| 134 | + Performance has improved. |
122 | 135 | Found 6 outliers among 100 measurements (6.00%)
|
123 | 136 | 2 (2.00%) low severe
|
124 |
| - 4 (4.00%) low mild |
| 137 | + 4 (4.00%) high severe |
125 | 138 |
|
126 |
| -hex::decode time: [105.65 µs 106.15 µs 106.65 µs] |
127 |
| - change: [-1.4824% -0.9722% -0.4135%] (p = 0.00 < 0.05) |
| 139 | +array_bytes::hex2slice_unchecked |
| 140 | + time: [212.00 µs 212.34 µs 212.71 µs] |
| 141 | + change: [-0.8427% -0.5482% -0.2810%] (p = 0.00 < 0.05) |
128 | 142 | Change within noise threshold.
|
129 |
| -Found 2 outliers among 100 measurements (2.00%) |
| 143 | +Found 9 outliers among 100 measurements (9.00%) |
130 | 144 | 1 (1.00%) low mild
|
131 |
| - 1 (1.00%) high mild |
| 145 | + 6 (6.00%) high mild |
| 146 | + 2 (2.00%) high severe |
132 | 147 |
|
133 |
| -rustc_hex::from_hex time: [66.218 µs 66.473 µs 66.750 µs] |
134 |
| - change: [-0.0431% +0.6585% +1.4552%] (p = 0.08 > 0.05) |
135 |
| - No change in performance detected. |
136 |
| -Found 9 outliers among 100 measurements (9.00%) |
137 |
| - 1 (1.00%) low severe |
| 148 | +hex::decode time: [244.37 µs 244.78 µs 245.25 µs] |
| 149 | + change: [-1.4130% -1.0496% -0.7133%] (p = 0.00 < 0.05) |
| 150 | + Change within noise threshold. |
| 151 | +Found 8 outliers among 100 measurements (8.00%) |
| 152 | + 5 (5.00%) high mild |
| 153 | + 3 (3.00%) high severe |
| 154 | + |
| 155 | +hex::decode_to_slice time: [166.67 µs 166.90 µs 167.16 µs] |
| 156 | + change: [+0.1484% +0.3293% +0.5160%] (p = 0.00 < 0.05) |
| 157 | + Change within noise threshold. |
| 158 | +Found 3 outliers among 100 measurements (3.00%) |
| 159 | + 3 (3.00%) high mild |
| 160 | + |
| 161 | +rustc_hex::from_hex time: [176.56 µs 177.79 µs 179.13 µs] |
| 162 | + change: [+1.4009% +2.5404% +3.5866%] (p = 0.00 < 0.05) |
| 163 | + Performance has regressed. |
| 164 | +Found 5 outliers among 100 measurements (5.00%) |
138 | 165 | 2 (2.00%) low mild
|
139 |
| - 4 (4.00%) high mild |
| 166 | + 1 (1.00%) high mild |
140 | 167 | 2 (2.00%) high severe
|
141 | 168 |
|
142 |
| -faster_hex::hex_decode time: [16.136 µs 16.211 µs 16.324 µs] |
143 |
| - change: [-2.4694% -1.9531% -1.4089%] (p = 0.00 < 0.05) |
144 |
| - Performance has improved. |
145 |
| -Found 7 outliers among 100 measurements (7.00%) |
146 |
| - 2 (2.00%) low mild |
147 |
| - 2 (2.00%) high mild |
148 |
| - 3 (3.00%) high severe |
| 169 | +faster_hex::hex_decode time: [39.127 µs 39.342 µs 39.582 µs] |
| 170 | + change: [-0.0442% +0.3160% +0.6546%] (p = 0.08 > 0.05) |
| 171 | + No change in performance detected. |
| 172 | +Found 18 outliers among 100 measurements (18.00%) |
| 173 | + 3 (3.00%) low severe |
| 174 | + 8 (8.00%) high mild |
| 175 | + 7 (7.00%) high severe |
149 | 176 |
|
150 | 177 | faster_hex::hex_decode_unchecked
|
151 |
| - time: [6.7977 µs 6.8215 µs 6.8475 µs] |
152 |
| - change: [-1.4235% -0.5587% +0.2182%] (p = 0.20 > 0.05) |
153 |
| - No change in performance detected. |
154 |
| -Found 5 outliers among 100 measurements (5.00%) |
155 |
| - 1 (1.00%) low mild |
156 |
| - 3 (3.00%) high mild |
157 |
| - 1 (1.00%) high severe |
| 178 | + time: [16.429 µs 16.479 µs 16.538 µs] |
| 179 | + change: [+0.5738% +0.9176% +1.3113%] (p = 0.00 < 0.05) |
| 180 | + Change within noise threshold. |
| 181 | +Found 14 outliers among 100 measurements (14.00%) |
| 182 | + 6 (6.00%) high mild |
| 183 | + 8 (8.00%) high severe |
158 | 184 |
|
159 | 185 | faster_hex::hex_decode_fallback
|
160 |
| - time: [6.7799 µs 6.8003 µs 6.8209 µs] |
161 |
| - change: [-1.9470% -1.3817% -0.8203%] (p = 0.00 < 0.05) |
| 186 | + time: [16.422 µs 16.440 µs 16.460 µs] |
| 187 | + change: [+0.3595% +0.6397% +0.9141%] (p = 0.00 < 0.05) |
162 | 188 | Change within noise threshold.
|
163 |
| -Found 4 outliers among 100 measurements (4.00%) |
164 |
| - 4 (4.00%) high mild |
| 189 | +Found 5 outliers among 100 measurements (5.00%) |
| 190 | + 1 (1.00%) high mild |
| 191 | + 4 (4.00%) high severe |
165 | 192 | ```
|
166 | 193 |
|
167 | 194 | <div align="right">
|
|
0 commit comments