-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathget_threshold.py
More file actions
executable file
·40 lines (33 loc) · 1.01 KB
/
Copy pathget_threshold.py
File metadata and controls
executable file
·40 lines (33 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import re
import sys
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
perc_list = {}
def extract_thput_base(file_path):
with open(file_path, 'r') as file:
data = file.readlines()
for line in data:
# Regex to match your data format
match = re.match(r"Threshold ([0-9.]+): Saved bits per element: [0-9]+ \(Total [0-9]+, ([0-9.]+)%\)", line.strip())
if match:
thresh = float(match.group(1))
perc = float(match.group(2))
if thresh not in perc_list:
perc_list[thresh] = []
perc_list[thresh].append(perc)
def main():
file = sys.argv[1]
extract_thput_base(file)
sizes = sys.argv[2].split()
print("Threshold", end="\t")
for i in sizes:
print(i + "B", end="\t")
print()
for i in perc_list.keys():
print(str(int(i * 100)) + "%", end="\t")
for j in perc_list[i]:
print(f"{j:.1f}%", end="\t")
print()
if __name__ == "__main__":
main()