mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-03 10:16:14 +00:00
-BEGIN VERIFY SCRIPT- sed --in-place --regexp-extended 's/BENCHMARK\(([^,]+), benchmark::PriorityLevel::(HIGH|LOW)\)/BENCHMARK(\1)/g' $( git grep -l PriorityLevel ) sed --in-place 's/#define BENCHMARK(n, priority_level)/#define BENCHMARK(n)/g' ./src/bench/bench.h -END VERIFY SCRIPT-
48 lines
1.1 KiB
C++
48 lines
1.1 KiB
C++
// Copyright (c) 2015-present 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 <crypto/sha256.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);
|
|
|
|
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);
|