latency-hist.py 1.0 KB

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