Skip to content

Commit

Permalink
Bench tests for CPubKey<->EllSwift
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruv committed Jul 19, 2022
1 parent edab3c7 commit 5072b2c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Makefile.bench.include
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ bench_bench_bitcoin_SOURCES = \
bench/data.cpp \
bench/data.h \
bench/duplicate_inputs.cpp \
bench/ellswift.cpp \
bench/examples.cpp \
bench/gcs_filter.cpp \
bench/hashpadding.cpp \
Expand Down
28 changes: 28 additions & 0 deletions src/bench/ellswift.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) 2016-2020 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 <key.h>
#include <pubkey.h>
#include <random.h>

#include <array>

static void EllSwiftEncode(benchmark::Bench& bench)
{
ECC_Start();
std::array<uint8_t, 32> rnd32;
GetRandBytes(rnd32);

CKey key;
key.MakeNewKey(false);
auto pubkey = key.GetPubKey();

bench.batch(1).unit("pubkey").run([&] {
pubkey.EllSwiftEncode(rnd32);
});
}

BENCHMARK(EllSwiftEncode);

0 comments on commit 5072b2c

Please sign in to comment.