change plot code to plot threads vs timing #8
|
@ -2,11 +2,13 @@ import os
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
|
||||||
# IO: This loads the timings for you
|
# IO: This loads the timings for you
|
||||||
threads, timings = [], []
|
threads, timings = [], []
|
||||||
for file in os.listdir('timings'):
|
for file in os.listdir('timings'):
|
||||||
with open(f'timings/{file}', 'r') as f:
|
with open(f'timings/{file}', 'r') as f:
|
||||||
n, t = f.read().strip().split(',')
|
n, t = f.read().strip().split(',')
|
||||||
|
if n != "None":
|
||||||
threads.append(int(n))
|
threads.append(int(n))
|
||||||
timings.append(float(t))
|
timings.append(float(t))
|
||||||
threads = np.array(threads)
|
threads = np.array(threads)
|
||||||
|
@ -17,7 +19,13 @@ print('This is the data I loaded: threads =', threads, ', timings =',timings)
|
||||||
fig, axs = plt.subplots()
|
fig, axs = plt.subplots()
|
||||||
|
|
||||||
# CREATE YOUR PLOT HERE
|
# 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
|
# Remember to label your axis
|
||||||
# Feel free to make it pretty
|
# Feel free to make it pretty
|
||||||
|
|
||||||
plt.savefig('threads_v_timings.png', dpi=300)
|
plt.savefig('threads_v_timings.png', dpi=300)
|
||||||
|
plt.show()
|
Loading…
Reference in a new issue