From 2f77487012f5ff2fd3b4f069a8ca84463626bf61 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Thu, 20 Aug 2015 21:26:22 +0200 Subject: [PATCH] Add context building benchmarks --- src/bench_internal.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/bench_internal.c b/src/bench_internal.c index 1a06e9441a7..dbe93af538a 100644 --- a/src/bench_internal.c +++ b/src/bench_internal.c @@ -16,6 +16,7 @@ #include "ecmult_const_impl.h" #include "ecmult_impl.h" #include "bench.h" +#include "secp256k1.c" typedef struct { secp256k1_scalar_t scalar_x, scalar_y; @@ -282,6 +283,22 @@ void bench_rfc6979_hmac_sha256(void* arg) { } } +void bench_context_verify(void* arg) { + int i; + (void)arg; + for (i = 0; i < 20; i++) { + secp256k1_context_destroy(secp256k1_context_create(SECP256K1_CONTEXT_VERIFY)); + } +} + +void bench_context_sign(void* arg) { + int i; + (void)arg; + for (i = 0; i < 200; i++) { + secp256k1_context_destroy(secp256k1_context_create(SECP256K1_CONTEXT_SIGN)); + } +} + int have_flag(int argc, char** argv, char *flag) { char** argm = argv + argc; @@ -327,5 +344,9 @@ int main(int argc, char **argv) { if (have_flag(argc, argv, "hash") || have_flag(argc, argv, "sha256")) run_benchmark("hash_sha256", bench_sha256, bench_setup, NULL, &data, 10, 20000); if (have_flag(argc, argv, "hash") || have_flag(argc, argv, "hmac")) run_benchmark("hash_hmac_sha256", bench_hmac_sha256, bench_setup, NULL, &data, 10, 20000); if (have_flag(argc, argv, "hash") || have_flag(argc, argv, "rng6979")) run_benchmark("hash_rfc6979_hmac_sha256", bench_rfc6979_hmac_sha256, bench_setup, NULL, &data, 10, 20000); + + if (have_flag(argc, argv, "context") || have_flag(argc, argv, "verify")) run_benchmark("context_verify", bench_context_verify, bench_setup, NULL, &data, 10, 20); + if (have_flag(argc, argv, "context") || have_flag(argc, argv, "sign")) run_benchmark("context_sign", bench_context_sign, bench_setup, NULL, &data, 10, 200); + return 0; }