Bitcoin Core
32.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
bench
strencodings.cpp
Go to the documentation of this file.
1
// Copyright (c) 2022-present The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#include <
bench/bench.h
>
6
#include <
consensus/consensus.h
>
7
#include <
crypto/hex_base.h
>
8
#include <random.h>
9
10
#include <cstddef>
11
#include <span>
12
#include <string>
13
#include <vector>
14
15
static
void
HexStrBench
(
benchmark::Bench
& bench)
16
{
17
FastRandomContext
rng
{
/*fDeterministic=*/
true
};
18
auto
data{
rng
.
randbytes
<std::byte>(
MAX_BLOCK_WEIGHT
)};
19
bench.
batch
(data.size()).
unit
(
"byte"
).
run
([&] {
20
auto
hex =
HexStr
(data);
21
ankerl::nanobench::doNotOptimizeAway
(hex);
22
});
23
}
24
25
BENCHMARK
(
HexStrBench
);
bench.h
BENCHMARK
#define BENCHMARK(n)
Definition
bench.h:69
HexStrBench
static void HexStrBench(benchmark::Bench &bench)
Definition
strencodings.cpp:15
FastRandomContext
Fast randomness source.
Definition
random.h:386
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:649
ankerl::nanobench::Bench::run
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition
nanobench.h:1308
ankerl::nanobench::Bench::batch
Bench & batch(T b) noexcept
Sets the batch size.
Definition
nanobench.h:1332
ankerl::nanobench::Bench::unit
Bench & unit(char const *unit)
Sets the operation unit.
consensus.h
MAX_BLOCK_WEIGHT
constexpr unsigned int MAX_BLOCK_WEIGHT
The maximum allowed weight for a block, see BIP 141 (network rule).
Definition
consensus.h:15
HexStr
std::string HexStr(const std::span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
Definition
hex_base.cpp:30
hex_base.h
ankerl::nanobench::doNotOptimizeAway
void doNotOptimizeAway(Arg &&arg)
Makes sure none of the given arguments are optimized away by the compiler.
Definition
nanobench.h:1353
rng
FastRandomContext rng
Definition
dbwrapper.cpp:413
Generated on
for Bitcoin Core by
1.18.0