25 argsman.
AddArg(
"-asymptote=<n1,n2,n3,...>",
26 "Test asymptotic growth of the runtime of an algorithm, if "
27 "supported by the benchmark",
29 argsman.
AddArg(
"-filter=<regex>",
30 strprintf(
"Regular expression filter to select benchmark by "
34 argsman.
AddArg(
"-list",
"List benchmarks without executing them",
37 "-min_time=<milliseconds>",
39 "Minimum runtime per benchmark, in milliseconds (default: %d)",
44 "-output_csv=<output.csv>",
45 "Generate CSV file with the most important benchmark results",
47 argsman.
AddArg(
"-output_json=<output.json>",
48 "Generate JSON file with all benchmark results",
54 std::stringstream ss(str);
55 std::vector<double> numbers;
65int main(
int argc,
char **argv) {
71 tfm::format(std::cerr,
"Error parsing command line arguments: %s\n",
78 <<
"Usage: bitcoin-bench [options]\n"
83 " bitcoin-bench executes microbenchmarks. The quality of the "
85 " highly depend on the stability of the machine. It can "
86 "sometimes be difficult\n"
87 " to get stable, repeatable results, so here are a few tips:\n"
89 " * Use pyperf [1] to disable frequency scaling, turbo boost "
91 " results, use CPU pinning and CPU isolation (see [2]).\n"
93 " * Each call of run() should do exactly the same work. E.g. "
95 " a std::vector doesn't do that as it will reallocate on "
96 "certain calls. Make\n"
97 " sure each run has exactly the same preconditions.\n"
99 " * If results are still not reliable, increase runtime with "
101 " -min_time=5000 to let a benchmark run for at least 5 "
104 " * bitcoin-bench uses nanobench [3] for which there is "
106 " documentation available online.\n"
108 "Environment Variables:\n"
110 " To attach a profiler you can run a benchmark in endless "
111 "mode. This can be\n"
112 " done with the environment variable NANOBENCH_ENDLESS. E.g. "
115 " NANOBENCH_ENDLESS=MuHash ./bitcoin-bench -filter=MuHash\n"
117 " In rare cases it can be useful to suppress stability "
118 "warnings. This can be\n"
119 " done with the environment variable "
120 "NANOBENCH_SUPPRESS_WARNINGS, e.g:\n"
122 " NANOBENCH_SUPPRESS_WARNINGS=1 ./bitcoin-bench\n"
127 " https://github.com/psf/pyperf\n"
129 " 2. CPU pinning & isolation\n"
130 " https://pyperf.readthedocs.io/en/latest/system.html\n"
133 " https://github.com/martinus/nanobench\n"
142 args.
min_time = std::chrono::milliseconds(
bool HelpRequested(const ArgsManager &args)
void SetupHelpOptions(ArgsManager &args)
Add help options to the args manager.
static constexpr int64_t DEFAULT_MIN_TIME_MS
int main(int argc, char **argv)
static std::vector< double > parseAsymptote(const std::string &str)
static const char * DEFAULT_BENCH_FILTER
static void SetupBenchArgs(ArgsManager &argsman)
@ ALLOW_ANY
disable validation
@ DISALLOW_NEGATION
unimplemented, draft implementation in #16545
bool ParseParameters(int argc, const char *const argv[], std::string &error)
std::string GetHelpMessage() const
Get the help string.
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const
Return integer argument or default value.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
void AddArg(const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat)
Add argument.
fs::path GetPathArg(std::string arg, const fs::path &default_value={}) const
Return path argument or default value.
static void RunAll(const Args &args)
std::string SHA256AutoDetect()
Autodetect the best available SHA256 implementation.
std::vector< double > asymptote
std::chrono::milliseconds min_time