|
7 | 7 | #include "validation.h"
|
8 | 8 | #include "base58.h"
|
9 | 9 |
|
| 10 | +#include <array> |
10 | 11 | #include <vector>
|
11 | 12 | #include <string>
|
12 | 13 |
|
13 | 14 |
|
14 | 15 | static void Base58Encode(benchmark::State& state)
|
15 | 16 | {
|
16 |
| - unsigned char buff[32] = { |
17 |
| - 17, 79, 8, 99, 150, 189, 208, 162, 22, 23, 203, 163, 36, 58, 147, |
18 |
| - 227, 139, 2, 215, 100, 91, 38, 11, 141, 253, 40, 117, 21, 16, 90, |
19 |
| - 200, 24 |
| 17 | + static const std::array<unsigned char, 32> buff = { |
| 18 | + { |
| 19 | + 17, 79, 8, 99, 150, 189, 208, 162, 22, 23, 203, 163, 36, 58, 147, |
| 20 | + 227, 139, 2, 215, 100, 91, 38, 11, 141, 253, 40, 117, 21, 16, 90, |
| 21 | + 200, 24 |
| 22 | + } |
20 | 23 | };
|
21 |
| - unsigned char* b = buff; |
22 | 24 | while (state.KeepRunning()) {
|
23 |
| - EncodeBase58(b, b + 32); |
| 25 | + EncodeBase58(buff.begin(), buff.end()); |
24 | 26 | }
|
25 | 27 | }
|
26 | 28 |
|
27 | 29 |
|
28 | 30 | static void Base58CheckEncode(benchmark::State& state)
|
29 | 31 | {
|
30 |
| - unsigned char buff[32] = { |
31 |
| - 17, 79, 8, 99, 150, 189, 208, 162, 22, 23, 203, 163, 36, 58, 147, |
32 |
| - 227, 139, 2, 215, 100, 91, 38, 11, 141, 253, 40, 117, 21, 16, 90, |
33 |
| - 200, 24 |
| 32 | + static const std::array<unsigned char, 32> buff = { |
| 33 | + { |
| 34 | + 17, 79, 8, 99, 150, 189, 208, 162, 22, 23, 203, 163, 36, 58, 147, |
| 35 | + 227, 139, 2, 215, 100, 91, 38, 11, 141, 253, 40, 117, 21, 16, 90, |
| 36 | + 200, 24 |
| 37 | + } |
34 | 38 | };
|
35 |
| - unsigned char* b = buff; |
36 | 39 | std::vector<unsigned char> vch;
|
37 |
| - vch.assign(b, b + 32); |
| 40 | + vch.assign(buff.begin(), buff.end()); |
38 | 41 | while (state.KeepRunning()) {
|
39 | 42 | EncodeBase58Check(vch);
|
40 | 43 | }
|
|
0 commit comments