40 std::stringstream ss(str);
41 std::vector<double> numbers;
54 std::vector<std::string>
args;
55 static std::vector<std::string> AVAILABLE_ARGS = {
"-testdatadir"};
56 for (
const std::string& arg_name : AVAILABLE_ARGS) {
57 auto op_arg = argsman.
GetArg(arg_name);
58 if (op_arg)
args.emplace_back(
strprintf(
"%s=%s", arg_name, *op_arg));
63int main(
int argc,
char** argv)
70 tfm::format(std::cerr,
"Error parsing command line arguments: %s\n", error);
75 std::cout <<
"Usage: bench_bitcoin [options]\n"
80 " bench_bitcoin executes microbenchmarks. The quality of the benchmark results\n"
81 " highly depend on the stability of the machine. It can sometimes be difficult\n"
82 " to get stable, repeatable results, so here are a few tips:\n"
84 " * Use pyperf [1] to disable frequency scaling, turbo boost etc. For best\n"
85 " results, use CPU pinning and CPU isolation (see [2]).\n"
87 " * Each call of run() should do exactly the same work. E.g. inserting into\n"
88 " a std::vector doesn't do that as it will reallocate on certain calls. Make\n"
89 " sure each run has exactly the same preconditions.\n"
91 " * If results are still not reliable, increase runtime with e.g.\n"
92 " -min-time=5000 to let a benchmark run for at least 5 seconds.\n"
94 " * bench_bitcoin uses nanobench [3] for which there is extensive\n"
95 " documentation available online.\n"
97 "Environment Variables:\n"
99 " To attach a profiler you can run a benchmark in endless mode. This can be\n"
100 " done with the environment variable NANOBENCH_ENDLESS. E.g. like so:\n"
102 " NANOBENCH_ENDLESS=MuHash ./bench_bitcoin -filter=MuHash\n"
104 " In rare cases it can be useful to suppress stability warnings. This can be\n"
105 " done with the environment variable NANOBENCH_SUPPRESS_WARNINGS, e.g:\n"
107 " NANOBENCH_SUPPRESS_WARNINGS=1 ./bench_bitcoin\n"
112 " https://github.com/psf/pyperf\n"
114 " 2. CPU pinning & isolation\n"
115 " https://pyperf.readthedocs.io/en/latest/system.html\n"
118 " https://github.com/martinus/nanobench\n"
138 }
catch (
const std::exception& e) {
bool HelpRequested(const ArgsManager &args)
void SetupHelpOptions(ArgsManager &args)
Add help options to the args manager.
static constexpr int64_t DEFAULT_MIN_TIME_MS
static std::vector< std::string > parseTestSetupArgs(const ArgsManager &argsman)
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
disallow -nofoo syntax
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)
void SetupCommonTestArgs(ArgsManager &argsman)
Register common test args.
std::string SHA256AutoDetect(sha256_implementation::UseImplementation use_implementation)
Autodetect the best available SHA256 implementation.