M2_SETI/A4/TP_A4/exo2/graph.py
2023-02-12 16:06:32 +01:00

126 lines
No EOL
2.9 KiB
Python

import numpy as np
import re
from matplotlib import pyplot as plt
with open ('time.txt', 'r') as timing:
text = timing.read()
# extract the values using regular expression
values = re.findall(r'\d+\.\d+|\d+', text)
# convert values to int or float
values = [float(value) if '.' in value else int(value) for value in values]
result = np.reshape(values,(35,5))
SEQ = result[0:5,3]
result = np.delete(result, (0,2,3), 1)
T1 = result[0:5,:]
T2 = result[5:10,:]
T4 = result[10:15,:]
T6 = result[15:20,:]
T8 = result[20:25,:]
T10 = result[25:30,:]
T12 = result[30:35,:]
plt.figure()
plt.plot(T1[:,0],SEQ,'+-')
plt.plot(T1[:,0],T1[:,1],'+-')
plt.plot(T2[:,0],T2[:,1],'+-')
plt.plot(T4[:,0],T4[:,1],'+-')
plt.plot(T6[:,0],T6[:,1],'+-')
plt.plot(T8[:,0],T8[:,1],'+-')
plt.plot(T10[:,0],T10[:,1],'+-')
plt.plot(T12[:,0],T12[:,1],'+-')
plt.legend(["Sequentiel","1 Thread","2 Threads","4 Threads","6 Threads","8 Threads","10 Threads","12 Threads"])
plt.xlabel("N")
plt.ylabel("t (s)")
plt.title("Multiplication")
plt.show()
with open ('time_500k.txt', 'r') as timing:
text = timing.read()
# extract the values using regular expression
values = re.findall(r'\d+\.\d+|\d+', text)
# convert values to int or float
values = [float(value) if '.' in value else int(value) for value in values]
result = np.reshape(values,(7,5))
SEQ = result[:,3]*1000
T = result[:,0]
Time = result[:,4]*1000
plt.figure()
plt.plot(T,SEQ,'+-')
plt.plot(T,Time,'+-')
plt.legend(["Sequentiel","OMP"])
plt.xlabel("Threads max")
plt.ylabel("t (ms)")
plt.title("Temps de traitement pour N = 5e5")
plt.show()
with open ('time_maths.txt', 'r') as timing:
text = timing.read()
# extract the values using regular expression
values = re.findall(r'\d+\.\d+|\d+', text)
# convert values to int or float
values = [float(value) if '.' in value else int(value) for value in values]
result = np.reshape(values,(20,5))
SEQ = result[0:5,3]
result = np.delete(result, (0,2,3), 1)
T1 = result[0:5,:]
T2 = result[5:10,:]
T6 = result[10:15,:]
T12 = result[15:20,:]
plt.figure()
plt.plot(T1[:,0],SEQ,'+-')
plt.plot(T1[:,0],T1[:,1],'+-')
plt.plot(T2[:,0],T2[:,1],'+-')
plt.plot(T6[:,0],T6[:,1],'+-')
plt.plot(T12[:,0],T12[:,1],'+-')
plt.legend(["Sequentiel","1 Thread","2 Threads","6 Threads","12 Threads"])
plt.xlabel("N")
plt.ylabel("t (s)")
plt.title("Fonctions mathématiques")
plt.show()
with open ('time_maths_500k.txt', 'r') as timing:
text = timing.read()
# extract the values using regular expression
values = re.findall(r'\d+\.\d+|\d+', text)
# convert values to int or float
values = [float(value) if '.' in value else int(value) for value in values]
result = np.reshape(values,(6,5))
SEQ = result[:,3]
T = result[:,0]
Time = result[:,4]
plt.figure()
plt.plot(T,SEQ,'+-')
plt.plot(T,Time,'+-')
plt.legend(["Sequentiel","OMP"])
plt.xlabel("Threads max")
plt.ylabel("t (s)")
plt.title("Temps de traitement pour N = 5e5")
plt.show()