From 96af810b533dc915d3538e3558099324c9a48e32 Mon Sep 17 00:00:00 2001 From: Patrick Lodder Date: Sun, 19 Dec 2021 17:36:46 -0400 Subject: [PATCH] bench: add scrypt Add an scrypt benchmark that hashes 80 byte inputs (size of a block header) --- src/Makefile.bench.include | 3 ++- src/bench/scrypt.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/bench/scrypt.cpp diff --git a/src/Makefile.bench.include b/src/Makefile.bench.include index 8e421659ba8..e603216a2b7 100644 --- a/src/Makefile.bench.include +++ b/src/Makefile.bench.include @@ -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 diff --git a/src/bench/scrypt.cpp b/src/bench/scrypt.cpp new file mode 100644 index 00000000000..f05fdd9bda3 --- /dev/null +++ b/src/bench/scrypt.cpp @@ -0,0 +1,28 @@ +#include +#include + +#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 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);