|
17 | 17 | #include "ecmult_impl.h" |
18 | 18 | #include "bench.h" |
19 | 19 |
|
| 20 | +static void help(int default_iters) { |
| 21 | + printf("Benchmarks internal routines for the following areas:\n"); |
| 22 | + printf(" - Scalar operations (modulo the curve's order)\n"); |
| 23 | + printf(" - Field operations (modulo the curve's field size)\n"); |
| 24 | + printf(" - Group operations (both in Jacobian and affine coordinates)\n"); |
| 25 | + printf(" - Point multiplication\n"); |
| 26 | + printf(" - Hash algorithms\n"); |
| 27 | + printf(" - Context object handling\n"); |
| 28 | + printf("\n"); |
| 29 | + printf("The default number of iterations for each benchmark is %d. This can be\n", default_iters); |
| 30 | + printf("customized using the SECP256K1_BENCH_ITERS environment variable.\n"); |
| 31 | + printf("\n"); |
| 32 | + printf("Usage: ./bench_internal [args]\n"); |
| 33 | + printf("By default, all benchmarks will be run.\n"); |
| 34 | + printf("args:\n"); |
| 35 | + printf(" help : display this help and exit\n"); |
| 36 | + printf(" scalar : all scalar operations (add, half, inverse, mul, negate, split)\n"); |
| 37 | + printf(" field : all field operations (half, inverse, issquare, mul, normalize, sqr, sqrt)\n"); |
| 38 | + printf(" group : all group operations (add, double, to_affine)\n"); |
| 39 | + printf(" ecmult : all point multiplication operations (ecmult_wnaf) \n"); |
| 40 | + printf(" hash : all hash algorithms (hmac, rng6979, sha256)\n"); |
| 41 | + printf(" context : all context object operations (context_create)\n"); |
| 42 | + printf("\n"); |
| 43 | +} |
| 44 | + |
20 | 45 | typedef struct { |
21 | 46 | secp256k1_scalar scalar[2]; |
22 | 47 | secp256k1_fe fe[4]; |
@@ -365,8 +390,19 @@ static void bench_context(void* arg, int iters) { |
365 | 390 |
|
366 | 391 | int main(int argc, char **argv) { |
367 | 392 | bench_inv data; |
368 | | - int iters = get_iters(20000); |
| 393 | + int default_iters = 20000; |
| 394 | + int iters = get_iters(default_iters); |
369 | 395 | int d = argc == 1; /* default */ |
| 396 | + |
| 397 | + if (argc > 1) { |
| 398 | + if (have_flag(argc, argv, "-h") |
| 399 | + || have_flag(argc, argv, "--help") |
| 400 | + || have_flag(argc, argv, "help")) { |
| 401 | + help(default_iters); |
| 402 | + return 0; |
| 403 | + } |
| 404 | + } |
| 405 | + |
370 | 406 | print_output_table_header_row(); |
371 | 407 |
|
372 | 408 | if (d || have_flag(argc, argv, "scalar") || have_flag(argc, argv, "half")) run_benchmark("scalar_half", bench_scalar_half, bench_setup, NULL, &data, 10, iters*100); |
|
0 commit comments