Jae-Won Chung commited on
Commit
9fd9223
1 Parent(s): ba182b7

Update compute_system_metrics.py

Browse files
Files changed (1) hide show
  1. scripts/compute_system_metrics.py +8 -5
scripts/compute_system_metrics.py CHANGED
@@ -1,5 +1,6 @@
1
  import os
2
  import csv
 
3
 
4
  import tyro
5
  import pandas as pd
@@ -14,13 +15,15 @@ def main(data_dir: str, out_file: str) -> None:
14
  os.makedirs(dirname, exist_ok=True)
15
  out_csv = csv.writer(open(out_file, "w", newline=""))
16
  metrics = ["throughput", "response_length", "latency", "energy"]
17
- out_csv.writerow(["model"] + metrics)
18
 
19
  for model_name in model_names:
20
- df = pd.read_json(f"{data_dir}/{model_name}/benchmark.json")
21
- out_csv.writerow(
22
- [model_name.replace("--", "/")] + df[metrics].mean().to_list(),
23
- )
 
 
24
 
25
 
26
  if __name__ == "__main__":
 
1
  import os
2
  import csv
3
+ from glob import glob
4
 
5
  import tyro
6
  import pandas as pd
 
15
  os.makedirs(dirname, exist_ok=True)
16
  out_csv = csv.writer(open(out_file, "w", newline=""))
17
  metrics = ["throughput", "response_length", "latency", "energy"]
18
+ out_csv.writerow(["model", "batch_size"] + metrics)
19
 
20
  for model_name in model_names:
21
+ for benchmark_file in glob(f"{data_dir}/{model_name}/benchmark_batch_*.json"):
22
+ batch_size = int(benchmark_file.split("_")[-1][:-5])
23
+ df = pd.read_json(benchmark_file)
24
+ out_csv.writerow(
25
+ [model_name.replace("--", "/"), str(batch_size)] + df[metrics].mean().to_list(),
26
+ )
27
 
28
 
29
  if __name__ == "__main__":