12 #include <validation.h> 18 static const int64_t DEFAULT_BENCH_EVALUATIONS = 5;
19 static const char* DEFAULT_BENCH_FILTER =
".*";
20 static const char* DEFAULT_BENCH_SCALING =
"1.0";
21 static const char* DEFAULT_BENCH_PRINTER =
"console";
22 static const char* DEFAULT_PLOT_PLOTLYURL =
"https://cdn.plot.ly/plotly-latest.min.js";
23 static const int64_t DEFAULT_PLOT_WIDTH = 1024;
24 static const int64_t DEFAULT_PLOT_HEIGHT = 768;
26 static void SetupBenchArgs()
43 static fs::path SetDataDir()
45 fs::path
ret = fs::temp_directory_path() /
"bench_bitcoin" / fs::unique_path();
46 fs::create_directories(
ret);
51 int main(
int argc,
char** argv)
56 fprintf(stderr,
"Error parsing command line arguments: %s\n",
error.c_str());
67 const fs::path bench_datadir{SetDataDir()};
74 int64_t evaluations =
gArgs.
GetArg(
"-evals", DEFAULT_BENCH_EVALUATIONS);
75 std::string regex_filter =
gArgs.
GetArg(
"-filter", DEFAULT_BENCH_FILTER);
76 std::string scaling_str =
gArgs.
GetArg(
"-scaling", DEFAULT_BENCH_SCALING);
79 double scaling_factor;
81 fprintf(stderr,
"Error parsing scaling factor as double: %s\n", scaling_str.c_str());
85 std::unique_ptr<benchmark::Printer> printer = MakeUnique<benchmark::ConsolePrinter>();
86 std::string printer_arg =
gArgs.
GetArg(
"-printer", DEFAULT_BENCH_PRINTER);
87 if (
"plot" == printer_arg) {
89 gArgs.
GetArg(
"-plot-plotlyurl", DEFAULT_PLOT_PLOTLYURL),
91 gArgs.
GetArg(
"-plot-height", DEFAULT_PLOT_HEIGHT)));
96 fs::remove_all(bench_datadir);
void RandomInit()
Initialize the RNG.
bool HelpRequested(const ArgsManager &args)
void ECC_Start()
Initialize the elliptic curve support.
UniValue ret(UniValue::VARR)
const std::function< std::string(const char *)> G_TRANSLATION_FUN
Translate a message to the native language of the user.
bool ParseParameters(int argc, const char *const argv[], std::string &error)
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
std::string SHA256AutoDetect()
Autodetect the best available SHA256 implementation.
void ForceSetArg(const std::string &strArg, const std::string &strValue)
bool ParseDouble(const std::string &str, double *out)
Convert string to double with strict parse error feedback.
std::string GetHelpMessage() const
Get the help string.
void ECC_Stop()
Deinitialize the elliptic curve support.
static void RunAll(Printer &printer, uint64_t num_evals, double scaling, const std::string &filter, bool is_list_only)
void AddArg(const std::string &name, const std::string &help, const bool debug_only, const OptionsCategory &cat)
Add argument.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
int main(int argc, char **argv)
bool error(const char *fmt, const Args &... args)