Merge bench_ecdh into bench

This commit is contained in:
Pieter Wuille 2021-10-17 12:10:23 -04:00
parent 2a7be678a6
commit 855e18d8a8
5 changed files with 15 additions and 20 deletions

1
.gitignore vendored
View File

@ -1,5 +1,4 @@
bench bench
bench_ecdh
bench_ecmult bench_ecmult
bench_schnorrsig bench_schnorrsig
bench_recover bench_recover

View File

@ -55,10 +55,6 @@ then
then then
$EXEC ./bench_recover >> bench.log 2>&1 $EXEC ./bench_recover >> bench.log 2>&1
fi fi
if [ "$ECDH" = "yes" ]
then
$EXEC ./bench_ecdh >> bench.log 2>&1
fi
if [ "$SCHNORRSIG" = "yes" ] if [ "$SCHNORRSIG" = "yes" ]
then then
$EXEC ./bench_schnorrsig >> bench.log 2>&1 $EXEC ./bench_schnorrsig >> bench.log 2>&1

View File

@ -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 main(void) {
int i; int i;
secp256k1_pubkey pubkey; secp256k1_pubkey pubkey;
@ -112,5 +116,10 @@ int main(void) {
secp256k1_context_destroy(data.ctx); secp256k1_context_destroy(data.ctx);
#ifdef ENABLE_MODULE_ECDH
/* ECDH benchmarks */
run_ecdh_bench(iters);
#endif
return 0; return 0;
} }

View File

@ -1,8 +1,4 @@
include_HEADERS += include/secp256k1_ecdh.h include_HEADERS += include/secp256k1_ecdh.h
noinst_HEADERS += src/modules/ecdh/main_impl.h noinst_HEADERS += src/modules/ecdh/main_impl.h
noinst_HEADERS += src/modules/ecdh/tests_impl.h noinst_HEADERS += src/modules/ecdh/tests_impl.h
if USE_BENCHMARK noinst_HEADERS += src/modules/ecdh/bench_impl.h
noinst_PROGRAMS += bench_ecdh
bench_ecdh_SOURCES = src/bench_ecdh.c
bench_ecdh_LDADD = libsecp256k1.la $(SECP_LIBS) $(COMMON_LIB)
endif

View File

@ -4,12 +4,10 @@
* file COPYING or https://www.opensource.org/licenses/mit-license.php.* * file COPYING or https://www.opensource.org/licenses/mit-license.php.*
***********************************************************************/ ***********************************************************************/
#include <string.h> #ifndef SECP256K1_MODULE_ECDH_BENCH_H
#define SECP256K1_MODULE_ECDH_BENCH_H
#include "../include/secp256k1.h"
#include "../include/secp256k1_ecdh.h" #include "../include/secp256k1_ecdh.h"
#include "util.h"
#include "bench.h"
typedef struct { typedef struct {
secp256k1_context *ctx; 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; bench_ecdh_data data;
int iters = get_iters(20000);
/* create a context with no capabilities */ /* create a context with no capabilities */
data.ctx = secp256k1_context_create(SECP256K1_FLAGS_TYPE_CONTEXT); 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); run_benchmark("ecdh", bench_ecdh, bench_ecdh_setup, NULL, &data, 10, iters);
secp256k1_context_destroy(data.ctx); secp256k1_context_destroy(data.ctx);
return 0;
} }
#endif /* SECP256K1_MODULE_ECDH_BENCH_H */