Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.16 KB | None | 0 0
  1. from sys import argv
  2. from os import path
  3. from collections import defaultdict
  4. import os
  5.  
  6. dirname = argv[1]
  7.  
  8. udp_mode = True
  9.  
  10. three_ues_recorded = []
  11. one_ue_recorded = []
  12. for fname in os.listdir(dirname):
  13. if 'throughput' not in fname:
  14. continue
  15. later_cmps = fname.split('-')
  16. name_cmps = later_cmps[0].split('_')
  17. transport = name_cmps[3]
  18. num_ue = name_cmps[4]
  19. mcs = name_cmps[5]
  20. rwnd = name_cmps[6] if not udp_mode else ""
  21. rtt = name_cmps[7] if not udp_mode else name_cmps[6]
  22. ue_in_file = later_cmps[2] if len(later_cmps) == 3 else later_cmps[3]
  23. if num_ue == "1ue":
  24. one_ue_recorded.append({
  25. "transport": transport,
  26. "num_ue": num_ue,
  27. "mcs": mcs,
  28. "rwnd": rwnd,
  29. "rtt": rtt,
  30. "path": path.join(dirname, fname)
  31. })
  32. else:
  33. # Todo record 3 UEs
  34. three_ues_recorded.append({
  35. "transport": transport,
  36. "num_ue": num_ue,
  37. "mcs": mcs,
  38. "rwnd": rwnd,
  39. "rtt": rtt,
  40. "path": path.join(dirname, fname)
  41. })
  42.  
  43. # For all with 1 ue, get the peak and average
  44. if len(one_ue_recorded) > 0:
  45. print("For 1 UE:")
  46. print("rtt\trwnd\tmcs\tpeak\tavg\n")
  47. for recorded in one_ue_recorded:
  48. path = recorded["path"]
  49. if "all" not in path:
  50. continue
  51. with open(recorded["path"]) as f:
  52. max_thru = 0
  53. throughput_acc = 0
  54. cnt = 0
  55. for line in f:
  56. comps = line.split(' ')
  57. (time, throughput) = (float(comps[0]), float(comps[1]))
  58. throughput_acc += throughput
  59. max_thru = max(throughput, max_thru)
  60. cnt += 1
  61.  
  62. avg = str(round(throughput_acc / cnt, 3))
  63. print("\t".join([
  64. recorded["rtt"], recorded["rwnd"], recorded["mcs"],
  65. str(max_thru), avg
  66. ]))
  67. print('\n')
  68.  
  69. # For all with 3 ue, get the peak and average
  70. if len(three_ues_recorded) > 0:
  71. consolidated = defaultdict(list)
  72. for recorded in three_ues_recorded:
  73. consolidated[(
  74. recorded["rtt"],
  75. recorded["rwnd"],
  76. recorded["mcs"],
  77. )].append(recorded)
  78.  
  79. print("For 3 UE:")
  80. print("rtt\trwnd\tmcs\tpeak\tavg\n")
  81. for key in consolidated.keys():
  82. recorded_runs = consolidated[key]
  83. run_avg = 0
  84. run_peak = 0
  85. for recorded in recorded_runs:
  86. path = recorded["path"]
  87. if "all" not in path:
  88. continue
  89. with open(recorded["path"]) as f:
  90. throughput_acc = 0
  91. cnt = 0
  92. for line in f:
  93. comps = line.split(' ')
  94. (time, throughput) = (float(comps[0]), float(comps[1]))
  95.  
  96. throughput_acc += throughput
  97. run_peak = max(run_peak, throughput)
  98. cnt += 1
  99. run_avg += (throughput_acc / cnt)
  100.  
  101. avg = str(round(run_avg / 3, 3))
  102. print("\t".join([key[0], key[1], key[2], str(run_peak), avg]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement