Bitcoin Core 28.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
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
7#include <random.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
#define BENCHMARK(n, priority_level)
Definition bench.h:79
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
Bench & unit(char const *unit)
Sets the operation unit.
@ HIGH
Definition bench.h:47
void Xor(Span< std::byte > write, Span< const std::byte > key, size_t key_offset=0)
Definition streams.h:28
static void Xor(benchmark::Bench &bench)
Definition xor.cpp:13