2025-plovdiv-parallel-python/exercises/exerciseA/plot.py
ASPP Student 83160aefac plot
2025-09-26 12:48:41 +03:00

28 lines
746 B
Python
Executable file

import os
import numpy as np
import matplotlib.pyplot as plt
# 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(',')
threads.append(int(n))
timings.append(float(t))
threads = np.array(threads)
timings = np.array(timings)
indexes = np.argsort(threads)
threads= threads[indexes]
timings = timings[indexes]
print('This is the data I loaded: threads =', threads, ', timings =',timings)
fig, axs = plt.subplots()
plt.scatter(threads, timings)
plt.plot(threads, timings)
# CREATE YOUR PLOT HERE
# Remember to label your axis
# Feel free to make it pretty
plt.savefig('threads_v_timings.png', dpi=300)