Bitcoin ABC 0.30.5
P2P Digital Currency
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
11static 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
21static 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
static void CashAddrEncode(benchmark::Bench &bench)
Definition: cashaddr.cpp:11
BENCHMARK(CashAddrEncode)
static void CashAddrDecode(benchmark::Bench &bench)
Definition: cashaddr.cpp:21
Main entry point to nanobench's benchmarking facility.
Definition: nanobench.h:616
ANKERL_NANOBENCH(NODISCARD) std Bench & batch(T b) noexcept
Sets the batch size.
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition: nanobench.h:1183
Bench & unit(char const *unit)
Sets the operation unit.
std::pair< std::string, data > Decode(const std::string &str, const std::string &default_prefix)
Decode a cashaddr string.
Definition: cashaddr.cpp:214
std::string Encode(const std::string &prefix, const data &payload)
Encode a cashaddr string.
Definition: cashaddr.cpp:198