Skip to content

Commit

Permalink
scripted-diff: Replace gArgs with local argsman in bench
Browse files Browse the repository at this point in the history
-BEGIN VERIFY SCRIPT-
sed -i -e 's/gArgs/argsman/g' src/bench/bench_bitcoin.cpp
-END VERIFY SCRIPT-
  • Loading branch information
MarcoFalke committed Apr 16, 2020
1 parent fa2bc41 commit fa46aeb
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions src/bench/bench_bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,38 @@ static const int64_t DEFAULT_PLOT_HEIGHT = 768;

static void SetupBenchArgs(ArgsManager& argsman)
{
SetupHelpOptions(gArgs);

gArgs.AddArg("-list", "List benchmarks without executing them. Can be combined with -scaling and -filter", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
gArgs.AddArg("-evals=<n>", strprintf("Number of measurement evaluations to perform. (default: %u)", DEFAULT_BENCH_EVALUATIONS), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
gArgs.AddArg("-filter=<regex>", strprintf("Regular expression filter to select benchmark by name (default: %s)", DEFAULT_BENCH_FILTER), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
gArgs.AddArg("-scaling=<n>", strprintf("Scaling factor for benchmark's runtime (default: %u)", DEFAULT_BENCH_SCALING), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
gArgs.AddArg("-printer=(console|plot)", strprintf("Choose printer format. console: print data to console. plot: Print results as HTML graph (default: %s)", DEFAULT_BENCH_PRINTER), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
gArgs.AddArg("-plot-plotlyurl=<uri>", strprintf("URL to use for plotly.js (default: %s)", DEFAULT_PLOT_PLOTLYURL), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
gArgs.AddArg("-plot-width=<x>", strprintf("Plot width in pixel (default: %u)", DEFAULT_PLOT_WIDTH), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
gArgs.AddArg("-plot-height=<x>", strprintf("Plot height in pixel (default: %u)", DEFAULT_PLOT_HEIGHT), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
SetupHelpOptions(argsman);

argsman.AddArg("-list", "List benchmarks without executing them. Can be combined with -scaling and -filter", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-evals=<n>", strprintf("Number of measurement evaluations to perform. (default: %u)", DEFAULT_BENCH_EVALUATIONS), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-filter=<regex>", strprintf("Regular expression filter to select benchmark by name (default: %s)", DEFAULT_BENCH_FILTER), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-scaling=<n>", strprintf("Scaling factor for benchmark's runtime (default: %u)", DEFAULT_BENCH_SCALING), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-printer=(console|plot)", strprintf("Choose printer format. console: print data to console. plot: Print results as HTML graph (default: %s)", DEFAULT_BENCH_PRINTER), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-plot-plotlyurl=<uri>", strprintf("URL to use for plotly.js (default: %s)", DEFAULT_PLOT_PLOTLYURL), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-plot-width=<x>", strprintf("Plot width in pixel (default: %u)", DEFAULT_PLOT_WIDTH), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-plot-height=<x>", strprintf("Plot height in pixel (default: %u)", DEFAULT_PLOT_HEIGHT), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
}

int main(int argc, char** argv)
{
ArgsManager argsman;
SetupBenchArgs(argsman);
std::string error;
if (!gArgs.ParseParameters(argc, argv, error)) {
if (!argsman.ParseParameters(argc, argv, error)) {
tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error);
return EXIT_FAILURE;
}

if (HelpRequested(gArgs)) {
std::cout << gArgs.GetHelpMessage();
if (HelpRequested(argsman)) {
std::cout << argsman.GetHelpMessage();

return EXIT_SUCCESS;
}

int64_t evaluations = gArgs.GetArg("-evals", DEFAULT_BENCH_EVALUATIONS);
std::string regex_filter = gArgs.GetArg("-filter", DEFAULT_BENCH_FILTER);
std::string scaling_str = gArgs.GetArg("-scaling", DEFAULT_BENCH_SCALING);
bool is_list_only = gArgs.GetBoolArg("-list", false);
int64_t evaluations = argsman.GetArg("-evals", DEFAULT_BENCH_EVALUATIONS);
std::string regex_filter = argsman.GetArg("-filter", DEFAULT_BENCH_FILTER);
std::string scaling_str = argsman.GetArg("-scaling", DEFAULT_BENCH_SCALING);
bool is_list_only = argsman.GetBoolArg("-list", false);

if (evaluations == 0) {
return EXIT_SUCCESS;
Expand All @@ -66,15 +66,15 @@ int main(int argc, char** argv)
}

std::unique_ptr<benchmark::Printer> printer = MakeUnique<benchmark::ConsolePrinter>();
std::string printer_arg = gArgs.GetArg("-printer", DEFAULT_BENCH_PRINTER);
std::string printer_arg = argsman.GetArg("-printer", DEFAULT_BENCH_PRINTER);
if ("plot" == printer_arg) {
printer.reset(new benchmark::PlotlyPrinter(
gArgs.GetArg("-plot-plotlyurl", DEFAULT_PLOT_PLOTLYURL),
gArgs.GetArg("-plot-width", DEFAULT_PLOT_WIDTH),
gArgs.GetArg("-plot-height", DEFAULT_PLOT_HEIGHT)));
argsman.GetArg("-plot-plotlyurl", DEFAULT_PLOT_PLOTLYURL),
argsman.GetArg("-plot-width", DEFAULT_PLOT_WIDTH),
argsman.GetArg("-plot-height", DEFAULT_PLOT_HEIGHT)));
}

gArgs.ClearArgs(); // gArgs no longer needed. Clear it here to avoid interactions with the testing setup in the benches
argsman.ClearArgs(); // argsman no longer needed. Clear it here to avoid interactions with the testing setup in the benches

benchmark::BenchRunner::RunAll(*printer, evaluations, scaling_factor, regex_filter, is_list_only);

Expand Down

0 comments on commit fa46aeb

Please sign in to comment.