Extract util::Xor, Add key_offset option, Add bench

This commit is contained in:
MarcoFalke
2023-06-12 11:28:59 +02:00
parent 99b3af78bd
commit 9999a49b32
4 changed files with 49 additions and 17 deletions

View File

@@ -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
View 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);