Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. # speedup and parralel performance analysis
  2.  
  3. import matplotlib.pyplot as plt
  4. import numpy as np
  5.  
  6. threads = [1, 2, 4, 8, 16]
  7. wall_time = [135.51, 69.36, 37.62, 20.73, 11.86]
  8. cpu_time = [135.53, 138.77, 150.48, 165.78, 186.57]
  9.  
  10. speedup = [wall_time[0] / time for time in wall_time]
  11. efficiency = [speed / proc for speed, proc in zip(speedup, threads)]
  12.  
  13. plt.plot(threads, wall_time)
  14. plt.xticks([1, 2, 4, 8, 16])
  15. plt.title("Time")
  16. plt.ylabel("time (s)")
  17. plt.xlabel("no. processors")
  18.  
  19. plt.savefig("time.png")
  20. plt.show()
  21.  
  22. su, = plt.plot(threads, speedup, label="speedup")
  23. yex, = plt.plot([0, 16], [0, 16], label="y=x") # plot y=x
  24. plt.xticks([1,2,4,8,16])
  25. plt.title("Speedup")
  26. plt.ylabel("speedup")
  27. plt.xlabel("no. processors")
  28. plt.legend(handles=[su, yex])
  29. plt.savefig("speedup.png")
  30. plt.show()
  31.  
  32. plt.plot(threads, efficiency, label="efficiency")
  33. plt.xticks([1,2,4,8,16])
  34. plt.title("Efficiency")
  35. plt.ylabel("efficiency")
  36. plt.xlabel("no. processors")
  37.  
  38. plt.savefig("efficiency.png")
  39. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement