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.
This commit is contained in:
James O'Beirne
2018-10-19 12:28:47 -04:00
parent df894fa69a
commit 58180b5fd4
5 changed files with 165 additions and 4 deletions

View File

@@ -176,6 +176,26 @@ gdb /home/example/bitcoind <pid>
Note: gdb attach step may require `sudo`
##### Profiling
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).
To generate a profile during test suite runs, use the `--perf` flag.
To see render the output to text, run
```sh
perf report -i /path/to/datadir/send-big-msgs.perf.data.xxxx --stdio | c++filt | less
```
For ways to generate more granular profiles, see the README in
[test/functional](/test/functional).
### Util tests
Util tests can be run locally by running `test/util/bitcoin-util-test.py`.