Merge #12079: Improve prioritisetransaction test coverage
[bitcoinplatinum.git] / src / bench / base58.cpp
blob70bfd7d0bf3f5685bcee485196bdec09b050f3a3
1 // Copyright (c) 2016-2017 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.
5 #include <bench/bench.h>
7 #include <validation.h>
8 #include <base58.h>
10 #include <array>
11 #include <vector>
12 #include <string>
15 static void Base58Encode(benchmark::State& state)
17 static const std::array<unsigned char, 32> buff = {
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
24 while (state.KeepRunning()) {
25 EncodeBase58(buff.data(), buff.data() + buff.size());
30 static void Base58CheckEncode(benchmark::State& state)
32 static const std::array<unsigned char, 32> buff = {
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
39 std::vector<unsigned char> vch;
40 vch.assign(buff.begin(), buff.end());
41 while (state.KeepRunning()) {
42 EncodeBase58Check(vch);
47 static void Base58Decode(benchmark::State& state)
49 const char* addr = "17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem";
50 std::vector<unsigned char> vch;
51 while (state.KeepRunning()) {
52 DecodeBase58(addr, vch);
57 BENCHMARK(Base58Encode, 470 * 1000);
58 BENCHMARK(Base58CheckEncode, 320 * 1000);
59 BENCHMARK(Base58Decode, 800 * 1000);