mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-09-07 18:42:13 +02:00
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:
@@ -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
|
||||||
|
|
||||||
|
18
src/bench/strencodings.cpp
Normal file
18
src/bench/strencodings.cpp
Normal 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);
|
Reference in New Issue
Block a user