From 353c660be52249b3906a7113a90c96117c43f84b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rinc?= Date: Mon, 16 Feb 2026 12:16:01 +0100 Subject: [PATCH] bench: use deterministic `HexStr` payload `HexStrBench` uses the bytes from the embedded block fixture as a random source of bytes to measure `HexStr` performance against. This coupling makes block benchmark migrations slightly more work than necessary. We can use deterministic pseudo-random bytes instead so this benchmark keeps stable input without fixture coupling. Use `MAX_BLOCK_WEIGHT` so the benchmark stays in the same size range and keeps measured work above harness overhead. This changes the benchmark baseline because input size moves from about 1 MB to 4 MB. Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Co-authored-by: Hodlinator <172445034+hodlinator@users.noreply.github.com> --- src/bench/strencodings.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bench/strencodings.cpp b/src/bench/strencodings.cpp index a0767b495fe..7d4e188730a 100644 --- a/src/bench/strencodings.cpp +++ b/src/bench/strencodings.cpp @@ -3,7 +3,8 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include -#include +#include +#include #include #include @@ -11,7 +12,8 @@ static void HexStrBench(benchmark::Bench& bench) { - auto const& data = benchmark::data::block413567; + FastRandomContext rng{/*fDeterministic=*/true}; + auto data{rng.randbytes(MAX_BLOCK_WEIGHT)}; bench.batch(data.size()).unit("byte").run([&] { auto hex = HexStr(data); ankerl::nanobench::doNotOptimizeAway(hex);