mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-18 11:57:37 -05:00

-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT- Commits of previous years: - 2021:f47dda2c58
- 2020:fa0074e2d8
- 2019:aaaaad6ac9
47 lines
1.1 KiB
C++
47 lines
1.1 KiB
C++
// Copyright (c) 2015-2022 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include <bench/bench.h>
|
|
#include <hash.h>
|
|
#include <random.h>
|
|
#include <uint256.h>
|
|
|
|
|
|
static void PrePadded(benchmark::Bench& bench)
|
|
{
|
|
|
|
CSHA256 hasher;
|
|
|
|
// Setup the salted hasher
|
|
uint256 nonce = GetRandHash();
|
|
hasher.Write(nonce.begin(), 32);
|
|
hasher.Write(nonce.begin(), 32);
|
|
uint256 data = GetRandHash();
|
|
bench.run([&] {
|
|
unsigned char out[32];
|
|
CSHA256 h = hasher;
|
|
h.Write(data.begin(), 32);
|
|
h.Finalize(out);
|
|
});
|
|
}
|
|
|
|
BENCHMARK(PrePadded, benchmark::PriorityLevel::HIGH);
|
|
|
|
static void RegularPadded(benchmark::Bench& bench)
|
|
{
|
|
CSHA256 hasher;
|
|
|
|
// Setup the salted hasher
|
|
uint256 nonce = GetRandHash();
|
|
uint256 data = GetRandHash();
|
|
bench.run([&] {
|
|
unsigned char out[32];
|
|
CSHA256 h = hasher;
|
|
h.Write(nonce.begin(), 32);
|
|
h.Write(data.begin(), 32);
|
|
h.Finalize(out);
|
|
});
|
|
}
|
|
|
|
BENCHMARK(RegularPadded, benchmark::PriorityLevel::HIGH);
|