diff --git a/src/bench/bench_bitcoin.cpp b/src/bench/bench_bitcoin.cpp --- a/src/bench/bench_bitcoin.cpp +++ b/src/bench/bench_bitcoin.cpp @@ -18,67 +18,68 @@ static const int64_t DEFAULT_PLOT_WIDTH = 1024; static const int64_t DEFAULT_PLOT_HEIGHT = 768; -static void SetupBenchArgs() { - SetupHelpOptions(gArgs); +static void SetupBenchArgs(ArgsManager &argsman) { + SetupHelpOptions(argsman); - gArgs.AddArg("-list", - "List benchmarks without executing them. Can be combined " - "with -scaling and -filter", - ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); - gArgs.AddArg( + argsman.AddArg("-list", + "List benchmarks without executing them. Can be combined " + "with -scaling and -filter", + ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); + argsman.AddArg( "-evals=", strprintf("Number of measurement evaluations to perform. (default: %u)", DEFAULT_BENCH_EVALUATIONS), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); - gArgs.AddArg("-filter=", - strprintf("Regular expression filter to select benchmark by " - "name (default: %s)", - DEFAULT_BENCH_FILTER), - ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); - gArgs.AddArg( + argsman.AddArg("-filter=", + strprintf("Regular expression filter to select benchmark by " + "name (default: %s)", + DEFAULT_BENCH_FILTER), + ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); + argsman.AddArg( "-scaling=", strprintf("Scaling factor for benchmark's runtime (default: %u)", DEFAULT_BENCH_SCALING), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); - gArgs.AddArg( + argsman.AddArg( "-printer=(console|junit|plot)", strprintf("Choose printer format. console: print data to console. " "junit: print results as a Junit compliant XML." "plot: print results as HTML graph (default: %s)", DEFAULT_BENCH_PRINTER), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); - gArgs.AddArg("-plot-plotlyurl=", - strprintf("URL to use for plotly.js (default: %s)", - DEFAULT_PLOT_PLOTLYURL), - ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); - gArgs.AddArg( + argsman.AddArg("-plot-plotlyurl=", + strprintf("URL to use for plotly.js (default: %s)", + DEFAULT_PLOT_PLOTLYURL), + ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); + argsman.AddArg( "-plot-width=", strprintf("Plot width in pixel (default: %u)", DEFAULT_PLOT_WIDTH), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); - gArgs.AddArg( + argsman.AddArg( "-plot-height=", strprintf("Plot height in pixel (default: %u)", DEFAULT_PLOT_HEIGHT), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); } int main(int argc, char **argv) { - SetupBenchArgs(); + 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); double scaling_factor; if (!ParseDouble(scaling_str, &scaling_factor)) { @@ -89,12 +90,12 @@ std::unique_ptr printer = std::make_unique(); - 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))); } if ("junit" == printer_arg) { printer.reset(new benchmark::JunitPrinter()); diff --git a/src/util/system.h b/src/util/system.h --- a/src/util/system.h +++ b/src/util/system.h @@ -210,6 +210,7 @@ public: ArgsManager(); + ~ArgsManager(); /** * Select the network in use diff --git a/src/util/system.cpp b/src/util/system.cpp --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -238,9 +238,11 @@ return true; } -ArgsManager::ArgsManager() { - // nothing to do -} +// Define default constructor and destructor that are not inline, so code +// instantiating this class doesn't need to #include class definitions for all +// members. For example, m_settings has an internal dependency on univalue. +ArgsManager::ArgsManager() {} +ArgsManager::~ArgsManager() {} const std::set ArgsManager::GetUnsuitableSectionOnlyArgs() const { std::set unsuitables;