bench: Adds a benchmark for HexStr

Benchmarks conversion of a full binary block into hex, like it is done in rest.cpp.
This commit is contained in:
Martin Leitner-Ankerl 2022-03-23 07:43:58 +01:00
parent 67c8411c37
commit 4e2b99f72a
No known key found for this signature in database
GPG key ID: FBEAAD7FC6FFFE81
2 changed files with 19 additions and 0 deletions

View file

@ -44,6 +44,7 @@ bench_bench_bitcoin_SOURCES = \
bench/rollingbloom.cpp \ bench/rollingbloom.cpp \
bench/rpc_blockchain.cpp \ bench/rpc_blockchain.cpp \
bench/rpc_mempool.cpp \ bench/rpc_mempool.cpp \
bench/strencodings.cpp \
bench/util_time.cpp \ bench/util_time.cpp \
bench/verify_script.cpp bench/verify_script.cpp

View file

@ -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);