Bitcoin ABC 0.30.7
P2P Digital Currency
base58.cpp
Go to the documentation of this file.
1// Copyright (c) 2016 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
12static void Base58Encode(benchmark::Bench &bench) {
13 static const std::vector<uint8_t> buffer = {
14 17, 79, 8, 99, 150, 189, 208, 162, 22, 23, 203,
15 163, 36, 58, 147, 227, 139, 2, 215, 100, 91, 38,
16 11, 141, 253, 40, 117, 21, 16, 90, 200, 24};
17 bench.batch(buffer.size()).unit("byte").run([&] { EncodeBase58(buffer); });
18}
19
21 static const std::vector<uint8_t> buffer = {
22 17, 79, 8, 99, 150, 189, 208, 162, 22, 23, 203,
23 163, 36, 58, 147, 227, 139, 2, 215, 100, 91, 38,
24 11, 141, 253, 40, 117, 21, 16, 90, 200, 24};
25 bench.batch(buffer.size()).unit("byte").run([&] {
26 EncodeBase58Check(buffer);
27 });
28}
29
30static void Base58Decode(benchmark::Bench &bench) {
31 const char *addr = "17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem";
32 std::vector<uint8_t> vch;
33 bench.batch(strlen(addr)).unit("byte").run([&] {
34 (void)DecodeBase58(addr, vch, 64);
35 });
36}
37
std::string EncodeBase58(Span< const uint8_t > input)
Why base-58 instead of standard base-64 encoding?
Definition: base58.cpp:101
std::string EncodeBase58Check(Span< const uint8_t > input)
Encode a byte span into a base58-encoded string, including checksum.
Definition: base58.cpp:152
bool DecodeBase58(const std::string &str, std::vector< uint8_t > &vchRet, int max_ret_len)
Decode a base58-encoded string (str) into a byte vector (vchRet).
Definition: base58.cpp:144
static void Base58Decode(benchmark::Bench &bench)
Definition: base58.cpp:30
BENCHMARK(Base58Encode)
static void Base58Encode(benchmark::Bench &bench)
Definition: base58.cpp:12
static void Base58CheckEncode(benchmark::Bench &bench)
Definition: base58.cpp:20
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.