gnuplot-scripts/memleak/memory-consumption-over-tim...

66 lines
2.3 KiB
Plaintext
Raw Normal View History

2021-12-05 10:00:20 +01:00
#!/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; print "SWP:",$3;}' \
2021-12-05 10:00:20 +01:00
# | 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, RSS)'
set y2label 'MiB (Swap)' textcolor 'dark-red'
2021-12-05 10:00:20 +01:00
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.
2021-12-05 11:28:47 +01:00
set ytics 10 nomirror # 1 tic every 10 MiB.
set mytics 2 # 1 mtic every 5 MiB.
set y2tics 10 nomirror textcolor 'dark-red'
2021-12-05 11:28:47 +01:00
set my2tics 2
set grid xtics ytics mxtics mytics lc "gray50" lw 0.75, lc "gray" lw 0.5
2021-12-05 10:00:20 +01:00
myfont = "Source Sans Pro,12"
2021-12-05 10:00:20 +01:00
# set terminal qt enhanced size 1200,900 font myfont
# set terminal png enhanced notransparent size 1200,900 font myfont
2021-12-05 10:00:20 +01:00
# set output sprintf("%s memory consumption over time.png", myprog)
myfont = "Source Sans Pro,16"
set terminal svg enhanced background rgb 'white' size 1200,900 dynamic font myfont
set output sprintf("%s memory consumption over time.svg", myprog)
2021-12-05 10:00:20 +01:00
plot infile every 4::0 using ((timecolumn(2) - mystarttime)):($3/1024) title 'USS' \
2021-12-05 16:07:42 +01:00
with linespoints linewidth 3 pointtype 7 pointsize 0.5 linecolor 'dark-violet', \
2021-12-05 10:00:20 +01:00
\
'' every 4::1 using ((timecolumn(2) - mystarttime)):($3/1024) title 'PSS' \
2021-12-05 10:00:20 +01:00
with linespoints linewidth 2 pointtype 7 pointsize 0.5 linecolor 'dark-green', \
\
'' every 4::2 using ((timecolumn(2) - mystarttime)):($3/1024) title 'RSS' \
with linespoints linewidth 2 pointtype 7 pointsize 0.5 linecolor 'dark-orange', \
\
'' every 4::3 using ((timecolumn(2) - mystarttime)):($3/1024) title 'Swap' \
with linespoints linewidth 2 pointtype 7 pointsize 0.5 linecolor 'dark-red' axes x1y2
2021-12-05 10:00:20 +01:00
print 'Maximum = ',GPVAL_DATA_Y_MAX