Skip to content

Commit 0a9bbc6

Browse files
committed
random bench refactor: move to new bench/random.cpp
1 parent bd5d168 commit 0a9bbc6

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

src/Makefile.bench.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ bench_bench_bitcoin_SOURCES = \
4949
bench/poly1305.cpp \
5050
bench/pool.cpp \
5151
bench/prevector.cpp \
52+
bench/random.cpp \
5253
bench/readblock.cpp \
5354
bench/rollingbloom.cpp \
5455
bench/rpc_blockchain.cpp \

src/bench/crypto_hash.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -196,22 +196,6 @@ static void SipHash_32b(benchmark::Bench& bench)
196196
});
197197
}
198198

199-
static void FastRandom_32bit(benchmark::Bench& bench)
200-
{
201-
FastRandomContext rng(true);
202-
bench.run([&] {
203-
rng.rand32();
204-
});
205-
}
206-
207-
static void FastRandom_1bit(benchmark::Bench& bench)
208-
{
209-
FastRandomContext rng(true);
210-
bench.run([&] {
211-
rng.randbool();
212-
});
213-
}
214-
215199
static void MuHash(benchmark::Bench& bench)
216200
{
217201
MuHash3072 acc;
@@ -274,8 +258,6 @@ BENCHMARK(SHA256D64_1024_STANDARD, benchmark::PriorityLevel::HIGH);
274258
BENCHMARK(SHA256D64_1024_SSE4, benchmark::PriorityLevel::HIGH);
275259
BENCHMARK(SHA256D64_1024_AVX2, benchmark::PriorityLevel::HIGH);
276260
BENCHMARK(SHA256D64_1024_SHANI, benchmark::PriorityLevel::HIGH);
277-
BENCHMARK(FastRandom_32bit, benchmark::PriorityLevel::HIGH);
278-
BENCHMARK(FastRandom_1bit, benchmark::PriorityLevel::HIGH);
279261

280262
BENCHMARK(MuHash, benchmark::PriorityLevel::HIGH);
281263
BENCHMARK(MuHashMul, benchmark::PriorityLevel::HIGH);

src/bench/random.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright (c) The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#include <bench/bench.h>
6+
#include <random.h>
7+
8+
static void FastRandom_32bit(benchmark::Bench& bench)
9+
{
10+
FastRandomContext rng(true);
11+
bench.run([&] {
12+
rng.rand32();
13+
});
14+
}
15+
16+
static void FastRandom_1bit(benchmark::Bench& bench)
17+
{
18+
FastRandomContext rng(true);
19+
bench.run([&] {
20+
rng.randbool();
21+
});
22+
}
23+
24+
BENCHMARK(FastRandom_32bit, benchmark::PriorityLevel::HIGH);
25+
BENCHMARK(FastRandom_1bit, benchmark::PriorityLevel::HIGH);

0 commit comments

Comments
 (0)