import matplotlib.pyplot as plt
import matplotlib.cbook as cbook

import numpy as np
import pandas as pd

f1 = open('const_m_timings.csv', 'r')
f2 = open('../11/const_m_timings.csv', 'r')
x1 = []
y1 = []
for l,p in zip(f1.readlines(), f2.readlines()):
    l = l.split(',')
    p = p.split(',')
    x1.append(p[0])
    y1.append(float(p[1])/float(l[1]))

f1 = open('const_Nm_timings.csv', 'r')
f2 = open('../11/const_Nm_timings.csv', 'r')
x2 = []
y2 = []
for l,p in zip(f1.readlines(), f2.readlines()):
    l = l.split(',')
    p = p.split(',')
    x2.append(p[0])
    y2.append(float(p[1])/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],f'{y1[i]:.2f}', color="blue")
for i in range(len(x2)):
        plt.text(i,y2[i],f'{y2[i]:.2f}', color="orange")
plt.title('Speedup after optimization')
plt.xlabel('N')
plt.ylabel('xspeedup')
plt.grid()
plt.legend()
plt.show()
