Skip to content

Commit

Permalink
bench: add scrypt
Browse files Browse the repository at this point in the history
Add an scrypt benchmark that hashes 80 byte inputs (size of a
block header)
  • Loading branch information
patricklodder committed Dec 20, 2021
1 parent da8dae3 commit 96af810
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Makefile.bench.include
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions src/bench/scrypt.cpp
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 96af810

Please sign in to comment.