From e69164e6f1db086f3fb471f2ea8eecde84191343 Mon Sep 17 00:00:00 2001 From: ASPP Student Date: Fri, 30 Aug 2024 12:09:47 +0300 Subject: [PATCH 1/2] plot multi-thread timings --- .gitignore | 3 +++ exercises/exerciseA/plot.py | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d6fa4f6..13d295e 100644 --- a/.gitignore +++ b/.gitignore @@ -117,3 +117,6 @@ dmypy.json # Pyre type checker .pyre/ + +# pngs +*.png diff --git a/exercises/exerciseA/plot.py b/exercises/exerciseA/plot.py index 4130224..b9a58b6 100644 --- a/exercises/exerciseA/plot.py +++ b/exercises/exerciseA/plot.py @@ -16,8 +16,12 @@ print('This is the data I loaded: threads =', threads, ', timings =',timings) fig, axs = plt.subplots() -# CREATE YOUR PLOT HERE + # Remember to label your axis # Feel free to make it pretty +axs.plot(threads, timings, '*') +axs.set_xlabel('number of threads') +axs.set_ylabel('processing time') + plt.savefig('threads_v_timings.png', dpi=300) -- 2.39.5 From a7cd9e443f1a592b199a60aa623af857b2eacb1e Mon Sep 17 00:00:00 2001 From: ASPP Student Date: Fri, 30 Aug 2024 12:27:32 +0300 Subject: [PATCH 2/2] update plot to relative speed up --- exercises/exerciseA/plot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/exercises/exerciseA/plot.py b/exercises/exerciseA/plot.py index b9a58b6..30cfd40 100644 --- a/exercises/exerciseA/plot.py +++ b/exercises/exerciseA/plot.py @@ -11,6 +11,7 @@ for file in os.listdir('timings'): timings.append(float(t)) threads = np.array(threads) timings = np.array(timings) +timings /= timings[np.where(threads == 1)[0][0]] print('This is the data I loaded: threads =', threads, ', timings =',timings) @@ -21,7 +22,7 @@ fig, axs = plt.subplots() # Feel free to make it pretty axs.plot(threads, timings, '*') axs.set_xlabel('number of threads') -axs.set_ylabel('processing time') +axs.set_ylabel('relative processing time to single threading') -plt.savefig('threads_v_timings.png', dpi=300) +plt.savefig('threads_v_relative_timings.png', dpi=300) -- 2.39.5