Skip to content

Commit da4e2f1

Browse files
jonatackmartinus
authored andcommitted
bench: various args improvements
- use ALLOW_BOOL for -list arg instead of ALLOW_ANY - touch up `-asymptote=<n1,n2,n3...>` help - pack Args struct a bit more efficiently - handle args in alphabetical order
1 parent d312fd9 commit da4e2f1

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/bench/bench.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ using ankerl::nanobench::Bench;
4141
typedef std::function<void(Bench&)> BenchFunction;
4242

4343
struct Args {
44-
std::string regex_filter;
4544
bool is_list_only;
4645
std::chrono::milliseconds min_time;
4746
std::vector<double> asymptote;
4847
std::string output_csv;
4948
std::string output_json;
49+
std::string regex_filter;
5050
};
5151

5252
class BenchRunner

src/bench/bench_bitcoin.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ static void SetupBenchArgs(ArgsManager& argsman)
2222
{
2323
SetupHelpOptions(argsman);
2424

25-
argsman.AddArg("-asymptote=n1,n2,n3,...", "Test asymptotic growth of the runtime of an algorithm, if supported by the benchmark", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
25+
argsman.AddArg("-asymptote=<n1,n2,n3,...>", "Test asymptotic growth of the runtime of an algorithm, if supported by the benchmark", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
2626
argsman.AddArg("-filter=<regex>", strprintf("Regular expression filter to select benchmark by name (default: %s)", DEFAULT_BENCH_FILTER), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
27-
argsman.AddArg("-list", "List benchmarks without executing them", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
27+
argsman.AddArg("-list", "List benchmarks without executing them", ArgsManager::ALLOW_BOOL, OptionsCategory::OPTIONS);
2828
argsman.AddArg("-min_time=<milliseconds>", strprintf("Minimum runtime per benchmark, in milliseconds (default: %d)", DEFAULT_MIN_TIME_MS), ArgsManager::ALLOW_INT, OptionsCategory::OPTIONS);
2929
argsman.AddArg("-output_csv=<output.csv>", "Generate CSV file with the most important benchmark results", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
3030
argsman.AddArg("-output_json=<output.json>", "Generate JSON file with all benchmark results", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
@@ -105,12 +105,12 @@ int main(int argc, char** argv)
105105
}
106106

107107
benchmark::Args args;
108-
args.regex_filter = argsman.GetArg("-filter", DEFAULT_BENCH_FILTER);
109-
args.is_list_only = argsman.GetBoolArg("-list", false);
110108
args.asymptote = parseAsymptote(argsman.GetArg("-asymptote", ""));
109+
args.is_list_only = argsman.GetBoolArg("-list", false);
111110
args.min_time = std::chrono::milliseconds(argsman.GetArg("-min_time", DEFAULT_MIN_TIME_MS));
112111
args.output_csv = argsman.GetArg("-output_csv", "");
113112
args.output_json = argsman.GetArg("-output_json", "");
113+
args.regex_filter = argsman.GetArg("-filter", DEFAULT_BENCH_FILTER);
114114

115115
benchmark::BenchRunner::RunAll(args);
116116

0 commit comments

Comments
 (0)