Bitcoin ABC
0.34.5
P2P Digital Currency
Loading...
Searching...
No Matches
src
bench
cashaddr.cpp
Go to the documentation of this file.
1
// Copyright (c) 2018-2019 The Bitcoin 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
#include <
cashaddr.h
>
7
8
#include <string>
9
#include <vector>
10
11
static
void
CashAddrEncode
(
benchmark::Bench
&bench) {
12
std::vector<uint8_t> buffer = {17, 79, 8, 99, 150, 189, 208, 162,
13
22, 23, 203, 163, 36, 58, 147, 227,
14
139, 2, 215, 100, 91, 38, 11, 141,
15
253, 40, 117, 21, 16, 90, 200, 24};
16
bench.
batch
(buffer.size()).
unit
(
"byte"
).
run
([&] {
17
cashaddr::Encode
(
"bitcoincash"
, buffer);
18
});
19
}
20
21
static
void
CashAddrDecode
(
benchmark::Bench
&bench) {
22
const
char
*addrWithPrefix =
23
"bitcoincash:qprnwmr02d7ky9m693qufj5mgkpf4wvssv0w86tkjd"
;
24
const
char
*addrNoPrefix =
"qprnwmr02d7ky9m693qufj5mgkpf4wvssv0w86tkjd"
;
25
bench.
run
([&] {
26
cashaddr::Decode
(addrWithPrefix,
"bitcoincash"
);
27
cashaddr::Decode
(addrNoPrefix,
"bitcoincash"
);
28
});
29
}
30
31
BENCHMARK
(
CashAddrEncode
);
32
BENCHMARK
(
CashAddrDecode
);
bench.h
BENCHMARK
#define BENCHMARK(n)
Definition
bench.h:65
CashAddrEncode
static void CashAddrEncode(benchmark::Bench &bench)
Definition
cashaddr.cpp:11
CashAddrDecode
static void CashAddrDecode(benchmark::Bench &bench)
Definition
cashaddr.cpp:21
cashaddr.h
ankerl::nanobench::Bench
Main entry point to nanobench's benchmarking facility.
Definition
nanobench.h:616
ankerl::nanobench::Bench::batch
ANKERL_NANOBENCH(NODISCARD) std Bench & batch(T b) noexcept
Sets the batch size.
ankerl::nanobench::Bench::run
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition
nanobench.h:1183
ankerl::nanobench::Bench::unit
Bench & unit(char const *unit)
Sets the operation unit.
cashaddr::Decode
std::pair< std::string, data > Decode(const std::string &str, const std::string &default_prefix)
Decode a cashaddr string.
Definition
cashaddr.cpp:216
cashaddr::Encode
std::string Encode(const std::string &prefix, const data &payload)
Encode a cashaddr string.
Definition
cashaddr.cpp:200
Generated on Mon Nov 23 2026 16:26:16 for Bitcoin ABC by
1.9.8