From 3208557ae1062f7fcce25d5f2c5a29dc34a18895 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sun, 17 Oct 2021 13:56:59 -0400 Subject: [PATCH] Merge bench_recover into bench --- .gitignore | 1 - ci/cirrus.sh | 4 ---- src/bench.c | 9 +++++++++ src/modules/recovery/Makefile.am.include | 6 +----- .../recovery/bench_impl.h} | 15 ++++++--------- 5 files changed, 16 insertions(+), 19 deletions(-) rename src/{bench_recover.c => modules/recovery/bench_impl.h} (91%) diff --git a/.gitignore b/.gitignore index 4c3aaa32d4b31..599a2ef59f4bb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ bench bench_ecmult bench_schnorrsig -bench_recover bench_internal tests exhaustive_tests diff --git a/ci/cirrus.sh b/ci/cirrus.sh index e48c899bc1234..86d2f06b139bc 100755 --- a/ci/cirrus.sh +++ b/ci/cirrus.sh @@ -51,10 +51,6 @@ then $EXEC ./bench_internal $EXEC ./bench } >> bench.log 2>&1 - if [ "$RECOVERY" = "yes" ] - then - $EXEC ./bench_recover >> 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 de74dd25e1b8d..6b457b88f4e07 100644 --- a/src/bench.c +++ b/src/bench.c @@ -80,6 +80,10 @@ static void bench_sign_run(void* arg, int iters) { # include "modules/ecdh/bench_impl.h" #endif +#ifdef ENABLE_MODULE_RECOVERY +# include "modules/recovery/bench_impl.h" +#endif + int main(void) { int i; secp256k1_pubkey pubkey; @@ -121,5 +125,10 @@ int main(void) { run_ecdh_bench(iters); #endif +#ifdef ENABLE_MODULE_RECOVERY + /* ECDSA recovery benchmarks */ + run_recovery_bench(iters); +#endif + return 0; } diff --git a/src/modules/recovery/Makefile.am.include b/src/modules/recovery/Makefile.am.include index e2d3f1248d25c..156ea690fad01 100644 --- a/src/modules/recovery/Makefile.am.include +++ b/src/modules/recovery/Makefile.am.include @@ -2,8 +2,4 @@ include_HEADERS += include/secp256k1_recovery.h noinst_HEADERS += src/modules/recovery/main_impl.h noinst_HEADERS += src/modules/recovery/tests_impl.h noinst_HEADERS += src/modules/recovery/tests_exhaustive_impl.h -if USE_BENCHMARK -noinst_PROGRAMS += bench_recover -bench_recover_SOURCES = src/bench_recover.c -bench_recover_LDADD = libsecp256k1.la $(SECP_LIBS) $(COMMON_LIB) -endif +noinst_HEADERS += src/modules/recovery/bench_impl.h diff --git a/src/bench_recover.c b/src/modules/recovery/bench_impl.h similarity index 91% rename from src/bench_recover.c rename to src/modules/recovery/bench_impl.h index 3ccd86dd9bacd..95330b1e5472d 100644 --- a/src/bench_recover.c +++ b/src/modules/recovery/bench_impl.h @@ -4,10 +4,10 @@ * file COPYING or https://www.opensource.org/licenses/mit-license.php.* ***********************************************************************/ -#include "../include/secp256k1.h" +#ifndef SECP256K1_MODULE_RECOVERY_BENCH_H +#define SECP256K1_MODULE_RECOVERY_BENCH_H + #include "../include/secp256k1_recovery.h" -#include "util.h" -#include "bench.h" typedef struct { secp256k1_context *ctx; @@ -48,17 +48,14 @@ void bench_recover_setup(void* arg) { } } -int main(void) { +void run_recovery_bench(int iters) { bench_recover_data data; - int iters = get_iters(20000); - data.ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY); - print_output_table_header_row(); - run_benchmark("ecdsa_recover", bench_recover, bench_recover_setup, NULL, &data, 10, iters); secp256k1_context_destroy(data.ctx); - return 0; } + +#endif /* SECP256K1_MODULE_RECOVERY_BENCH_H */