Skip to content

Commit 1f10f16

Browse files
committed
bench: add usage description and documentation
This adds some usage description with tips to `bench_bitcoin -h`.
1 parent d3c6f8b commit 1f10f16

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

src/bench/bench_bitcoin.cpp

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <bench/bench.h>
66

7+
#include <clientversion.h>
78
#include <crypto/sha256.h>
89
#include <util/strencodings.h>
910
#include <util/system.h>
@@ -50,7 +51,51 @@ int main(int argc, char** argv)
5051
}
5152

5253
if (HelpRequested(argsman)) {
53-
std::cout << argsman.GetHelpMessage();
54+
std::cout << "Usage: bench_bitcoin [options]\n"
55+
"\n"
56+
<< argsman.GetHelpMessage()
57+
<< "Description:\n"
58+
"\n"
59+
" bench_bitcoin executes microbenchmarks. The quality of the benchmark results\n"
60+
" highly depend on the stability of the machine. It can sometimes be difficult\n"
61+
" to get stable, repeatable results, so here are a few tips:\n"
62+
"\n"
63+
" * Use pyperf [1] to disable frequency scaling, turbo boost etc. For best\n"
64+
" results, use CPU pinning and CPU isolation (see [2]).\n"
65+
"\n"
66+
" * Each call of run() should do exactly the same work. E.g. inserting into\n"
67+
" a std::vector doesn't do that as it will reallocate on certain calls. Make\n"
68+
" sure each run has exactly the same preconditions.\n"
69+
"\n"
70+
" * If results are still not reliable, increase runtime with e.g.\n"
71+
" -min_time=5000 to let a benchmark run for at least 5 seconds.\n"
72+
"\n"
73+
" * bench_bitcoin uses nanobench [3] for which there is extensive\n"
74+
" documentation available online.\n"
75+
"\n"
76+
"Environment Variables:\n"
77+
"\n"
78+
" To attach a profiler you can run a benchmark in endless mode. This can be\n"
79+
" done with the environment variable NANOBENCH_ENDLESS. E.g. like so:\n"
80+
"\n"
81+
" NANOBENCH_ENDLESS=MuHash ./bench_bitcoin -filter=MuHash\n"
82+
"\n"
83+
" In rare cases it can be useful to suppress stability warnings. This can be\n"
84+
" done with the environment variable NANOBENCH_SUPPRESS_WARNINGS, e.g:\n"
85+
"\n"
86+
" NANOBENCH_SUPPRESS_WARNINGS=1 ./bench_bitcoin\n"
87+
"\n"
88+
"Notes:\n"
89+
"\n"
90+
" 1. pyperf\n"
91+
" https://github.com/psf/pyperf\n"
92+
"\n"
93+
" 2. CPU pinning & isolation\n"
94+
" https://pyperf.readthedocs.io/en/latest/system.html\n"
95+
"\n"
96+
" 3. nanobench\n"
97+
" https://github.com/martinus/nanobench\n"
98+
"\n";
5499

55100
return EXIT_SUCCESS;
56101
}

0 commit comments

Comments
 (0)