aboutsummaryrefslogtreecommitdiff
path: root/src/bench
diff options
context:
space:
mode:
authorMartin Leitner-Ankerl <martin.ankerl@gmail.com>2022-03-23 07:43:58 +0100
committerMartin Leitner-Ankerl <martin.ankerl@gmail.com>2022-04-17 14:29:52 +0200
commit4e2b99f72a90b956f3050095abed4949aff9b516 (patch)
tree8f0453324ed56110d2eaa5c90fe1512a778ab403 /src/bench
parent67c8411c37b483caa2fe3f7f4f40b68ed2a9bcf7 (diff)
downloadbitcoin-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.
Diffstat (limited to 'src/bench')
-rw-r--r--src/bench/strencodings.cpp18
1 files changed, 18 insertions, 0 deletions
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);