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.
This commit is contained in:
kevkevinpal
2026-01-23 18:27:35 +00:00
committed by kevkevinpal
parent ebb35882da
commit c49c9be504
3 changed files with 14 additions and 14 deletions

View File

@@ -12,7 +12,7 @@
#include "util.h"
#include "bench.h"
static void help(int default_iters) {
static void help(const char *executable_path, int default_iters) {
printf("Benchmarks the following algorithms:\n");
printf(" - ECDSA signing/verification\n");
@@ -36,7 +36,7 @@ static void help(int default_iters) {
printf("The default number of iterations for each benchmark is %d. This can be\n", default_iters);
printf("customized using the SECP256K1_BENCH_ITERS environment variable.\n");
printf("\n");
printf("Usage: ./bench [args]\n");
printf("Usage: %s [args]\n", executable_path);
printf("By default, all benchmarks will be run.\n");
printf("args:\n");
printf(" help : display this help and exit\n");
@@ -189,7 +189,7 @@ int main(int argc, char** argv) {
int default_iters = 20000;
int iters = get_iters(default_iters);
if (iters == 0) {
help(default_iters);
help(argv[0], default_iters);
return EXIT_FAILURE;
}
@@ -197,11 +197,11 @@ int main(int argc, char** argv) {
if (have_flag(argc, argv, "-h")
|| have_flag(argc, argv, "--help")
|| have_flag(argc, argv, "help")) {
help(default_iters);
help(argv[0], default_iters);
return EXIT_SUCCESS;
} else if (invalid_args) {
fprintf(stderr, "./bench: unrecognized argument.\n\n");
help(default_iters);
help(argv[0], default_iters);
return EXIT_FAILURE;
}
}