mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 20:03:34 -03: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:
parent
67c8411c37
commit
4e2b99f72a
2 changed files with 19 additions and 0 deletions
|
@ -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
|
||||
|
||||
|
|
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);
|
Loading…
Reference in a new issue