You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -467,3 +467,15 @@ partially-converted asynchronous version of the same name to the `test/asynchron
467
467
Use this generated file as a starting point for the completed conversion.
468
468
469
469
The script is used like so: `python tools/convert_test_to_async.py [test_file.py]`
470
+
471
+
## Generating a flame graph using py-spy
472
+
To profile a test script and generate a flame graph, follow these steps:
473
+
1. Install `py-spy` if you haven't already:
474
+
```bash
475
+
pip install py-spy
476
+
```
477
+
2. Inside your test script, perform any required setup and then loop over the code you want to profile for improved sampling.
478
+
3. Run `py-spy record -o <output.svg> -r <sample_rate=100> -- python <path/to/script>` to generate a `.svg` file containing the flame graph.
479
+
(Note: on macOS you will need to run this command using `sudo` to allow `py-spy` to attach to the Python process.)
480
+
4. If you need to include native code (for example the C extensions), profiling should be done on a Linux system, as macOS and Windows do not support the `--native` option of `py-spy`.
481
+
Creating an ubuntu Evergreen spawn host and using `scp` to copy the flamegraph `.svg` file back to your local machine is the best way to do this.
0 commit comments