Lemma is an Electromagnetics API
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

plottimings.py 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. from collections import defaultdict
  4. import cpuinfo # pip install py-cpuinfo
  5. light_grey = np.array([float(225)/float(255)]*3)
  6. def fixLeg(legend):
  7. rect = legend.get_frame()
  8. #rect.set_color('None')
  9. rect.set_facecolor(light_grey)
  10. rect.set_linewidth(0.0)
  11. rect.set_alpha(1.0)
  12. def deSpine(ax1):
  13. spines_to_remove = ['top', 'right']
  14. for spine in spines_to_remove:
  15. ax1.spines[spine].set_visible(False)
  16. #ax1.xaxis.set_ticks_position('none')
  17. #ax1.yaxis.set_ticks_position('none')
  18. ax1.get_xaxis().tick_bottom()
  19. ax1.get_yaxis().tick_left()
  20. timings = np.recfromtxt(r"timings.csv", delimiter=r",", encoding=None)
  21. BENCH = {} # defaultdict(str)
  22. for i,line in enumerate(timings):
  23. # check if compiler has been added already
  24. if line[0].strip() in BENCH:
  25. pass
  26. else:
  27. BENCH[line[0].strip()] = {}
  28. print(line[1])
  29. BENCH[line[0].strip()]["version"] = line[1].strip()
  30. # check to see if Hankel has been added already
  31. if line[4].strip() in BENCH[line[0].strip()]:
  32. pass
  33. else:
  34. BENCH[line[0].strip()][line[4].strip()] = {}
  35. BENCH[line[0].strip()][line[4].strip()]["NP"] = []
  36. BENCH[line[0].strip()][line[4].strip()]["Time"] = []
  37. BENCH[line[0].strip()][line[4].strip()]["NP"].append( line[5] )
  38. BENCH[line[0].strip()][line[4].strip()]["Time"].append( line[6] )
  39. #print (BENCH)
  40. fig = plt.figure()
  41. for compiler in BENCH:
  42. print (compiler)
  43. for hankel in BENCH[compiler]:
  44. if hankel != "version":
  45. plt.plot(BENCH[compiler][hankel]["NP"], BENCH[compiler][hankel]["Time"], ".-", label=str(hankel))
  46. plt.gca().set_yscale('log')
  47. plt.gca().set_title( str(compiler) + " " + str(BENCH[compiler]["version"]) )
  48. plt.suptitle( cpuinfo.get_cpu_info()['brand'] )
  49. leg = plt.legend()
  50. deSpine(plt.gca())
  51. fixLeg(leg)
  52. plt.gca().set_xlabel("OMP_NUM_THREADS")
  53. plt.gca().set_ylabel("execution time (s)")
  54. plt.savefig("timings.png")
  55. plt.show()