Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
bench
obfuscation.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 <
util/obfuscation.h
>
8
9
#include <cstddef>
10
#include <vector>
11
12
static
void
ObfuscationBench
(
benchmark::Bench
& bench)
13
{
14
FastRandomContext
frc{
/*fDeterministic=*/
true
};
15
auto
data{frc.
randbytes
<std::byte>(1024)};
16
const
Obfuscation
obfuscation{frc.
randbytes
<
Obfuscation::KEY_SIZE
>()};
17
18
size_t
offset{0};
19
bench.
batch
(data.size()).
unit
(
"byte"
).
run
([&] {
20
obfuscation(data, offset++);
// mutated differently each time
21
ankerl::nanobench::doNotOptimizeAway
(data);
22
});
23
}
24
25
BENCHMARK
(
ObfuscationBench
);
bench.h
BENCHMARK
#define BENCHMARK(n)
Definition
bench.h:68
FastRandomContext
Fast randomness source.
Definition
random.h:386
Obfuscation
Definition
obfuscation.h:20
Obfuscation::KEY_SIZE
static constexpr size_t KEY_SIZE
Definition
obfuscation.h:23
RandomMixin::randbytes
std::vector< B > randbytes(size_t len) noexcept
Generate random bytes.
Definition
random.h:297
ankerl::nanobench::Bench
Main entry point to nanobench's benchmarking facility.
Definition
nanobench.h:627
ankerl::nanobench::Bench::run
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition
nanobench.h:1234
ankerl::nanobench::Bench::batch
Bench & batch(T b) noexcept
Sets the batch size.
Definition
nanobench.h:1258
ankerl::nanobench::Bench::unit
Bench & unit(char const *unit)
Sets the operation unit.
ankerl::nanobench::doNotOptimizeAway
void doNotOptimizeAway(Arg &&arg)
Makes sure none of the given arguments are optimized away by the compiler.
Definition
nanobench.h:1279
ObfuscationBench
static void ObfuscationBench(benchmark::Bench &bench)
Definition
obfuscation.cpp:12
obfuscation.h
Generated on
for Bitcoin Core by
1.17.0