2024-heraklion-parallel-python/exercises/exerciseA/plot.py
2024-08-30 12:17:06 +03:00

24 lines
598 B
Python

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)
print('This is the data I loaded: threads =', threads, ', timings =',timings)
fig, axs = plt.subplots()
plt.plot(threads, timings, '+')
plt.xlabel('threads')
plt.ylabel('timings')
plt.savefig('threads_v_timings.png', dpi=300)