Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # speedup and parralel performance analysis
- import matplotlib.pyplot as plt
- import numpy as np
- threads = [1, 2, 4, 8, 16]
- wall_time = [135.51, 69.36, 37.62, 20.73, 11.86]
- cpu_time = [135.53, 138.77, 150.48, 165.78, 186.57]
- speedup = [wall_time[0] / time for time in wall_time]
- efficiency = [speed / proc for speed, proc in zip(speedup, threads)]
- plt.plot(threads, wall_time)
- plt.xticks([1, 2, 4, 8, 16])
- plt.title("Time")
- plt.ylabel("time (s)")
- plt.xlabel("no. processors")
- plt.savefig("time.png")
- plt.show()
- su, = plt.plot(threads, speedup, label="speedup")
- yex, = plt.plot([0, 16], [0, 16], label="y=x") # plot y=x
- plt.xticks([1,2,4,8,16])
- plt.title("Speedup")
- plt.ylabel("speedup")
- plt.xlabel("no. processors")
- plt.legend(handles=[su, yex])
- plt.savefig("speedup.png")
- plt.show()
- plt.plot(threads, efficiency, label="efficiency")
- plt.xticks([1,2,4,8,16])
- plt.title("Efficiency")
- plt.ylabel("efficiency")
- plt.xlabel("no. processors")
- plt.savefig("efficiency.png")
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement