aboutsummaryrefslogtreecommitdiff
path: root/test/functional/README.md
diff options
context:
space:
mode:
authorJames O'Beirne <james.obeirne@gmail.com>2018-10-19 12:28:47 -0400
committerJames O'Beirne <james.obeirne@gmail.com>2019-01-22 08:55:55 -0500
commit58180b5fd467ff15e7170145d77c84f13ccafe6e (patch)
tree5a7be4313cd7dd4e15f9666cf702235c2962ce5b /test/functional/README.md
parentdf894fa69a09ff2b7f00af0cf220e5132a69c70a (diff)
downloadbitcoin-58180b5fd467ff15e7170145d77c84f13ccafe6e.tar.xz
tests: add utility to easily profile node performance with perf
Introduces `TestNode.profile_with_perf()` context manager which samples node execution to produce profiling data. Also introduces a test framework flag, `--perf`, which will run perf on all nodes for the duration of a given test.
Diffstat (limited to 'test/functional/README.md')
-rw-r--r--test/functional/README.md33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/functional/README.md b/test/functional/README.md
index d40052ac93..711151d606 100644
--- a/test/functional/README.md
+++ b/test/functional/README.md
@@ -118,3 +118,36 @@ Helpers for script.py
#### [test_framework/blocktools.py](test_framework/blocktools.py)
Helper functions for creating blocks and transactions.
+
+### Benchmarking with perf
+
+An easy way to profile node performance during functional tests is provided
+for Linux platforms using `perf`.
+
+Perf will sample the running node and will generate profile data in the node's
+datadir. The profile data can then be presented using `perf report` or a graphical
+tool like [hotspot](https://github.com/KDAB/hotspot).
+
+There are two ways of invoking perf: one is to use the `--perf` flag when
+running tests, which will profile each node during the entire test run: perf
+begins to profile when the node starts and ends when it shuts down. The other
+way is the use the `profile_with_perf` context manager, e.g.
+
+```python
+with node.profile_with_perf("send-big-msgs"):
+ # Perform activity on the node you're interested in profiling, e.g.:
+ for _ in range(10000):
+ node.p2p.send_message(some_large_message)
+```
+
+To see useful textual output, run
+
+```sh
+perf report -i /path/to/datadir/send-big-msgs.perf.data.xxxx --stdio | c++filt | less
+```
+
+#### See also:
+
+- [Installing perf](https://askubuntu.com/q/50145)
+- [Perf examples](http://www.brendangregg.com/perf.html)
+- [Hotspot](https://github.com/KDAB/hotspot): a GUI for perf output analysis