import matplotlib.pyplot as plt
%matplotlib inline
# Read captured data
def read_stats(filename):
time = []
vmsize = []
vmpeak = []
vmrss = []
vmhwm = []
lists = (time, vmsize, vmpeak, vmrss, vmhwm)
with open(filename, 'r') as f:
for line in f:
for (l, d) in zip(lists, line.split()):
l.append(float(d))
return lists
def plot_memstats(filename, title):
(time, vmsize, vmpeak, vmrss, vmhwm) = read_stats(filename)
plt.subplot(2,1,1)
plt.plot(time, vmrss)
plt.ylabel('Memory commit (KiB)')
plt.title(title)
plt.subplot(2,1,2)
plt.plot(time, list(map(lambda k: k / 1024, vmsize)))
plt.ylabel('VM size (MiB)')
plt.xlabel('Time (sec)')
plt.show()
plot_memstats('rkos-stats', 'RKOS memory usage')
plot_memstats('rust-stats', 'Hosted memory usage')