random bench refactor: move to new bench/random.cpp

This commit is contained in:
Pieter Wuille
2024-07-05 09:51:26 -04:00
parent bd5d1688b4
commit 0a9bbc64c1
3 changed files with 26 additions and 18 deletions

25
src/bench/random.cpp Normal file
View File

@@ -0,0 +1,25 @@
// Copyright (c) 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 <random.h>
static void FastRandom_32bit(benchmark::Bench& bench)
{
FastRandomContext rng(true);
bench.run([&] {
rng.rand32();
});
}
static void FastRandom_1bit(benchmark::Bench& bench)
{
FastRandomContext rng(true);
bench.run([&] {
rng.randbool();
});
}
BENCHMARK(FastRandom_32bit, benchmark::PriorityLevel::HIGH);
BENCHMARK(FastRandom_1bit, benchmark::PriorityLevel::HIGH);