File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -460,3 +460,17 @@ partially-converted asynchronous version of the same name to the `test/asynchron
460
460
Use this generated file as a starting point for the completed conversion.
461
461
462
462
The script is used like so: ` python tools/convert_test_to_async.py [test_file.py] `
463
+
464
+ ## Generating a flame graph using py-spy
465
+ To profile a test script and generate a flame graph, follow these steps:
466
+ 1 . Install ` py-spy ` if you haven't already:
467
+ ``` bash
468
+ pip install py-spy
469
+ ```
470
+ 2 . Inside your test script, perform any required setup and then loop over the code you want to profile for improved sampling
471
+ 3 . Run the ` flamegraph ` justfile target to generate a ` .svg ` file containing the flame graph:
472
+ ``` bash
473
+ just flamegraph < output_name=profile> < sample_rate=2000> < path/to/script>
474
+ ```
475
+ 4 . Profiling should be done on a Linux system, as macOS and Windows do not support the ` --native ` option of ` py-spy ` .
476
+ 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.
Original file line number Diff line number Diff line change @@ -68,6 +68,9 @@ setup-tests *args="":
68
68
teardown-tests :
69
69
bash .evergreen/ scripts/ teardown-tests.sh
70
70
71
+ flamegraph * args :
72
+ bash tools/ generate_flamegraph.sh {{ args}}
73
+
71
74
[group (' server' )]
72
75
run-server * args = " ":
73
76
bash .evergreen/ scripts/ run-server.sh {{ args}}
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ set -eu
3
+
4
+ sudo py-spy record -o ${1:- profile} .svg -r ${2:- 2000} -- python $3
You can’t perform that action at this time.
0 commit comments