|  | 
| 17 | 17 | #include "ecmult_impl.h" | 
| 18 | 18 | #include "bench.h" | 
| 19 | 19 | 
 | 
|  | 20 | +static void help(int default_iters) { | 
|  | 21 | +    printf("Benchmarks various internal routines.\n"); | 
|  | 22 | +    printf("\n"); | 
|  | 23 | +    printf("The default number of iterations for each benchmark is %d. This can be\n", default_iters); | 
|  | 24 | +    printf("customized using the SECP256K1_BENCH_ITERS environment variable.\n"); | 
|  | 25 | +    printf("\n"); | 
|  | 26 | +    printf("Usage: ./bench_internal [args]\n"); | 
|  | 27 | +    printf("By default, all benchmarks will be run.\n"); | 
|  | 28 | +    printf("args:\n"); | 
|  | 29 | +    printf("    help       : display this help and exit\n"); | 
|  | 30 | +    printf("    scalar     : all scalar operations (add, half, inverse, mul, negate, split)\n"); | 
|  | 31 | +    printf("    field      : all field operations (half, inverse, issquare, mul, normalize, sqr, sqrt)\n"); | 
|  | 32 | +    printf("    group      : all group operations (add, double, to_affine)\n"); | 
|  | 33 | +    printf("    ecmult     : all point multiplication operations (ecmult_wnaf) \n"); | 
|  | 34 | +    printf("    hash       : all hash algorithms (hmac, rng6979, sha256)\n"); | 
|  | 35 | +    printf("    context    : all context object operations (context_create)\n"); | 
|  | 36 | +    printf("\n"); | 
|  | 37 | +} | 
|  | 38 | + | 
| 20 | 39 | typedef struct { | 
| 21 | 40 |     secp256k1_scalar scalar[2]; | 
| 22 | 41 |     secp256k1_fe fe[4]; | 
| @@ -365,8 +384,19 @@ static void bench_context(void* arg, int iters) { | 
| 365 | 384 | 
 | 
| 366 | 385 | int main(int argc, char **argv) { | 
| 367 | 386 |     bench_inv data; | 
| 368 |  | -    int iters = get_iters(20000); | 
|  | 387 | +    int default_iters = 20000; | 
|  | 388 | +    int iters = get_iters(default_iters); | 
| 369 | 389 |     int d = argc == 1; /* default */ | 
|  | 390 | + | 
|  | 391 | +    if (argc > 1) { | 
|  | 392 | +        if (have_flag(argc, argv, "-h") | 
|  | 393 | +           || have_flag(argc, argv, "--help") | 
|  | 394 | +           || have_flag(argc, argv, "help")) { | 
|  | 395 | +            help(default_iters); | 
|  | 396 | +            return 0; | 
|  | 397 | +        } | 
|  | 398 | +    } | 
|  | 399 | + | 
| 370 | 400 |     print_output_table_header_row(); | 
| 371 | 401 | 
 | 
| 372 | 402 |     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