aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2021-07-05 08:47:10 +0800
committerfanquake <fanquake@gmail.com>2021-07-05 08:47:36 +0800
commitc609e10545492aba480ff17aff7eefc13a0b5cd8 (patch)
tree21640a6539178aa1234483e9f75b458b042af881 /src
parent7a49fdc58115845ece3a9890bf9498bee6b559de (diff)
parentd8513fe41102dcbfc05235f3b95e33eb1878f880 (diff)
downloadbitcoin-c609e10545492aba480ff17aff7eefc13a0b5cd8.tar.xz
Merge bitcoin/bitcoin#22292: bench, doc: benchmarking updates and fixups
d8513fe41102dcbfc05235f3b95e33eb1878f880 doc: update doc/benchmarking.md (Jon Atack) 84e2d5b78181d08b258c77f9c9c4e1bb7fdaa451 bench: bench_bitcoin.cpp help fixups (Jon Atack) 10f4ce20783cbbcb0c0997c605452d9e60827e6d bench: bench.h fixes and improvements (Jon Atack) Pull request description: Fixups and updates I noticed while writing benchmarks for #22284. ACKs for top commit: za-kk: ACK d8513fe41102dcbfc05235f3b95e33eb1878f880 theStack: ACK d8513fe41102dcbfc05235f3b95e33eb1878f880 🚤 Tree-SHA512: d494956b5d6a3329e98e8b6f4405a10613b8fce51a04bbf4493d8b3497b8d5b177c1a9a3eeb828796eb4edb92b0ace769595151e223671c0dc8f09bcf631ebb5
Diffstat (limited to 'src')
-rw-r--r--src/bench/bench.h18
-rw-r--r--src/bench/bench_bitcoin.cpp8
2 files changed, 15 insertions, 11 deletions
diff --git a/src/bench/bench.h b/src/bench/bench.h
index 22f06d8cb8..c4fcd80e33 100644
--- a/src/bench/bench.h
+++ b/src/bench/bench.h
@@ -18,16 +18,19 @@
/*
* Usage:
-static void CODE_TO_TIME(benchmark::Bench& bench)
+static void NameOfYourBenchmarkFunction(benchmark::Bench& bench)
{
- ... do any setup needed...
- nanobench::Config().run([&] {
- ... do stuff you want to time...
+ ...do any setup needed...
+
+ bench.run([&] {
+ ...do stuff you want to time; refer to src/bench/nanobench.h
+ for more information and the options that can be passed here...
});
- ... do any cleanup needed...
+
+ ...do any cleanup needed...
}
-BENCHMARK(CODE_TO_TIME);
+BENCHMARK(NameOfYourBenchmarkFunction);
*/
@@ -55,7 +58,8 @@ public:
static void RunAll(const Args& args);
};
-}
+} // namespace benchmark
+
// BENCHMARK(foo) expands to: benchmark::BenchRunner bench_11foo("foo", foo);
#define BENCHMARK(n) \
benchmark::BenchRunner PASTE2(bench_, PASTE2(__LINE__, n))(STRINGIZE(n), n);
diff --git a/src/bench/bench_bitcoin.cpp b/src/bench/bench_bitcoin.cpp
index 135659f87f..aab777cac1 100644
--- a/src/bench/bench_bitcoin.cpp
+++ b/src/bench/bench_bitcoin.cpp
@@ -16,11 +16,11 @@ static void SetupBenchArgs(ArgsManager& argsman)
{
SetupHelpOptions(argsman);
- argsman.AddArg("-list", "List benchmarks without executing them", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
+ argsman.AddArg("-asymptote=n1,n2,n3,...", "Test asymptotic growth of the runtime of an algorithm, if supported by the benchmark", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-filter=<regex>", strprintf("Regular expression filter to select benchmark by name (default: %s)", DEFAULT_BENCH_FILTER), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
- argsman.AddArg("-asymptote=n1,n2,n3,...", strprintf("Test asymptotic growth of the runtime of an algorithm, if supported by the benchmark"), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
- argsman.AddArg("-output_csv=<output.csv>", "Generate CSV file with the most important benchmark results.", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
- argsman.AddArg("-output_json=<output.json>", "Generate JSON file with all benchmark results.", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
+ argsman.AddArg("-list", "List benchmarks without executing them", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
+ argsman.AddArg("-output_csv=<output.csv>", "Generate CSV file with the most important benchmark results", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
+ argsman.AddArg("-output_json=<output.json>", "Generate JSON file with all benchmark results", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
}
// parses a comma separated list like "10,20,30,50"