93 lines
3.2 KiB
Gnuplot
Executable File
93 lines
3.2 KiB
Gnuplot
Executable File
#!/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;}' \
|
|
# | sed "s/:/ $(date --iso-8601=minutes)/" >> mem-myprogram.data
|
|
#
|
|
# Arguments: <program name> <time of first data point> [ytic mode] [width] [height]
|
|
# Argument 3 (ytic mode) means:
|
|
# - default: 1 tic every 10 MiB, 1 mtic every 5 MiB.
|
|
# - big: 1 tic every 100 MiB, 1 mtic every 10 MiB.
|
|
# - verybig: 1 tic every 1000 MiB, 1 mtic every 100 MiB.
|
|
# Example usage: ./memory-consumption-over-time.gp myprogram 2021-12-05T08:42
|
|
|
|
if (ARGC < 2) {
|
|
printerr "You probably want to supply the program name ", \
|
|
"and the time of first data point. ", \
|
|
"See the header of this script for more information."
|
|
}
|
|
|
|
myprog='unknown'
|
|
if (ARGC >= 1) {
|
|
myprog = ARG1
|
|
}
|
|
infile=sprintf('mem-%s.data', myprog)
|
|
|
|
mytimefmt = "%Y-%m-%dT%H:%M"
|
|
mystarttime = strptime(mytimefmt, "1970-01-01T00:00")
|
|
if (ARGC >= 2) {
|
|
mystarttime = strptime(mytimefmt, ARG2)
|
|
}
|
|
|
|
myytics = 10 # 1 tic every 10 MiB.
|
|
mymytics = 2 # 1 mtic every 5 MiB.
|
|
if (ARGC >= 3) {
|
|
if (ARG3 eq "big") {
|
|
myytics = 100 # 1 tic every 100 MiB.
|
|
mymytics = 10 # 1 mtic every 10 MiB.
|
|
}
|
|
if (ARG3 eq "verybig") {
|
|
myytics = 1000 # 1 tic every 1000 MiB.
|
|
mymytics = 10 # 1 mtic every 10 MiB.
|
|
}}
|
|
|
|
array mysize[2] = [ 1200, 900 ]
|
|
if (ARGC >= 5) {
|
|
array mysize[2] = [ ARG4, ARG5 ]
|
|
}
|
|
|
|
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'
|
|
|
|
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 myytics nomirror
|
|
set mytics mymytics
|
|
set y2tics myytics nomirror textcolor 'dark-red'
|
|
set my2tics mymytics
|
|
set grid xtics ytics mxtics mytics lc "gray50" lw 0.75, lc "gray" lw 0.5
|
|
|
|
myfont = "Source Sans Pro,12"
|
|
|
|
# set terminal qt enhanced size mysize[1],mysize[2] font myfont
|
|
|
|
# set terminal png enhanced notransparent size mysize[1],mysize[2] font myfont
|
|
# set output sprintf("%s memory consumption over time.png", myprog)
|
|
|
|
myfont = "Source Sans Pro,16"
|
|
set terminal svg enhanced background rgb 'white' size mysize[1],mysize[2] \
|
|
dynamic font myfont
|
|
set output sprintf("%s memory consumption over time.svg", myprog)
|
|
|
|
set y2range [0:] # Don't go into minus if Swap is 0 the whole time.
|
|
|
|
plot infile every 4::0 using ((timecolumn(2) - mystarttime)):($3/1024) title 'USS' \
|
|
with linespoints linewidth 3 pointtype 7 pointsize 0.5, \
|
|
\
|
|
'' every 4::1 using ((timecolumn(2) - mystarttime)):($3/1024) title 'PSS' \
|
|
with linespoints linewidth 2 pointtype 7 pointsize 0.5, \
|
|
\
|
|
'' every 4::2 using ((timecolumn(2) - mystarttime)):($3/1024) title 'RSS' \
|
|
with linespoints linewidth 2 pointtype 7 pointsize 0.5, \
|
|
\
|
|
'' 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
|