Add memleak plot script.

This commit is contained in:
tastytea 2021-12-05 10:00:20 +01:00
commit 230e4db3b6
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,59 @@
#!/usr/bin/env -S gnuplot --persist -c
# Gnuplot script for data generated with:
# smem -P '^myprogram' -t | tail -n1 \
# | awk '{print "USS:", $4; print "PSS:",$5; print "RSS:",$6;}' \
# | sed "s/:/ $(date --iso-8601=minutes)/" >> mem-myprogram.data
# Example usage: ./memory-consumption-over-time.gp myprogram 2021-12-05T08:42
if (ARGC > 0) {
myprog = ARG1
} else {
myprog='unknown'
}
infile=sprintf('mem-%s.data', myprog)
mytimefmt = "%Y-%m-%dT%H:%M"
if (ARGC > 1) {
mystarttime = strptime(mytimefmt, ARG2)
} else {
mystarttime = strptime(mytimefmt, "1970-01-01T00:00")
}
set title sprintf('%s memory consumption over time', myprog)
set key left top
set xlabel 'Time (Hours)'
set ylabel 'MiB (USS \& PSS)'
set y2label 'MiB (RSS)' textcolor 'dark-orange'
set xdata time
set timefmt mytimefmt
set xtics timedate
set xtics format "%tH"
set xtics 21600 # 1 tic every 6 hours.
set mxtics 6 # 1 mtic every hour.
set ytics 5 nomirror # 1 tic every 5 MiB.
set mytics 5
set y2tics 5 nomirror textcolor 'dark-orange'
set my2tics 5
set grid xtics ytics mxtics mytics lc "gray50",lc "gray"
myfont = "Source Sans Pro,12"
# set terminal qt enhanced font myfont
# set terminal svg enhanced background rgb 'white' size 1200,900 dynamic font myfont
# set output sprintf("%s memory consumption over time.png", myprog)
set terminal png enhanced notransparent size 1200,900 font myfont
set output sprintf("%s memory consumption over time.png", myprog)
plot infile every 3::0 using ((timecolumn(2) - mystarttime)):($3/1024) title 'USS' \
with linespoints linewidth 2 pointtype 7 pointsize 0.5 linecolor 'dark-violet', \
\
'' every 3::1 using ((timecolumn(2) - mystarttime)):($3/1024) title 'PSS' \
with linespoints linewidth 2 pointtype 7 pointsize 0.5 linecolor 'dark-green', \
\
'' every 3::2 using ((timecolumn(2) - mystarttime)):($3/1024) title 'RSS' \
with linespoints linewidth 2 pointtype 7 pointsize 0.5 linecolor 'dark-orange' axes x1y2
print 'Maximum = ',GPVAL_DATA_Y_MAX