You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.7 KiB
Python

import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
import numpy as np
Y_MEM = [37, 3365, 6693, 10021, 13349, 16677, 20005, 23333, 26661]
Y_CPY = [36, 4004, 7972, 11940, 15908, 19876, 23844, 27812, 31780]
YA_MEM = [28, 1788, 3585, 5298, 7028, 9174, 10515, 12258, 14003]
YA_CPY = [31, 2477 , 4909 , 7372, 9802, 12217 , 15049, 17081, 19514]
X = [0, 128, 256, 384, 512, 640, 768, 896, 1024]
plt.scatter(X, Y_MEM, color="b", label="RISCV MEM")
plt.scatter(X, Y_CPY, color="b", marker="x", label="RISCV COPY")
plt.scatter(X, YA_MEM, color="r", label="ARM MEM")
plt.scatter(X, YA_CPY, color="r",marker="x", label="ARM COPY")
x = np.array(X).reshape(-1, 1)
y = np.array(Y_MEM).reshape(-1, 1)
y2 = np.array(YA_MEM).reshape(-1, 1)
reg = LinearRegression().fit(x, y)
reg2 = LinearRegression().fit(x, y2)
print("score obtenu : " + str(reg.score(x, y)))
print("score obtenu : " + str(reg2.score(x, y2)))
print("attente à zéro : {}".format(reg.intercept_))
print("attente à zéro : {}".format(reg2.intercept_))
x_lin = [0, max(X)]
y_lin = [reg.predict(np.array([0]).reshape(-1, 1)), reg.predict(np.array([x_lin[1]]).reshape(-1, 1))]
y_lin2 = [reg2.predict(np.array([0]).reshape(-1, 1)), reg2.predict(np.array([x_lin[1]]).reshape(-1, 1))]
y_lin = [y_lin[0][0][0], y_lin[1][0][0]]
y_lin2 = [y_lin2[0][0][0], y_lin2[1][0][0]]
plt.plot(x_lin, y_lin, color = "b", label="RegLin score : {:.4f}".format(reg.score(x, y)))
plt.plot(x_lin, y_lin2, color = "r", label="RegLin score : {:.4f}".format(reg2.score(x, y2)))
plt.xlim([0, 1024])
plt.ylim([50, 32000])
plt.legend()
plt.title("Cycles d'exécution en fonction de n_max")
plt.ylabel("Cycles")
plt.xlabel("N_max")
plt.savefig("memory_cycles.png")
plt.show()