From 855e18d8a809b98a622ab55765792aca132ea640 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sun, 17 Oct 2021 12:10:23 -0400 Subject: [PATCH] Merge bench_ecdh into bench --- .gitignore | 1 - ci/cirrus.sh | 4 ---- src/bench.c | 9 +++++++++ src/modules/ecdh/Makefile.am.include | 6 +----- src/{bench_ecdh.c => modules/ecdh/bench_impl.h} | 15 +++++---------- 5 files changed, 15 insertions(+), 20 deletions(-) rename src/{bench_ecdh.c => modules/ecdh/bench_impl.h} (89%) diff --git a/.gitignore b/.gitignore index 2ed952579..4c3aaa32d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ bench -bench_ecdh bench_ecmult bench_schnorrsig bench_recover diff --git a/ci/cirrus.sh b/ci/cirrus.sh index a87494314..e48c899bc 100755 --- a/ci/cirrus.sh +++ b/ci/cirrus.sh @@ -55,10 +55,6 @@ then then $EXEC ./bench_recover >> bench.log 2>&1 fi - if [ "$ECDH" = "yes" ] - then - $EXEC ./bench_ecdh >> bench.log 2>&1 - fi if [ "$SCHNORRSIG" = "yes" ] then $EXEC ./bench_schnorrsig >> bench.log 2>&1 diff --git a/src/bench.c b/src/bench.c index 704c7c09c..de74dd25e 100644 --- a/src/bench.c +++ b/src/bench.c @@ -76,6 +76,10 @@ static void bench_sign_run(void* arg, int iters) { } } +#ifdef ENABLE_MODULE_ECDH +# include "modules/ecdh/bench_impl.h" +#endif + int main(void) { int i; secp256k1_pubkey pubkey; @@ -112,5 +116,10 @@ int main(void) { secp256k1_context_destroy(data.ctx); +#ifdef ENABLE_MODULE_ECDH + /* ECDH benchmarks */ + run_ecdh_bench(iters); +#endif + return 0; } diff --git a/src/modules/ecdh/Makefile.am.include b/src/modules/ecdh/Makefile.am.include index e3088b469..7f7f95f1f 100644 --- a/src/modules/ecdh/Makefile.am.include +++ b/src/modules/ecdh/Makefile.am.include @@ -1,8 +1,4 @@ include_HEADERS += include/secp256k1_ecdh.h noinst_HEADERS += src/modules/ecdh/main_impl.h noinst_HEADERS += src/modules/ecdh/tests_impl.h -if USE_BENCHMARK -noinst_PROGRAMS += bench_ecdh -bench_ecdh_SOURCES = src/bench_ecdh.c -bench_ecdh_LDADD = libsecp256k1.la $(SECP_LIBS) $(COMMON_LIB) -endif +noinst_HEADERS += src/modules/ecdh/bench_impl.h diff --git a/src/bench_ecdh.c b/src/modules/ecdh/bench_impl.h similarity index 89% rename from src/bench_ecdh.c rename to src/modules/ecdh/bench_impl.h index b6d4ee294..0b8b74e23 100644 --- a/src/bench_ecdh.c +++ b/src/modules/ecdh/bench_impl.h @@ -4,12 +4,10 @@ * file COPYING or https://www.opensource.org/licenses/mit-license.php.* ***********************************************************************/ -#include +#ifndef SECP256K1_MODULE_ECDH_BENCH_H +#define SECP256K1_MODULE_ECDH_BENCH_H -#include "../include/secp256k1.h" #include "../include/secp256k1_ecdh.h" -#include "util.h" -#include "bench.h" typedef struct { secp256k1_context *ctx; @@ -44,18 +42,15 @@ static void bench_ecdh(void* arg, int iters) { } } -int main(void) { +void run_ecdh_bench(int iters) { bench_ecdh_data data; - int iters = get_iters(20000); - /* create a context with no capabilities */ data.ctx = secp256k1_context_create(SECP256K1_FLAGS_TYPE_CONTEXT); - print_output_table_header_row(); - run_benchmark("ecdh", bench_ecdh, bench_ecdh_setup, NULL, &data, 10, iters); secp256k1_context_destroy(data.ctx); - return 0; } + +#endif /* SECP256K1_MODULE_ECDH_BENCH_H */