Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
hashpadding.cpp
Go to the documentation of this file.
1// Copyright (c) 2015-2018 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 <hash.h>
7#include <random.h>
8#include <uint256.h>
9
11 CSHA256 hasher;
12
13 // Setup the salted hasher
14 uint256 nonce = GetRandHash();
15 hasher.Write(nonce.begin(), 32);
16 hasher.Write(nonce.begin(), 32);
17 uint256 data = GetRandHash();
18 bench.run([&] {
19 uint8_t out[32];
20 CSHA256 h = hasher;
21 h.Write(data.begin(), 32);
22 h.Finalize(out);
23 });
24}
25
27
29 CSHA256 hasher;
30
31 // Setup the salted hasher
32 uint256 nonce = GetRandHash();
33 uint256 data = GetRandHash();
34 bench.run([&] {
35 uint8_t out[32];
36 CSHA256 h = hasher;
37 h.Write(nonce.begin(), 32);
38 h.Write(data.begin(), 32);
39 h.Finalize(out);
40 });
41}
42
#define BENCHMARK(n)
Definition bench.h:65
A hasher class for SHA-256.
Definition sha256.h:13
CSHA256 & Write(const uint8_t *data, size_t len)
Definition sha256.cpp:819
Main entry point to nanobench's benchmarking facility.
Definition nanobench.h:616
uint8_t * begin()
Definition uint256.h:85
256-bit opaque blob.
Definition uint256.h:129
static void PrePadded(benchmark::Bench &bench)
static void RegularPadded(benchmark::Bench &bench)
uint256 GetRandHash() noexcept
Definition random.cpp:659
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85