bench: Update help functions in bench and bench_internal #1811

pull kevkevinpal wants to merge 1 commits into bitcoin-core:master from kevkevinpal:refactorHelpBenchFunction changing 3 files +14 −14
  1. kevkevinpal commented at 1:01 pm on January 27, 2026: contributor

    Motivation

    This change is motivated by #1793#pullrequestreview-3644885897

    While aligning implementation across all benchmarks, argv could be passed to the help() in bench.c and bench_internal.c.

    Description

    In the bench and bench_internal help functions argv was not being passed. In this change, we pass in argv and use it in the help text.

  2. in src/bench.c:15 in 58ee45b13d
    11@@ -12,7 +12,7 @@
    12 #include "util.h"
    13 #include "bench.h"
    14 
    15-static void help(int default_iters) {
    16+static void help(char **argv, int default_iters) {
    


    real-or-random commented at 8:43 am on January 30, 2026:
    nit: I know this uses only argv[0], but still, this interface seems a bit cursed because you can’t really use argv without argc. Either you pass both argc and argv (like in have_flag), or you simply only argv[0].

    kevkevinpal commented at 10:34 pm on February 3, 2026:

    Thanks for the suggestion

    I went ahead and did that in 5fb24a3

    This modifies the help() functions in bench.c, bench_ecmult.c and bench_internal.c


    real-or-random commented at 2:00 pm on February 6, 2026:

    Thanks for the update. Now that I see this variant, I tend to think that the variant where only argv[0] is passed to help() is less cluttered. I mean all of these help functions only need argv[0] (and I see no reason why they should require the remaining args in the future). Sorry for being specific only now…

    Also, can you squash after you make this change?


    kevkevinpal commented at 4:52 pm on February 6, 2026:

    No problem and sorry about that, I’ve updated and squashed in e1598c7

    Now we just have a const char *executable_path that we use. Let me know if that looks good!

    Thanks for the review!

  3. real-or-random added the label tweak/refactor on Jan 30, 2026
  4. real-or-random added the label user-documentation on Jan 30, 2026
  5. kevkevinpal force-pushed on Feb 3, 2026
  6. kevkevinpal force-pushed on Feb 6, 2026
  7. real-or-random approved
  8. real-or-random commented at 7:40 pm on February 6, 2026: contributor
    ACK e1598c7ff2ec0ed938c62da96e5aa4a666dd129c
  9. real-or-random commented at 7:40 pm on February 6, 2026: contributor
  10. in src/bench.c:39 in e1598c7ff2
    35@@ -36,7 +36,7 @@ static void help(int default_iters) {
    36     printf("The default number of iterations for each benchmark is %d. This can be\n", default_iters);
    37     printf("customized using the SECP256K1_BENCH_ITERS environment variable.\n");
    38     printf("\n");
    39-    printf("Usage: ./bench [args]\n");
    40+    printf("Usage: %s <help|ecdsa|ecdsa_sign|ecdsa_verify|ec|ec_keygen>\n", executable_path);
    


    hebasto commented at 6:51 am on February 7, 2026:
    With optional modules enabled, the list of arguments becomes inconsistent with the descriptions below, which creates confusion. I think we should leave “[args]” as a placeholder accompanied by the explanatory list. Regardless of the approach, the help output should be consistent across all benchmark binaries.

    kevkevinpal commented at 0:18 am on February 10, 2026:
    Thanks for the review, that is a fair point. I’ve updated the 3 benches to use [args] instead in c49c9be
  11. hebasto approved
  12. hebasto commented at 6:51 am on February 7, 2026: member
    ACK e1598c7ff2ec0ed938c62da96e5aa4a666dd129c, tested on Fedora 43.
  13. bench: Update help functions in bench and bench_internal
    In the bench and bench_internal help functions argv was not being
    passed, in this change we pass in argv[0] and use it in the help text.
    
    Additionally instead of passing all of argv in bench_ecmult we now
    just pass argv[0] and is used as the executable_path variable.
    c49c9be504
  14. kevkevinpal force-pushed on Feb 10, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-02-16 20:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me