benchmarks: Switch to NONE contexts
This commit is contained in:
parent
e3f84777eb
commit
8d7a9a8eda
15
src/bench.c
15
src/bench.c
|
@ -164,7 +164,7 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
/* Check if the user tries to benchmark optional module without building it */
|
/* Check if the user tries to benchmark optional module without building it */
|
||||||
#ifndef ENABLE_MODULE_ECDH
|
#ifndef ENABLE_MODULE_ECDH
|
||||||
if (have_flag(argc, argv, "ecdh")) {
|
if (have_flag(argc, argv, "ecdh")) {
|
||||||
fprintf(stderr, "./bench: ECDH module not enabled.\n");
|
fprintf(stderr, "./bench: ECDH module not enabled.\n");
|
||||||
fprintf(stderr, "Use ./configure --enable-module-ecdh.\n\n");
|
fprintf(stderr, "Use ./configure --enable-module-ecdh.\n\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -172,7 +172,7 @@ int main(int argc, char** argv) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ENABLE_MODULE_RECOVERY
|
#ifndef ENABLE_MODULE_RECOVERY
|
||||||
if (have_flag(argc, argv, "recover") || have_flag(argc, argv, "ecdsa_recover")) {
|
if (have_flag(argc, argv, "recover") || have_flag(argc, argv, "ecdsa_recover")) {
|
||||||
fprintf(stderr, "./bench: Public key recovery module not enabled.\n");
|
fprintf(stderr, "./bench: Public key recovery module not enabled.\n");
|
||||||
fprintf(stderr, "Use ./configure --enable-module-recovery.\n\n");
|
fprintf(stderr, "Use ./configure --enable-module-recovery.\n\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -180,15 +180,15 @@ int main(int argc, char** argv) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ENABLE_MODULE_SCHNORRSIG
|
#ifndef ENABLE_MODULE_SCHNORRSIG
|
||||||
if (have_flag(argc, argv, "schnorrsig") || have_flag(argc, argv, "schnorrsig_sign") || have_flag(argc, argv, "schnorrsig_verify")) {
|
if (have_flag(argc, argv, "schnorrsig") || have_flag(argc, argv, "schnorrsig_sign") || have_flag(argc, argv, "schnorrsig_verify")) {
|
||||||
fprintf(stderr, "./bench: Schnorr signatures module not enabled.\n");
|
fprintf(stderr, "./bench: Schnorr signatures module not enabled.\n");
|
||||||
fprintf(stderr, "Use ./configure --enable-module-schnorrsig.\n\n");
|
fprintf(stderr, "Use ./configure --enable-module-schnorrsig.\n\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ECDSA verification benchmark */
|
/* ECDSA benchmark */
|
||||||
data.ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY);
|
data.ctx = secp256k1_context_create(SECP256K1_CONTEXT_NONE);
|
||||||
|
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
data.msg[i] = 1 + i;
|
data.msg[i] = 1 + i;
|
||||||
|
@ -206,11 +206,6 @@ int main(int argc, char** argv) {
|
||||||
print_output_table_header_row();
|
print_output_table_header_row();
|
||||||
if (d || have_flag(argc, argv, "ecdsa") || have_flag(argc, argv, "verify") || have_flag(argc, argv, "ecdsa_verify")) run_benchmark("ecdsa_verify", bench_verify, NULL, NULL, &data, 10, iters);
|
if (d || have_flag(argc, argv, "ecdsa") || have_flag(argc, argv, "verify") || have_flag(argc, argv, "ecdsa_verify")) run_benchmark("ecdsa_verify", bench_verify, NULL, NULL, &data, 10, iters);
|
||||||
|
|
||||||
secp256k1_context_destroy(data.ctx);
|
|
||||||
|
|
||||||
/* ECDSA signing benchmark */
|
|
||||||
data.ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN);
|
|
||||||
|
|
||||||
if (d || have_flag(argc, argv, "ecdsa") || have_flag(argc, argv, "sign") || have_flag(argc, argv, "ecdsa_sign")) run_benchmark("ecdsa_sign", bench_sign_run, bench_sign_setup, NULL, &data, 10, iters);
|
if (d || have_flag(argc, argv, "ecdsa") || have_flag(argc, argv, "sign") || have_flag(argc, argv, "ecdsa_sign")) run_benchmark("ecdsa_sign", bench_sign_run, bench_sign_setup, NULL, &data, 10, iters);
|
||||||
|
|
||||||
secp256k1_context_destroy(data.ctx);
|
secp256k1_context_destroy(data.ctx);
|
||||||
|
|
|
@ -308,7 +308,7 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data.ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY);
|
data.ctx = secp256k1_context_create(SECP256K1_CONTEXT_NONE);
|
||||||
scratch_size = secp256k1_strauss_scratch_size(POINTS) + STRAUSS_SCRATCH_OBJECTS*16;
|
scratch_size = secp256k1_strauss_scratch_size(POINTS) + STRAUSS_SCRATCH_OBJECTS*16;
|
||||||
if (!have_flag(argc, argv, "simple")) {
|
if (!have_flag(argc, argv, "simple")) {
|
||||||
data.scratch = secp256k1_scratch_space_create(data.ctx, scratch_size);
|
data.scratch = secp256k1_scratch_space_create(data.ctx, scratch_size);
|
||||||
|
|
|
@ -343,19 +343,11 @@ void bench_rfc6979_hmac_sha256(void* arg, int iters) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bench_context_verify(void* arg, int iters) {
|
void bench_context(void* arg, int iters) {
|
||||||
int i;
|
int i;
|
||||||
(void)arg;
|
(void)arg;
|
||||||
for (i = 0; i < iters; i++) {
|
for (i = 0; i < iters; i++) {
|
||||||
secp256k1_context_destroy(secp256k1_context_create(SECP256K1_CONTEXT_VERIFY));
|
secp256k1_context_destroy(secp256k1_context_create(SECP256K1_CONTEXT_NONE));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void bench_context_sign(void* arg, int iters) {
|
|
||||||
int i;
|
|
||||||
(void)arg;
|
|
||||||
for (i = 0; i < iters; i++) {
|
|
||||||
secp256k1_context_destroy(secp256k1_context_create(SECP256K1_CONTEXT_SIGN));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,8 +387,7 @@ int main(int argc, char **argv) {
|
||||||
if (d || have_flag(argc, argv, "hash") || have_flag(argc, argv, "hmac")) run_benchmark("hash_hmac_sha256", bench_hmac_sha256, bench_setup, NULL, &data, 10, iters);
|
if (d || have_flag(argc, argv, "hash") || have_flag(argc, argv, "hmac")) run_benchmark("hash_hmac_sha256", bench_hmac_sha256, bench_setup, NULL, &data, 10, iters);
|
||||||
if (d || 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, iters);
|
if (d || 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, iters);
|
||||||
|
|
||||||
if (d || have_flag(argc, argv, "context") || have_flag(argc, argv, "verify")) run_benchmark("context_verify", bench_context_verify, bench_setup, NULL, &data, 10, 1 + iters/1000);
|
if (d || have_flag(argc, argv, "context")) run_benchmark("context_create", bench_context, bench_setup, NULL, &data, 10, iters);
|
||||||
if (d || have_flag(argc, argv, "context") || have_flag(argc, argv, "sign")) run_benchmark("context_sign", bench_context_sign, bench_setup, NULL, &data, 10, 1 + iters/100);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ void run_recovery_bench(int iters, int argc, char** argv) {
|
||||||
bench_recover_data data;
|
bench_recover_data data;
|
||||||
int d = argc == 1;
|
int d = argc == 1;
|
||||||
|
|
||||||
data.ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY);
|
data.ctx = secp256k1_context_create(SECP256K1_CONTEXT_NONE);
|
||||||
|
|
||||||
if (d || have_flag(argc, argv, "ecdsa") || have_flag(argc, argv, "recover") || have_flag(argc, argv, "ecdsa_recover")) run_benchmark("ecdsa_recover", bench_recover, bench_recover_setup, NULL, &data, 10, iters);
|
if (d || have_flag(argc, argv, "ecdsa") || have_flag(argc, argv, "recover") || have_flag(argc, argv, "ecdsa_recover")) run_benchmark("ecdsa_recover", bench_recover, bench_recover_setup, NULL, &data, 10, iters);
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ void run_schnorrsig_bench(int iters, int argc, char** argv) {
|
||||||
bench_schnorrsig_data data;
|
bench_schnorrsig_data data;
|
||||||
int d = argc == 1;
|
int d = argc == 1;
|
||||||
|
|
||||||
data.ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY | SECP256K1_CONTEXT_SIGN);
|
data.ctx = secp256k1_context_create(SECP256K1_CONTEXT_NONE);
|
||||||
data.keypairs = (const secp256k1_keypair **)malloc(iters * sizeof(secp256k1_keypair *));
|
data.keypairs = (const secp256k1_keypair **)malloc(iters * sizeof(secp256k1_keypair *));
|
||||||
data.pk = (const unsigned char **)malloc(iters * sizeof(unsigned char *));
|
data.pk = (const unsigned char **)malloc(iters * sizeof(unsigned char *));
|
||||||
data.msgs = (const unsigned char **)malloc(iters * sizeof(unsigned char *));
|
data.msgs = (const unsigned char **)malloc(iters * sizeof(unsigned char *));
|
||||||
|
|
Loading…
Reference in New Issue