Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sys import argv
- from os import path
- from collections import defaultdict
- import os
- dirname = argv[1]
- udp_mode = True
- three_ues_recorded = []
- one_ue_recorded = []
- for fname in os.listdir(dirname):
- if 'throughput' not in fname:
- continue
- later_cmps = fname.split('-')
- name_cmps = later_cmps[0].split('_')
- transport = name_cmps[3]
- num_ue = name_cmps[4]
- mcs = name_cmps[5]
- rwnd = name_cmps[6] if not udp_mode else ""
- rtt = name_cmps[7] if not udp_mode else name_cmps[6]
- ue_in_file = later_cmps[2] if len(later_cmps) == 3 else later_cmps[3]
- if num_ue == "1ue":
- one_ue_recorded.append({
- "transport": transport,
- "num_ue": num_ue,
- "mcs": mcs,
- "rwnd": rwnd,
- "rtt": rtt,
- "path": path.join(dirname, fname)
- })
- else:
- # Todo record 3 UEs
- three_ues_recorded.append({
- "transport": transport,
- "num_ue": num_ue,
- "mcs": mcs,
- "rwnd": rwnd,
- "rtt": rtt,
- "path": path.join(dirname, fname)
- })
- # For all with 1 ue, get the peak and average
- if len(one_ue_recorded) > 0:
- print("For 1 UE:")
- print("rtt\trwnd\tmcs\tpeak\tavg\n")
- for recorded in one_ue_recorded:
- path = recorded["path"]
- if "all" not in path:
- continue
- with open(recorded["path"]) as f:
- max_thru = 0
- throughput_acc = 0
- cnt = 0
- for line in f:
- comps = line.split(' ')
- (time, throughput) = (float(comps[0]), float(comps[1]))
- throughput_acc += throughput
- max_thru = max(throughput, max_thru)
- cnt += 1
- avg = str(round(throughput_acc / cnt, 3))
- print("\t".join([
- recorded["rtt"], recorded["rwnd"], recorded["mcs"],
- str(max_thru), avg
- ]))
- print('\n')
- # For all with 3 ue, get the peak and average
- if len(three_ues_recorded) > 0:
- consolidated = defaultdict(list)
- for recorded in three_ues_recorded:
- consolidated[(
- recorded["rtt"],
- recorded["rwnd"],
- recorded["mcs"],
- )].append(recorded)
- print("For 3 UE:")
- print("rtt\trwnd\tmcs\tpeak\tavg\n")
- for key in consolidated.keys():
- recorded_runs = consolidated[key]
- run_avg = 0
- run_peak = 0
- for recorded in recorded_runs:
- path = recorded["path"]
- if "all" not in path:
- continue
- with open(recorded["path"]) as f:
- throughput_acc = 0
- cnt = 0
- for line in f:
- comps = line.split(' ')
- (time, throughput) = (float(comps[0]), float(comps[1]))
- throughput_acc += throughput
- run_peak = max(run_peak, throughput)
- cnt += 1
- run_avg += (throughput_acc / cnt)
- avg = str(round(run_avg / 3, 3))
- print("\t".join([key[0], key[1], key[2], str(run_peak), avg]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement