Added CashAddr benchmarks for decoding/encoding
https://reviews.bitcoinabc.org/D1856
This commit is contained in:
@@ -11,6 +11,7 @@ bench_bench_bitcoin_SOURCES = \
|
||||
bench/bench_bitcoin.cpp \
|
||||
bench/bench.cpp \
|
||||
bench/bench.h \
|
||||
bench/cashaddr.cpp \
|
||||
bench/Examples.cpp \
|
||||
bench/rollingbloom.cpp \
|
||||
bench/crypto_hash.cpp \
|
||||
|
||||
32
src/bench/cashaddr.cpp
Normal file
32
src/bench/cashaddr.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) 2018 The Bitcoin developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "cashaddr.h"
|
||||
#include "bench.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
static void CashAddrEncode(benchmark::State &state) {
|
||||
std::vector<uint8_t> buffer = {17, 79, 8, 99, 150, 189, 208, 162,
|
||||
22, 23, 203, 163, 36, 58, 147, 227,
|
||||
139, 2, 215, 100, 91, 38, 11, 141,
|
||||
253, 40, 117, 21, 16, 90, 200, 24};
|
||||
while (state.KeepRunning()) {
|
||||
cashaddr::Encode("blackcoin", buffer);
|
||||
}
|
||||
}
|
||||
|
||||
static void CashAddrDecode(benchmark::State &state) {
|
||||
const char *addrWithPrefix =
|
||||
"blackcoin:qprnwmr02d7ky9m693qufj5mgkpf4wvssv0w86tkjd";
|
||||
const char *addrNoPrefix = "qprnwmr02d7ky9m693qufj5mgkpf4wvssv0w86tkjd";
|
||||
while (state.KeepRunning()) {
|
||||
cashaddr::Decode(addrWithPrefix, "blackcoin");
|
||||
cashaddr::Decode(addrNoPrefix, "blackcoin");
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(CashAddrEncode);
|
||||
BENCHMARK(CashAddrDecode);
|
||||
Reference in New Issue
Block a user