Skip to content

Commit

Permalink
Pass open files instead of names
Browse files Browse the repository at this point in the history
  • Loading branch information
polybeandip committed Nov 4, 2024
1 parent 31fa876 commit 2dd295f
Showing 1 changed file with 31 additions and 30 deletions.
61 changes: 31 additions & 30 deletions frontends/queues/evaluation/plot_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,23 @@ def parse(stat, file):
"specialized": {"round_robin": {}, "strict": {}},
}

with open(file) as file:
data = json.load(file)
for file, data in data.items():
if isinstance(data, dict):
data = data[stat]

flow_no = file.split("flow")[0][-1]

if "round_robin" in file:
if "binheap" in file:
out["binheap"]["round_robin"][flow_no] = data
else:
out["specialized"]["round_robin"][flow_no] = data
if "strict" in file:
if "binheap" in file:
out["binheap"]["strict"][flow_no] = data
else:
out["specialized"]["strict"][flow_no] = data
data = json.load(file)
for file, data in data.items():
if isinstance(data, dict):
data = data[stat]

flow_no = file.split("flow")[0][-1]

if "round_robin" in file:
if "binheap" in file:
out["binheap"]["round_robin"][flow_no] = data
else:
out["specialized"]["round_robin"][flow_no] = data
if "strict" in file:
if "binheap" in file:
out["binheap"]["strict"][flow_no] = data
else:
out["specialized"]["strict"][flow_no] = data

return out

Expand Down Expand Up @@ -95,20 +94,22 @@ def draw(data, stat, logic, unit):
if stat == "total_time":
file1 = sys.argv[2]
file2 = sys.argv[3]

cycle_data = parse("cycles", file1)
slack_data = parse("worst_slack", file2)

data = cycle_data.copy()
for impl in data.keys():
for logic in data[impl].keys():
for flow_no in data[impl][logic].keys():
cycles = cycle_data[impl][logic][flow_no]
slack = slack_data[impl][logic][flow_no]
data[impl][logic][flow_no] = (1000 * cycles) / (7 - slack)
with open(file1) as file1:
with open(file2) as file2:
cycle_data = parse("cycles", file1)
slack_data = parse("worst_slack", file2)

data = cycle_data.copy()
for impl in data.keys():
for logic in data[impl].keys():
for flow_no in data[impl][logic].keys():
cycles = cycle_data[impl][logic][flow_no]
slack = slack_data[impl][logic][flow_no]
data[impl][logic][flow_no] = (1000 * cycles) / (7 - slack)
else:
file = sys.argv[2]
data = parse(stat, file)
with open(file) as file:
data = parse(stat, file)

# Draw results
unit = "μs" if stat == "total_time" else None
Expand Down

0 comments on commit 2dd295f

Please sign in to comment.