bench: add scrypt

Add an scrypt benchmark that hashes 80 byte inputs (size of a
block header)
This commit is contained in:
Patrick Lodder 2021-12-19 17:36:46 -04:00
parent da8dae3eb3
commit 96af810b53
No known key found for this signature in database
GPG Key ID: 7C523F5FBABE80E7
2 changed files with 30 additions and 1 deletions

View File

@ -23,7 +23,8 @@ bench_bench_dogecoin_SOURCES = \
bench/base58.cpp \
bench/lockedpool.cpp \
bench/perf.cpp \
bench/perf.h
bench/perf.h \
bench/scrypt.cpp
# bench_bench_dogecoin_SOURCES_DISABLED = \
# bench/checkblock.cpp \ # disabled because this checks a specific bitcoin block

28
src/bench/scrypt.cpp Normal file
View File

@ -0,0 +1,28 @@
#include <iostream>
#include <vector>
#include "bench.h"
#include "crypto/scrypt.h"
#include "uint256.h"
#include "utiltime.h"
#include "utilstrencodings.h"
// 80 bytes input, size of CPureBlockHeader
static const uint64_t BUFFER_SIZE = 80;
static void Scrypt(benchmark::State& state)
{
uint256 output;
std::vector<char> in(BUFFER_SIZE, 0);
#ifdef USE_SSE2
scrypt_detect_sse2();
#endif // USE_SSE2
while (state.KeepRunning())
{
scrypt_1024_1_1_256(in.data(), BEGIN(output));
}
}
BENCHMARK(Scrypt);