Bitcoin Core 28.99.0
P2P Digital Currency
xor.cpp
Go to the documentation of this file.
1// Copyright (c) The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or https://opensource.org/license/mit/.
4
5#include <bench/bench.h>
6#include <random.h>
7#include <span.h>
8#include <streams.h>
9
10#include <cstddef>
11#include <vector>
12
13static void Xor(benchmark::Bench& bench)
14{
15 FastRandomContext frc{/*fDeterministic=*/true};
16 auto data{frc.randbytes<std::byte>(1024)};
17 auto key{frc.randbytes<std::byte>(31)};
18
19 bench.batch(data.size()).unit("byte").run([&] {
20 util::Xor(data, key);
21 });
22}
23
Fast randomness source.
Definition: random.h:377
Main entry point to nanobench's benchmarking facility.
Definition: nanobench.h:627
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition: nanobench.h:1234
Bench & batch(T b) noexcept
Sets the batch size.
Definition: nanobench.h:1258
@ HIGH
Definition: bench.h:48
void Xor(Span< std::byte > write, Span< const std::byte > key, size_t key_offset=0)
Definition: streams.h:28
BENCHMARK(Xor, benchmark::PriorityLevel::HIGH)
static void Xor(benchmark::Bench &bench)
Definition: xor.cpp:13