Created
May 12, 2022 19:43
-
-
Save kirbysayshi/04f9dd0432e7d062fbdaa184d61be6d5 to your computer and use it in GitHub Desktop.
process profiling with graphs (bash, gnuplot)
This file contains 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
for log in *-anary.log; do awk '$0<200' <$log | gnuplot -e "set term png; set yrange [0:200]; unset autoscale y; set output \"$(basename $log .log).trimmed.png\";plot '-' with boxes"; done |
This file contains 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
pattern=anary; | |
end=$((SECONDS+60)); | |
prefix=$(date +%s) | |
LOGFILE="$prefix-$pattern.log" | |
: > $LOGFILE # truncate | |
while [ $SECONDS -lt $end ]; do | |
for pid in $(pgrep -f $pattern); do | |
ps -p $pid -o %cpu= ; | |
done | perl -nle '$sum += $_ } END { print $sum' >> $LOGFILE; | |
sleep 0.5; | |
done; | |
gnuplot<<<"set term png;set output \"$prefix-$pattern.png\";plot \"$LOGFILE\" with boxes" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example of the raw image:
Example of "cleaned file":