plot_result.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. """
  2. Copyright 2011-2014 Mario Mulansky
  3. Copyright 2011-2014 Karsten Ahnert
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENSE_1_0.txt or
  6. copy at http://www.boost.org/LICENSE_1_0.txt)
  7. """
  8. import numpy as np
  9. from matplotlib import pyplot as plt
  10. plt.rc("font", size=16)
  11. def get_runtime_from_file(filename):
  12. gcc_perf_file = open(filename, 'r')
  13. for line in gcc_perf_file:
  14. if "Minimal Runtime:" in line:
  15. return float(line.split(":")[-1])
  16. t_gcc = [get_runtime_from_file("perf_workbook/odeint_rk4_array_gcc.perf"),
  17. get_runtime_from_file("perf_ariel/odeint_rk4_array_gcc.perf"),
  18. get_runtime_from_file("perf_lyra/odeint_rk4_array_gcc.perf")]
  19. t_intel = [get_runtime_from_file("perf_workbook/odeint_rk4_array_intel.perf"),
  20. get_runtime_from_file("perf_ariel/odeint_rk4_array_intel.perf"),
  21. get_runtime_from_file("perf_lyra/odeint_rk4_array_intel.perf")]
  22. t_gfort = [get_runtime_from_file("perf_workbook/rk4_gfort.perf"),
  23. get_runtime_from_file("perf_ariel/rk4_gfort.perf"),
  24. get_runtime_from_file("perf_lyra/rk4_gfort.perf")]
  25. t_c_intel = [get_runtime_from_file("perf_workbook/rk4_c_intel.perf"),
  26. get_runtime_from_file("perf_ariel/rk4_c_intel.perf"),
  27. get_runtime_from_file("perf_lyra/rk4_c_intel.perf")]
  28. print t_c_intel
  29. ind = np.arange(3) # the x locations for the groups
  30. width = 0.15 # the width of the bars
  31. fig = plt.figure()
  32. ax = fig.add_subplot(111)
  33. rects1 = ax.bar(ind, t_gcc, width, color='b', label="odeint gcc")
  34. rects2 = ax.bar(ind+width, t_intel, width, color='g', label="odeint intel")
  35. rects3 = ax.bar(ind+2*width, t_c_intel, width, color='y', label="C intel")
  36. rects4 = ax.bar(ind+3*width, t_gfort, width, color='c', label="gfort")
  37. ax.axis([-width, 2.0+5*width, 0.0, 0.85])
  38. ax.set_ylabel('Runtime (s)')
  39. ax.set_title('Performance for integrating the Lorenz system')
  40. ax.set_xticks(ind + 1.5*width)
  41. ax.set_xticklabels(('Core i5-3210M\n3.1 GHz',
  42. 'Xeon E5-2690\n3.8 GHz',
  43. 'Opteron 8431\n 2.4 GHz'))
  44. ax.legend(loc='upper left', prop={'size': 16})
  45. plt.savefig("perf.pdf")
  46. plt.savefig("perf.png", dpi=50)
  47. plt.show()