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)",
43 "-output_csv=<output.csv>",
44 "Generate CSV file with the most important benchmark results",
46 argsman.
AddArg(
"-output_json=<output.json>",
47 "Generate JSON file with all benchmark results",
53 std::stringstream ss(str);
54 std::vector<double> numbers;
64int main(
int argc,
char **argv) {
70 tfm::format(std::cerr,
"Error parsing command line arguments: %s\n",
77 <<
"Usage: bitcoin-bench [options]\n"
82 " bitcoin-bench executes microbenchmarks. The quality of the "
84 " highly depend on the stability of the machine. It can "
85 "sometimes be difficult\n"
86 " to get stable, repeatable results, so here are a few tips:\n"
88 " * Use pyperf [1] to disable frequency scaling, turbo boost "
90 " results, use CPU pinning and CPU isolation (see [2]).\n"
92 " * Each call of run() should do exactly the same work. E.g. "
94 " a std::vector doesn't do that as it will reallocate on "
95 "certain calls. Make\n"
96 " sure each run has exactly the same preconditions.\n"
98 " * If results are still not reliable, increase runtime with "
100 " -min_time=5000 to let a benchmark run for at least 5 "
103 " * bitcoin-bench uses nanobench [3] for which there is "
105 " documentation available online.\n"
107 "Environment Variables:\n"
109 " To attach a profiler you can run a benchmark in endless "
110 "mode. This can be\n"
111 " done with the environment variable NANOBENCH_ENDLESS. E.g. "
114 " NANOBENCH_ENDLESS=MuHash ./bitcoin-bench -filter=MuHash\n"
116 " In rare cases it can be useful to suppress stability "
117 "warnings. This can be\n"
118 " done with the environment variable "
119 "NANOBENCH_SUPPRESS_WARNINGS, e.g:\n"
121 " NANOBENCH_SUPPRESS_WARNINGS=1 ./bitcoin-bench\n"
126 " https://github.com/psf/pyperf\n"
128 " 2. CPU pinning & isolation\n"
129 " https://pyperf.readthedocs.io/en/latest/system.html\n"
132 " https://github.com/martinus/nanobench\n"
141 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)
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)
bool error(const char *fmt, const Args &...args)
std::string SHA256AutoDetect()
Autodetect the best available SHA256 implementation.
std::vector< double > asymptote
std::chrono::milliseconds min_time