Skip to content

Commit

Permalink
bench: Add FeefracMultipication benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed Jun 3, 2024
1 parent 5fb70b5 commit 0f5abaf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Makefile.bench.include
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ bench_bench_bitcoin_SOURCES = \
bench/duplicate_inputs.cpp \
bench/ellswift.cpp \
bench/examples.cpp \
bench/feefrac_mul.cpp \
bench/gcs_filter.cpp \
bench/hashpadding.cpp \
bench/index_blockfilter.cpp \
Expand Down
26 changes: 26 additions & 0 deletions src/bench/feefrac_mul.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) 2024-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php.

#include <bench/bench.h>
#include <random.h>
#include <util/feefrac.h>

#include <bit>
#include <cstdint>

static void FeefracMultipication(benchmark::Bench& bench)
{
FastRandomContext rnd;
uint64_t a64 = rnd.rand64();
uint32_t b32 = rnd.rand32();
uint64_t c64 = rnd.rand64();
uint32_t d32 = rnd.rand32();
bench.minEpochIterations(10000000).run([&] {
FeeRateCompare(
FeeFrac(std::bit_cast<std::int64_t>(a64++), std::bit_cast<std::int32_t>(b32++)),
FeeFrac(std::bit_cast<std::int64_t>(c64++), std::bit_cast<std::int32_t>(d32++)));
});
}

BENCHMARK(FeefracMultipication, benchmark::PriorityLevel::HIGH);

0 comments on commit 0f5abaf

Please sign in to comment.