Spaces:
Running
Running
root
commited on
Commit
•
8533f92
1
Parent(s):
9197037
use json built in module and os.listdir
Browse files- extract.py +18 -38
extract.py
CHANGED
@@ -1,10 +1,8 @@
|
|
1 |
-
import subprocess
|
2 |
import re
|
3 |
-
import
|
4 |
-
import datetime
|
5 |
import numpy as np
|
6 |
import statistics
|
7 |
-
import
|
8 |
import csv
|
9 |
|
10 |
model = []
|
@@ -18,41 +16,23 @@ temp_response_length = []
|
|
18 |
temp_latency = []
|
19 |
temp_energy = []
|
20 |
|
21 |
-
|
22 |
-
model2 = input("model 2: ")
|
23 |
-
model3 = input("model 3: ")
|
24 |
-
model4 = input("model 4: ")
|
25 |
-
|
26 |
-
model_name = []
|
27 |
-
model_name.append(model1)
|
28 |
-
model_name.append(model2)
|
29 |
-
model_name.append(model3)
|
30 |
-
model_name.append(model4)
|
31 |
|
32 |
match_name = False
|
33 |
|
34 |
-
for
|
35 |
-
with open(
|
36 |
-
|
37 |
|
38 |
-
for
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
match3 = re.search(r'"latency":\s*(\d+.\d+)', model_lines[i])
|
43 |
-
match4 = re.search(r'"energy":\s*(\d+.\d+)', model_lines[i])
|
44 |
-
if match and not match_name:
|
45 |
-
temp_model_name = str(match.group(1))
|
46 |
-
model.append(temp_model_name.replace('--', '/'))
|
47 |
match_name = True
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
elif match3:
|
53 |
-
temp_latency.append(float(match3.group(1)))
|
54 |
-
elif match4:
|
55 |
-
temp_energy.append(float(match4.group(1)))
|
56 |
|
57 |
match_name = False
|
58 |
|
@@ -67,10 +47,10 @@ for i in range(len(model_name)):
|
|
67 |
temp_energy.clear()
|
68 |
|
69 |
|
70 |
-
avg_throughput = [
|
71 |
-
avg_response_length = [
|
72 |
-
avg_latency = [
|
73 |
-
avg_energy = [
|
74 |
|
75 |
for i in range(len(model)):
|
76 |
print(model[i])
|
|
|
|
|
1 |
import re
|
2 |
+
import json
|
|
|
3 |
import numpy as np
|
4 |
import statistics
|
5 |
+
import os
|
6 |
import csv
|
7 |
|
8 |
model = []
|
|
|
16 |
temp_latency = []
|
17 |
temp_energy = []
|
18 |
|
19 |
+
model_name = os.listdir("data/chat")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
match_name = False
|
22 |
|
23 |
+
for models in model_name:
|
24 |
+
with open("data/chat/"+models+"/benchmark.json", 'r') as file:
|
25 |
+
json_data = json.load(file)
|
26 |
|
27 |
+
for obj in json_data:
|
28 |
+
if not match_name:
|
29 |
+
name = str(obj["model"])
|
30 |
+
model.append(name.replace('--','/'))
|
|
|
|
|
|
|
|
|
|
|
31 |
match_name = True
|
32 |
+
temp_throughput.append(float(obj["throughput"]))
|
33 |
+
temp_response_length.append(float(obj["response_length"]))
|
34 |
+
temp_latency.append(float(obj["latency"]))
|
35 |
+
temp_energy.append(float(obj["energy"]))
|
|
|
|
|
|
|
|
|
36 |
|
37 |
match_name = False
|
38 |
|
|
|
47 |
temp_energy.clear()
|
48 |
|
49 |
|
50 |
+
avg_throughput = [statistics.mean(row) for row in throughput]
|
51 |
+
avg_response_length = [statistics.mean(row) for row in response_length]
|
52 |
+
avg_latency = [statistics.mean(row) for row in latency]
|
53 |
+
avg_energy = [statistics.mean(row) for row in energy]
|
54 |
|
55 |
for i in range(len(model)):
|
56 |
print(model[i])
|