2024-heraklion-parallel-python/exercises/exerciseA/plot.py

31 lines
759 B
Python
Raw Normal View History

2024-08-29 11:19:39 +02:00
import os
import numpy as np
import matplotlib.pyplot as plt
2024-08-29 11:19:39 +02:00
# IO: This loads the timings for you
threads, timings = [], []
for file in os.listdir('timings'):
with open(f'timings/{file}', 'r') as f:
n, t = f.read().strip().split(',')
if n != "None":
threads.append(int(n))
timings.append(float(t))
2024-08-29 11:19:39 +02:00
threads = np.array(threads)
timings = np.array(timings)
print('This is the data I loaded: threads =', threads, ', timings =',timings)
fig, axs = plt.subplots()
# CREATE YOUR PLOT HERE
plt.plot(threads, timings, ".")
plt.xlabel("# of Threads")
plt.ylabel("Timings")
plt.title('Time vs Thread')
2024-08-29 11:19:39 +02:00
# Remember to label your axis
# Feel free to make it pretty
plt.savefig('threads_v_timings.png', dpi=300)
plt.show()