Skip to content

Commit 0f5abaf

Browse files
committed
bench: Add FeefracMultipication benchmark
1 parent 5fb70b5 commit 0f5abaf

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/Makefile.bench.include

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ bench_bench_bitcoin_SOURCES = \
3232
bench/duplicate_inputs.cpp \
3333
bench/ellswift.cpp \
3434
bench/examples.cpp \
35+
bench/feefrac_mul.cpp \
3536
bench/gcs_filter.cpp \
3637
bench/hashpadding.cpp \
3738
bench/index_blockfilter.cpp \

src/bench/feefrac_mul.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright (c) 2024-present The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or https://www.opensource.org/licenses/mit-license.php.
4+
5+
#include <bench/bench.h>
6+
#include <random.h>
7+
#include <util/feefrac.h>
8+
9+
#include <bit>
10+
#include <cstdint>
11+
12+
static void FeefracMultipication(benchmark::Bench& bench)
13+
{
14+
FastRandomContext rnd;
15+
uint64_t a64 = rnd.rand64();
16+
uint32_t b32 = rnd.rand32();
17+
uint64_t c64 = rnd.rand64();
18+
uint32_t d32 = rnd.rand32();
19+
bench.minEpochIterations(10000000).run([&] {
20+
FeeRateCompare(
21+
FeeFrac(std::bit_cast<std::int64_t>(a64++), std::bit_cast<std::int32_t>(b32++)),
22+
FeeFrac(std::bit_cast<std::int64_t>(c64++), std::bit_cast<std::int32_t>(d32++)));
23+
});
24+
}
25+
26+
BENCHMARK(FeefracMultipication, benchmark::PriorityLevel::HIGH);

0 commit comments

Comments
 (0)