diff options
author | Martin Leitner-Ankerl <martin.ankerl@gmail.com> | 2022-03-23 07:43:58 +0100 |
---|---|---|
committer | Martin Leitner-Ankerl <martin.ankerl@gmail.com> | 2022-04-17 14:29:52 +0200 |
commit | 4e2b99f72a90b956f3050095abed4949aff9b516 (patch) | |
tree | 8f0453324ed56110d2eaa5c90fe1512a778ab403 | |
parent | 67c8411c37b483caa2fe3f7f4f40b68ed2a9bcf7 (diff) | |
download | bitcoin-4e2b99f72a90b956f3050095abed4949aff9b516.tar.xz |
bench: Adds a benchmark for HexStr
Benchmarks conversion of a full binary block into hex, like it is done in rest.cpp.
-rw-r--r-- | src/Makefile.bench.include | 1 | ||||
-rw-r--r-- | src/bench/strencodings.cpp | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/Makefile.bench.include b/src/Makefile.bench.include index 5dae4374e3..a6cda582a8 100644 --- a/src/Makefile.bench.include +++ b/src/Makefile.bench.include @@ -44,6 +44,7 @@ bench_bench_bitcoin_SOURCES = \ bench/rollingbloom.cpp \ bench/rpc_blockchain.cpp \ bench/rpc_mempool.cpp \ + bench/strencodings.cpp \ bench/util_time.cpp \ bench/verify_script.cpp diff --git a/src/bench/strencodings.cpp b/src/bench/strencodings.cpp new file mode 100644 index 0000000000..69b3a83cbf --- /dev/null +++ b/src/bench/strencodings.cpp @@ -0,0 +1,18 @@ +// Copyright (c) 2022 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include <bench/bench.h> +#include <bench/data.h> +#include <util/strencodings.h> + +static void HexStrBench(benchmark::Bench& bench) +{ + auto const& data = benchmark::data::block413567; + bench.batch(data.size()).unit("byte").run([&] { + auto hex = HexStr(data); + ankerl::nanobench::doNotOptimizeAway(hex); + }); +} + +BENCHMARK(HexStrBench); |