Bitcoin Core
28.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
src
bench
base58.cpp
Go to the documentation of this file.
1
// Copyright (c) 2016-2022 The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#include <
bench/bench.h
>
6
7
#include <
base58.h
>
8
9
#include <array>
10
#include <vector>
11
12
13
static
void
Base58Encode
(
benchmark::Bench
& bench)
14
{
15
static
const
std::array<unsigned char, 32> buff = {
16
{
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
20
}
21
};
22
bench.
batch
(buff.size()).
unit
(
"byte"
).
run
([&] {
23
EncodeBase58
(buff);
24
});
25
}
26
27
28
static
void
Base58CheckEncode
(
benchmark::Bench
& bench)
29
{
30
static
const
std::array<unsigned char, 32> buff = {
31
{
32
17, 79, 8, 99, 150, 189, 208, 162, 22, 23, 203, 163, 36, 58, 147,
33
227, 139, 2, 215, 100, 91, 38, 11, 141, 253, 40, 117, 21, 16, 90,
34
200, 24
35
}
36
};
37
bench.
batch
(buff.size()).
unit
(
"byte"
).
run
([&] {
38
EncodeBase58Check
(buff);
39
});
40
}
41
42
43
static
void
Base58Decode
(
benchmark::Bench
& bench)
44
{
45
const
char
* addr =
"17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem"
;
46
std::vector<unsigned char> vch;
47
bench.
batch
(strlen(addr)).
unit
(
"byte"
).
run
([&] {
48
(void)
DecodeBase58
(addr, vch, 64);
49
});
50
}
51
52
53
BENCHMARK
(
Base58Encode
,
benchmark::PriorityLevel::HIGH
);
54
BENCHMARK
(
Base58CheckEncode
,
benchmark::PriorityLevel::HIGH
);
55
BENCHMARK
(
Base58Decode
,
benchmark::PriorityLevel::HIGH
);
EncodeBase58
std::string EncodeBase58(Span< const unsigned char > input)
Why base-58 instead of standard base-64 encoding?
Definition
base58.cpp:89
EncodeBase58Check
std::string EncodeBase58Check(Span< const unsigned char > input)
Encode a byte span into a base58-encoded string, including checksum.
Definition
base58.cpp:137
DecodeBase58
static bool DecodeBase58(const char *psz, std::vector< unsigned char > &vch, int max_ret_len)
Definition
base58.cpp:40
base58.h
Base58Decode
static void Base58Decode(benchmark::Bench &bench)
Definition
base58.cpp:43
Base58Encode
static void Base58Encode(benchmark::Bench &bench)
Definition
base58.cpp:13
Base58CheckEncode
static void Base58CheckEncode(benchmark::Bench &bench)
Definition
base58.cpp:28
bench.h
BENCHMARK
#define BENCHMARK(n, priority_level)
Definition
bench.h:79
ankerl::nanobench::Bench
Main entry point to nanobench's benchmarking facility.
Definition
nanobench.h:627
ankerl::nanobench::Bench::run
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition
nanobench.h:1234
ankerl::nanobench::Bench::batch
Bench & batch(T b) noexcept
Sets the batch size.
Definition
nanobench.h:1258
ankerl::nanobench::Bench::unit
Bench & unit(char const *unit)
Sets the operation unit.
benchmark::HIGH
@ HIGH
Definition
bench.h:47
Generated on Thu Oct 3 2024 09:20:15 for Bitcoin Core by
1.12.0