24 argsman.
AddArg(
"-asymptote=<n1,n2,n3,...>",
25 "Test asymptotic growth of the runtime of an algorithm, if "
26 "supported by the benchmark",
28 argsman.
AddArg(
"-filter=<regex>",
29 strprintf(
"Regular expression filter to select benchmark by "
33 argsman.
AddArg(
"-list",
"List benchmarks without executing them",
36 "-min_time=<milliseconds>",
38 "Minimum runtime per benchmark, in milliseconds (default: %d)",
42 "-output_csv=<output.csv>",
43 "Generate CSV file with the most important benchmark results",
45 argsman.
AddArg(
"-output_json=<output.json>",
46 "Generate JSON file with all benchmark results",
52 std::stringstream ss(str);
53 std::vector<double> numbers;
63 int main(
int argc,
char **argv) {
69 tfm::format(std::cerr,
"Error parsing command line arguments: %s\n",
76 <<
"Usage: bitcoin-bench [options]\n"
81 " bitcoin-bench executes microbenchmarks. The quality of the "
83 " highly depend on the stability of the machine. It can "
84 "sometimes be difficult\n"
85 " to get stable, repeatable results, so here are a few tips:\n"
87 " * Use pyperf [1] to disable frequency scaling, turbo boost "
89 " results, use CPU pinning and CPU isolation (see [2]).\n"
91 " * Each call of run() should do exactly the same work. E.g. "
93 " a std::vector doesn't do that as it will reallocate on "
94 "certain calls. Make\n"
95 " sure each run has exactly the same preconditions.\n"
97 " * If results are still not reliable, increase runtime with "
99 " -min_time=5000 to let a benchmark run for at least 5 "
102 " * bitcoin-bench uses nanobench [3] for which there is "
104 " documentation available online.\n"
106 "Environment Variables:\n"
108 " To attach a profiler you can run a benchmark in endless "
109 "mode. This can be\n"
110 " done with the environment variable NANOBENCH_ENDLESS. E.g. "
113 " NANOBENCH_ENDLESS=MuHash ./bitcoin-bench -filter=MuHash\n"
115 " In rare cases it can be useful to suppress stability "
116 "warnings. This can be\n"
117 " done with the environment variable "
118 "NANOBENCH_SUPPRESS_WARNINGS, e.g:\n"
120 " NANOBENCH_SUPPRESS_WARNINGS=1 ./bitcoin-bench\n"
125 " https://github.com/psf/pyperf\n"
127 " 2. CPU pinning & isolation\n"
128 " https://pyperf.readthedocs.io/en/latest/system.html\n"
131 " https://github.com/martinus/nanobench\n"
140 args.
min_time = std::chrono::milliseconds(
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.
static void RunAll(const Args &args)
std::string SHA256AutoDetect()
Autodetect the best available SHA256 implementation.
std::vector< double > asymptote
std::chrono::milliseconds min_time
bool HelpRequested(const ArgsManager &args)
void SetupHelpOptions(ArgsManager &args)
Add help options to the args manager.
bool error(const char *fmt, const Args &...args)