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 \
|
2021-12-05 13:49:58 +01:00
|
|
|
# | 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
|
2021-12-05 20:56:09 +01:00
|
|
|
#
|
2021-12-07 17:54:33 +01:00
|
|
|
# Arguments: <program name> <time of first data point> [ytic mode] [mtic mode] [width] [height]
|
2021-12-06 10:53:45 +01:00
|
|
|
# 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.
|
2021-12-07 17:54:33 +01:00
|
|
|
# Argument 4 (mtic mode) means:
|
|
|
|
# - short: 1 tic every 10 minutes.
|
|
|
|
# - default: 1 tic every hour.
|
|
|
|
# - long: 1 tic every 6 hours.
|
2021-12-05 10:00:20 +01:00
|
|
|
# Example usage: ./memory-consumption-over-time.gp myprogram 2021-12-05T08:42
|
|
|
|
|
2021-12-05 20:56:09 +01:00
|
|
|
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) {
|
2021-12-05 10:00:20 +01:00
|
|
|
myprog = ARG1
|
|
|
|
}
|
|
|
|
infile=sprintf('mem-%s.data', myprog)
|
|
|
|
|
|
|
|
mytimefmt = "%Y-%m-%dT%H:%M"
|
2021-12-05 20:56:09 +01:00
|
|
|
mystarttime = strptime(mytimefmt, "1970-01-01T00:00")
|
|
|
|
if (ARGC >= 2) {
|
2021-12-05 10:00:20 +01:00
|
|
|
mystarttime = strptime(mytimefmt, ARG2)
|
2021-12-05 20:56:09 +01:00
|
|
|
}
|
2021-12-05 20:57:02 +01:00
|
|
|
|
2021-12-06 10:53:45 +01:00
|
|
|
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.
|
2021-12-07 17:54:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
set xlabel 'Time (Hours)'
|
|
|
|
set xtics format "%tH"
|
|
|
|
set xtics 3600 # 1 tic every hour.
|
|
|
|
set mxtics 6 # 1 mtic every 10 minutes.
|
|
|
|
if (ARGC >= 4) {
|
|
|
|
if (ARG4 eq "short") {
|
|
|
|
set xlabel 'Time (Minutes)'
|
|
|
|
set xtics format "%tM"
|
|
|
|
set xtics 600 # 1 tic every 10 minutes.
|
|
|
|
set mxtics 10 # 1 tic every minute.
|
|
|
|
}
|
|
|
|
if (ARG4 eq "long") {
|
|
|
|
set xlabel 'Time (Hours)'
|
|
|
|
set xtics format "%tH"
|
|
|
|
set xtics 21600 # 1 tic every 6 hours.
|
|
|
|
set mxtics 6 # 1 mtic every hour.
|
|
|
|
}
|
|
|
|
}
|
2021-12-06 10:53:45 +01:00
|
|
|
|
2021-12-05 20:57:02 +01:00
|
|
|
array mysize[2] = [ 1200, 900 ]
|
2021-12-07 17:54:33 +01:00
|
|
|
if (ARGC >= 6) {
|
|
|
|
array mysize[2] = [ ARG5, ARG6 ]
|
2021-12-05 10:00:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
set title sprintf('%s memory consumption over time', myprog)
|
|
|
|
set key left top
|
2021-12-05 13:49:58 +01:00
|
|
|
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
|
|
|
|
|
2021-12-06 10:53:45 +01:00
|
|
|
set ytics myytics nomirror
|
|
|
|
set mytics mymytics
|
|
|
|
set y2tics myytics nomirror textcolor 'dark-red'
|
|
|
|
set my2tics mymytics
|
2021-12-05 11:54:33 +01:00
|
|
|
set grid xtics ytics mxtics mytics lc "gray50" lw 0.75, lc "gray" lw 0.5
|
2021-12-05 10:00:20 +01:00
|
|
|
|
2021-12-05 13:49:58 +01:00
|
|
|
myfont = "Source Sans Pro,12"
|
2021-12-05 10:00:20 +01:00
|
|
|
|
2021-12-05 20:57:02 +01:00
|
|
|
# set terminal qt enhanced size mysize[1],mysize[2] font myfont
|
2021-12-05 11:54:33 +01:00
|
|
|
|
2021-12-05 20:57:02 +01:00
|
|
|
# set terminal png enhanced notransparent size mysize[1],mysize[2] font myfont
|
2021-12-05 10:00:20 +01:00
|
|
|
# set output sprintf("%s memory consumption over time.png", myprog)
|
2021-12-05 11:54:33 +01:00
|
|
|
|
|
|
|
myfont = "Source Sans Pro,16"
|
2021-12-05 20:57:02 +01:00
|
|
|
set terminal svg enhanced background rgb 'white' size mysize[1],mysize[2] \
|
|
|
|
dynamic font myfont
|
2021-12-05 11:54:33 +01:00
|
|
|
set output sprintf("%s memory consumption over time.svg", myprog)
|
2021-12-05 10:00:20 +01:00
|
|
|
|
2021-12-07 10:54:09 +01:00
|
|
|
set y2range [0:] # Don't go into minus if Swap is 0 the whole time.
|
|
|
|
|
2021-12-05 13:49:58 +01:00
|
|
|
plot infile every 4::0 using ((timecolumn(2) - mystarttime)):($3/1024) title 'USS' \
|
2021-12-05 18:03:09 +01:00
|
|
|
with linespoints linewidth 3 pointtype 7 pointsize 0.5, \
|
2021-12-05 10:00:20 +01:00
|
|
|
\
|
2021-12-05 13:49:58 +01:00
|
|
|
'' every 4::1 using ((timecolumn(2) - mystarttime)):($3/1024) title 'PSS' \
|
2021-12-05 18:03:09 +01:00
|
|
|
with linespoints linewidth 2 pointtype 7 pointsize 0.5, \
|
2021-12-05 10:00:20 +01:00
|
|
|
\
|
2021-12-05 13:49:58 +01:00
|
|
|
'' every 4::2 using ((timecolumn(2) - mystarttime)):($3/1024) title 'RSS' \
|
2021-12-05 18:03:09 +01:00
|
|
|
with linespoints linewidth 2 pointtype 7 pointsize 0.5, \
|
2021-12-05 13:49:58 +01:00
|
|
|
\
|
|
|
|
'' 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
|