From a097dd2fd3e4884f631b008be951dd72ac537ed4 Mon Sep 17 00:00:00 2001 From: ASPP Student Date: Fri, 30 Aug 2024 12:22:23 +0300 Subject: [PATCH] change plot code to plot threads vs timing --- exercises/exerciseA/plot.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/exercises/exerciseA/plot.py b/exercises/exerciseA/plot.py index 4130224..67c5983 100644 --- a/exercises/exerciseA/plot.py +++ b/exercises/exerciseA/plot.py @@ -2,13 +2,15 @@ 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)) + if n != "None": + threads.append(int(n)) + timings.append(float(t)) threads = np.array(threads) timings = np.array(timings) @@ -17,7 +19,13 @@ 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') + # Remember to label your axis # Feel free to make it pretty plt.savefig('threads_v_timings.png', dpi=300) +plt.show() \ No newline at end of file -- 2.39.5