mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-25 00:41:04 +02:00
bench: make ObfuscationBench more representative
A previous PR already solved the tiny byte-array-xors during serialization, so it makes sense to keep focusing on the performance of bigger continuous chunks. This also renames the file from `xor` to `obfuscation` to enable scripted diff name unification later. > C++ compiler .......................... GNU 14.2.0 | ns/byte | byte/s | err% | ins/byte | cyc/byte | IPC | bra/byte | miss% | total | benchmark |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:---------- | 0.84 | 1,184,138,235.64 | 0.0% | 9.01 | 3.03 | 2.971 | 1.00 | 0.1% | 5.50 | `ObfuscationBench` > C++ compiler .......................... Clang 20.1.7 | ns/byte | byte/s | err% | ins/byte | cyc/byte | IPC | bra/byte | miss% | total | benchmark |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:---------- | 0.89 | 1,124,087,330.23 | 0.1% | 6.52 | 3.20 | 2.041 | 0.50 | 0.2% | 5.50 | `ObfuscationBench`
This commit is contained in:
@@ -35,6 +35,7 @@ add_executable(bench_bitcoin
|
||||
mempool_eviction.cpp
|
||||
mempool_stress.cpp
|
||||
merkle_root.cpp
|
||||
obfuscation.cpp
|
||||
parse_hex.cpp
|
||||
peer_eviction.cpp
|
||||
poly1305.cpp
|
||||
@@ -51,7 +52,6 @@ add_executable(bench_bitcoin
|
||||
txgraph.cpp
|
||||
util_time.cpp
|
||||
verify_script.cpp
|
||||
xor.cpp
|
||||
)
|
||||
|
||||
include(TargetDataSources)
|
||||
|
@@ -4,22 +4,23 @@
|
||||
|
||||
#include <bench/bench.h>
|
||||
#include <random.h>
|
||||
#include <span.h>
|
||||
#include <streams.h>
|
||||
#include <util/obfuscation.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
|
||||
static void Xor(benchmark::Bench& bench)
|
||||
static void ObfuscationBench(benchmark::Bench& bench)
|
||||
{
|
||||
FastRandomContext frc{/*fDeterministic=*/true};
|
||||
auto data{frc.randbytes<std::byte>(1024)};
|
||||
auto key{frc.randbytes<std::byte>(Obfuscation::KEY_SIZE)};
|
||||
const auto key{frc.randbytes<Obfuscation::KEY_SIZE>()};
|
||||
|
||||
size_t offset{0};
|
||||
bench.batch(data.size()).unit("byte").run([&] {
|
||||
util::Xor(data, key);
|
||||
util::Xor(data, key, offset++); // mutated differently each time
|
||||
ankerl::nanobench::doNotOptimizeAway(data);
|
||||
});
|
||||
}
|
||||
|
||||
BENCHMARK(Xor, benchmark::PriorityLevel::HIGH);
|
||||
BENCHMARK(ObfuscationBench, benchmark::PriorityLevel::HIGH);
|
Reference in New Issue
Block a user