plot-cpu.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # -*- coding: utf-8 -*-
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4. from mpl_toolkits.axes_grid.axislines import Subplot
  5. def get_mean_std(data, size):
  6. s = data[np.where(data[:,0] == size)][:,1]
  7. # remove 2x std outliers
  8. std = np.std(s)
  9. outliers = s[np.abs(s - np.mean(s)) > 4 * np.std(s)]
  10. s = s[np.abs(s - np.mean(s)) < 4 * np.std(s)]
  11. return np.mean(s), np.std(s)
  12. def read_data(fname):
  13. data = np.loadtxt(fname)
  14. ymean = []
  15. ystd = []
  16. for i in range(128, 4096 + 128, 128):
  17. m, s = get_mean_std(data, i)
  18. ymean.append(m)
  19. ystd.append(s)
  20. return ymean, ystd
  21. xs = np.arange(128, 4096 + 128, 128)
  22. dgma_cpu_mean, dgma_cpu_std = read_data('ipedirectgma.cpu.txt')
  23. #dgma_gpu_mean, dgma_gpu_std = read_data('ipedirectgma.gpu.txt')
  24. cam2_cpu_mean, cam2_cpu_std = read_data('ipecamera2.cpu.txt')
  25. #cam2_gpu_mean, cam2_gpu_std = read_data('ipecamera2.gpu.txt')
  26. print dgma_cpu_mean[8]
  27. print cam2_cpu_mean[8]
  28. #plt.rc('font', **dict(family='serif'))
  29. fig = plt.figure(1, (4,3))
  30. ax = Subplot(fig, 111)
  31. fig.add_subplot(ax)
  32. plt.xlabel('Packet size (B)')
  33. plt.ylabel('Latency (us)')
  34. #ax.plot(xs, dgma_gpu_mean, 'x-', label='GPU memory (embedded)', color='#3b5b92')
  35. #ax.plot(xs, cam2_gpu_mean, '.-', label='GPU memory (workstation)', color='#3b5b92')
  36. ax.plot(xs, cam2_cpu_mean, '.-', markersize=4, label='Setup1', color='#028e2c')
  37. ax.plot(xs, dgma_cpu_mean, 'x-', markersize=4, label='Setup2', color='#77DD77')
  38. plt.xticks([128, 1024, 2048, 2048+1024, 4096])
  39. # plt.yticks([2,4,6,8])
  40. plt.xlim(0, 4200)
  41. ax.axis["right"].set_visible(False)
  42. ax.axis["top"].set_visible(False)
  43. plt.legend(loc='upper left', frameon=False)
  44. plt.savefig('latency-cpu.pdf', dpi=300, bbox_inches='tight')
  45. # A = np.vstack([xs, np.ones(len(xs))]).T
  46. # mc, cc = np.linalg.lstsq(A, yscm)[0]
  47. # mg, cg = np.linalg.lstsq(A, ysgm)[0]
  48. # print 100000000/ (100000000 * mc + cc)
  49. # print 100000000/ (100000000 * mg + cg)