Bitcoin Core
25.99.0
P2P Digital Currency
src
bench
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
13
static
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
24
BENCHMARK
(
Xor
,
benchmark::PriorityLevel::HIGH
);
bench.h
FastRandomContext
Fast randomness source.
Definition:
random.h:144
FastRandomContext::randbytes
std::vector< B > randbytes(size_t len)
Generate random bytes.
Definition:
random.cpp:596
ankerl::nanobench::Bench
Main entry point to nanobench's benchmarking facility.
Definition:
nanobench.h:623
ankerl::nanobench::Bench::run
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition:
nanobench.h:1230
ankerl::nanobench::Bench::batch
Bench & batch(T b) noexcept
Sets the batch size.
Definition:
nanobench.h:1254
benchmark::HIGH
@ HIGH
Definition:
bench.h:47
util::Xor
void Xor(Span< std::byte > write, Span< const std::byte > key, size_t key_offset=0)
Definition:
streams.h:28
streams.h
BENCHMARK
BENCHMARK(Xor, benchmark::PriorityLevel::HIGH)
Xor
static void Xor(benchmark::Bench &bench)
Definition:
xor.cpp:13
Generated on Sun Oct 1 2023 02:44:01 for Bitcoin Core by
1.9.1