Created
August 1, 2024 04:39
-
-
Save smiley-yoyo/9bdcd48754f79dc405edebfea8dc0c86 to your computer and use it in GitHub Desktop.
using py-spy record top cpu usage python program
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| output=$1 | |
| if [ -z "$output" ]; then | |
| output="profile.svg" | |
| fi | |
| # assume that the top usage program is python program, or you can customize the top command | |
| # using head/tail to get the top 1 line (the first 8 are headers) | |
| topid=`top -b -n 1| head -n 8 |tail -n 1|awk '{print $1}'` | |
| echo "top pid: $topid, recording..." | |
| py-spy record -o $output --pid $topid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment