INF205/lab_2/10_memleak/plot.py

35 lines
743 B
Python
Raw Normal View History

2024-02-27 17:37:22 +00:00
import matplotlib.pyplot as plt
import matplotlib.cbook as cbook
import numpy as np
import pandas as pd
f = open('const_m_timings.csv', 'r')
x1 = []
y1 = []
for l in f.readlines():
l = l.split(',')
x1.append(l[0])
y1.append(float(l[1]))
f = open('const_Nm_timings.csv', 'r')
x2 = []
y2 = []
for l in f.readlines():
l = l.split(',')
x2.append(l[0])
y2.append(float(l[1]))
plt.plot(x1, y1, label = 'constant m')
plt.plot(x2, y2, label = 'constant Nm')
for i in range(len(x1)):
plt.text(i,y1[i],str(y1[i])+'s')
for i in range(len(x2)):
plt.text(i,y2[i],str(y2[i])+'s')
plt.title('runtime t as a function of number of steps N')
plt.xlabel('N')
plt.ylabel('time (s)')
plt.grid()
plt.legend()
plt.show()