aboutsummaryrefslogtreecommitdiff
path: root/src/bench/bench_bitcoin.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-12-23 14:46:20 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2017-12-23 14:53:05 +0100
commit5180a86c96bc05d2a731f70f36aae28ab5a3fad4 (patch)
tree2339b7b14ec174861d1baa73a44a33680644f820 /src/bench/bench_bitcoin.cpp
parent20166f8a448156f476f3e23825f59ebec36424a9 (diff)
parent760af84072408ba53d009e868fccc25fb186d40c (diff)
downloadbitcoin-5180a86c96bc05d2a731f70f36aae28ab5a3fad4.tar.xz
Merge #11517: Tests: Improve benchmark precision
760af84 Removed CCheckQueueSpeed benchmark (Martin Ankerl) 00721e6 Improved microbenchmarking with multiple features. (Martin Ankerl) Pull request description: The benchmark's KeepRunning() used to make a function call for each call, inflating measurement times for short running code. This change inlines the critical code that is executed each run and moves the slow timer updates into a new function. This change increases the average runtime for Trig from 0.000000082339208 sec to 0.000000080948591. Tree-SHA512: 36b3bc55fc9b1d4cbf526b7103af6af18e9783e6b8f3ad3adbd09fac0bf9401cfefad58fd1e6fa2615d3c4e677998f912f3323d61d7b00b1c660d581c257d577
Diffstat (limited to 'src/bench/bench_bitcoin.cpp')
-rw-r--r--src/bench/bench_bitcoin.cpp48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/bench/bench_bitcoin.cpp b/src/bench/bench_bitcoin.cpp
index 84e51d809a..5e0432f0ee 100644
--- a/src/bench/bench_bitcoin.cpp
+++ b/src/bench/bench_bitcoin.cpp
@@ -10,16 +10,62 @@
#include <util.h>
#include <random.h>
+#include <boost/lexical_cast.hpp>
+
+#include <memory>
+
+static const int64_t DEFAULT_BENCH_EVALUATIONS = 5;
+static const char* DEFAULT_BENCH_FILTER = ".*";
+static const char* DEFAULT_BENCH_SCALING = "1.0";
+static const char* DEFAULT_BENCH_PRINTER = "console";
+static const char* DEFAULT_PLOT_PLOTLYURL = "https://cdn.plot.ly/plotly-latest.min.js";
+static const int64_t DEFAULT_PLOT_WIDTH = 1024;
+static const int64_t DEFAULT_PLOT_HEIGHT = 768;
+
int
main(int argc, char** argv)
{
+ gArgs.ParseParameters(argc, argv);
+
+ if (gArgs.IsArgSet("-?") || gArgs.IsArgSet("-h") || gArgs.IsArgSet("-help")) {
+ std::cout << HelpMessageGroup(_("Options:"))
+ << HelpMessageOpt("-?", _("Print this help message and exit"))
+ << HelpMessageOpt("-list", _("List benchmarks without executing them. Can be combined with -scaling and -filter"))
+ << HelpMessageOpt("-evals=<n>", strprintf(_("Number of measurement evaluations to perform. (default: %u)"), DEFAULT_BENCH_EVALUATIONS))
+ << HelpMessageOpt("-filter=<regex>", strprintf(_("Regular expression filter to select benchmark by name (default: %s)"), DEFAULT_BENCH_FILTER))
+ << HelpMessageOpt("-scaling=<n>", strprintf(_("Scaling factor for benchmark's runtime (default: %u)"), DEFAULT_BENCH_SCALING))
+ << HelpMessageOpt("-printer=(console|plot)", strprintf(_("Choose printer format. console: print data to console. plot: Print results as HTML graph (default: %s)"), DEFAULT_BENCH_PRINTER))
+ << HelpMessageOpt("-plot-plotlyurl=<uri>", strprintf(_("URL to use for plotly.js (default: %s)"), DEFAULT_PLOT_PLOTLYURL))
+ << HelpMessageOpt("-plot-width=<x>", strprintf(_("Plot width in pixel (default: %u)"), DEFAULT_PLOT_WIDTH))
+ << HelpMessageOpt("-plot-height=<x>", strprintf(_("Plot height in pixel (default: %u)"), DEFAULT_PLOT_HEIGHT));
+
+ return 0;
+ }
+
SHA256AutoDetect();
RandomInit();
ECC_Start();
SetupEnvironment();
fPrintToDebugLog = false; // don't want to write to debug.log file
- benchmark::BenchRunner::RunAll();
+ int64_t evaluations = gArgs.GetArg("-evals", DEFAULT_BENCH_EVALUATIONS);
+ std::string regex_filter = gArgs.GetArg("-filter", DEFAULT_BENCH_FILTER);
+ std::string scaling_str = gArgs.GetArg("-scaling", DEFAULT_BENCH_SCALING);
+ bool is_list_only = gArgs.GetBoolArg("-list", false);
+
+ double scaling_factor = boost::lexical_cast<double>(scaling_str);
+
+
+ std::unique_ptr<benchmark::Printer> printer(new benchmark::ConsolePrinter());
+ std::string printer_arg = gArgs.GetArg("-printer", DEFAULT_BENCH_PRINTER);
+ if ("plot" == printer_arg) {
+ printer.reset(new benchmark::PlotlyPrinter(
+ gArgs.GetArg("-plot-plotlyurl", DEFAULT_PLOT_PLOTLYURL),
+ gArgs.GetArg("-plot-width", DEFAULT_PLOT_WIDTH),
+ gArgs.GetArg("-plot-height", DEFAULT_PLOT_HEIGHT)));
+ }
+
+ benchmark::BenchRunner::RunAll(*printer, evaluations, scaling_factor, regex_filter, is_list_only);
ECC_Stop();
}