Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
bench
hashpadding.cpp
Go to the documentation of this file.
1
// Copyright (c) 2015-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 <
crypto/sha256.h
>
7
#include <random.h>
8
#include <
uint256.h
>
9
10
11
static
void
PrePadded
(
benchmark::Bench
& bench)
12
{
13
14
CSHA256
hasher;
15
16
// Setup the salted hasher
17
uint256
nonce
=
GetRandHash
();
18
hasher.
Write
(
nonce
.begin(), 32);
19
hasher.
Write
(
nonce
.begin(), 32);
20
uint256
data =
GetRandHash
();
21
bench.
run
([&] {
22
unsigned
char
out[32];
23
CSHA256
h = hasher;
24
h.
Write
(data.begin(), 32);
25
h.
Finalize
(out);
26
});
27
}
28
29
BENCHMARK
(
PrePadded
);
30
31
static
void
RegularPadded
(
benchmark::Bench
& bench)
32
{
33
CSHA256
hasher;
34
35
// Setup the salted hasher
36
uint256
nonce
=
GetRandHash
();
37
uint256
data =
GetRandHash
();
38
bench.
run
([&] {
39
unsigned
char
out[32];
40
CSHA256
h = hasher;
41
h.
Write
(
nonce
.begin(), 32);
42
h.
Write
(data.begin(), 32);
43
h.
Finalize
(out);
44
});
45
}
46
47
BENCHMARK
(
RegularPadded
);
bench.h
BENCHMARK
#define BENCHMARK(n)
Definition
bench.h:68
CSHA256
A hasher class for SHA-256.
Definition
sha256.h:14
CSHA256::Finalize
void Finalize(unsigned char hash[OUTPUT_SIZE])
Definition
sha256.cpp:725
CSHA256::Write
CSHA256 & Write(const unsigned char *data, size_t len)
Definition
sha256.cpp:699
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
uint256
256-bit opaque blob.
Definition
uint256.h:195
PrePadded
static void PrePadded(benchmark::Bench &bench)
Definition
hashpadding.cpp:11
RegularPadded
static void RegularPadded(benchmark::Bench &bench)
Definition
hashpadding.cpp:31
nonce
unsigned int nonce
Definition
miner_tests.cpp:82
GetRandHash
uint256 GetRandHash() noexcept
Generate a random uint256.
Definition
random.h:463
sha256.h
uint256.h
Generated on
for Bitcoin Core by
1.17.0