mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-03 01:33:20 +02:00
Extract util::Xor, Add key_offset option, Add bench
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <bench/nanobench.h>
|
||||
#include <bench/nanobench.h> // IWYU pragma: export
|
||||
|
||||
/*
|
||||
* Usage:
|
||||
|
||||
24
src/bench/xor.cpp
Normal file
24
src/bench/xor.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
// Copyright (c) The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or https://opensource.org/license/mit/.
|
||||
|
||||
#include <bench/bench.h>
|
||||
|
||||
#include <random.h>
|
||||
#include <streams.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
|
||||
static void Xor(benchmark::Bench& bench)
|
||||
{
|
||||
FastRandomContext frc{/*fDeterministic=*/true};
|
||||
auto data{frc.randbytes<std::byte>(1024)};
|
||||
auto key{frc.randbytes<std::byte>(31)};
|
||||
|
||||
bench.batch(data.size()).unit("byte").run([&] {
|
||||
util::Xor(data, key);
|
||||
});
|
||||
}
|
||||
|
||||
BENCHMARK(Xor, benchmark::PriorityLevel::HIGH);
|
||||
Reference in New Issue
Block a user