latency-hist-gpu.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import sys
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4. from mpl_toolkits.axes_grid.axislines import Subplot
  5. c = np.loadtxt('ipecamera2.1024.gpu.txt')
  6. g = np.loadtxt('ipedirectgma.1024.gpu.txt')
  7. cpu_data = c[:,1]
  8. gpu_data = g[:,1]
  9. cpu_data = cpu_data[cpu_data < 5]
  10. gpu_data = gpu_data[gpu_data < 5]
  11. #plt.rc('font', **dict(family='serif'))
  12. fig = plt.figure(1, (4,3.2))
  13. ax = Subplot(fig, 111)
  14. fig.add_subplot(ax)
  15. cpu_weights = np.ones_like(cpu_data)/float(len(cpu_data))
  16. gpu_weights = np.ones_like(gpu_data)/float(len(gpu_data))
  17. # divide by 2 for one-way latency
  18. # plt.ylim(0.1, 10000)
  19. # plt.hist(gpu_data, bins=200, label='GPU', log=True)
  20. # plt.hist(cpu_data, bins=200, label='CPU', log=True)
  21. ax.hist(gpu_data, weights=gpu_weights, bins=50, color='#3b5b92', label='Setup 1', linewidth=0)
  22. ax.hist(cpu_data, weights=cpu_weights, bins=50, color='#aec6cf', label='Setup 2', linewidth=0)
  23. plt.xticks([2.0, 3.0, 4.0, 5.0])
  24. plt.yticks([0,0.25,0.5])
  25. ax.axis["right"].set_visible(False)
  26. ax.axis["top"].set_visible(False)
  27. # plt.semilogy()
  28. plt.xlabel(u'Latency in \u00b5s')
  29. plt.ylabel('Frequency')
  30. plt.legend(loc='upper right',frameon=False)
  31. plt.savefig('latency-hist-gpu.pdf', dpi=300, bbox_inches='tight')