From 107965eb5b1f086d1a5c0d1206836e4dd4c83f1f Mon Sep 17 00:00:00 2001 From: lateminer Date: Sun, 18 Nov 2018 14:40:49 +0300 Subject: [PATCH] Added CashAddr benchmarks for decoding/encoding https://reviews.bitcoinabc.org/D1856 --- src/Makefile.bench.include | 1 + src/bench/cashaddr.cpp | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/bench/cashaddr.cpp diff --git a/src/Makefile.bench.include b/src/Makefile.bench.include index 35e9507a1..1674d65c9 100644 --- a/src/Makefile.bench.include +++ b/src/Makefile.bench.include @@ -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 \ diff --git a/src/bench/cashaddr.cpp b/src/bench/cashaddr.cpp new file mode 100644 index 000000000..fa2721de1 --- /dev/null +++ b/src/bench/cashaddr.cpp @@ -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 +#include + +static void CashAddrEncode(benchmark::State &state) { + std::vector 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); \ No newline at end of file