plot_server_results.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import sys
  2. import numpy as np
  3. import matplotlib.pylab as plt
  4. import pdb
  5. #
  6. import data_helpers
  7. #
  8. if __name__ == '__main__':
  9. transfers = data_helpers.read_server_results(sys.argv[1])
  10. clients = data_helpers.read_client_info(sys.argv[2])
  11. #
  12. #approx_start_time = np.min([x['time_of_first_byte'] for x in transfers])
  13. approx_start_time = clients['start_time']
  14. #
  15. colormap = plt.get_cmap('tab20').colors #'tab10'
  16. assigned_colors = []
  17. #
  18. for transfer in transfers:
  19. if transfer['custom_data']['circuit'][1][-1] in assigned_colors:
  20. color_index = assigned_colors.index(transfer['custom_data']['circuit'][1][-1])
  21. else:
  22. color_index = len(assigned_colors)
  23. assigned_colors.append(transfer['custom_data']['circuit'][1][-1])
  24. #
  25. plt.step(transfer['deltas']['timestamps']-approx_start_time, np.cumsum(transfer['deltas']['bytes']),
  26. color=colormap[color_index%len(colormap)], where='post')
  27. #
  28. ax1 = plt.gca()
  29. ax1.set_ylabel('Bytes')
  30. ax2 = ax1.twinx()
  31. ax2.set_ylim([x/(2**20) for x in ax1.get_ylim()])
  32. ax2.set_ylabel('MiB')
  33. plt.show()
  34. #
  35. last_byte_times = np.array([x['time_of_last_byte'] for x in transfers])
  36. plt.plot(np.sort(last_byte_times)-approx_start_time, np.arange(len(last_byte_times)))
  37. plt.xlim([0, None])
  38. plt.ylim([0, None])
  39. plt.show()
  40. #