Spaces:
Running
Running
File size: 1,889 Bytes
9197037 8533f92 9197037 8533f92 9197037 8533f92 9197037 8533f92 9197037 8533f92 9197037 8533f92 9197037 8533f92 9197037 |
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
import re
import json
import numpy as np
import statistics
import os
import csv
model = []
throughput = []
response_length = []
latency = []
energy = []
temp_throughput = []
temp_response_length = []
temp_latency = []
temp_energy = []
model_name = os.listdir("data/chat")
match_name = False
for models in model_name:
with open("data/chat/"+models+"/benchmark.json", 'r') as file:
json_data = json.load(file)
for obj in json_data:
if not match_name:
name = str(obj["model"])
model.append(name.replace('--','/'))
match_name = True
temp_throughput.append(float(obj["throughput"]))
temp_response_length.append(float(obj["response_length"]))
temp_latency.append(float(obj["latency"]))
temp_energy.append(float(obj["energy"]))
match_name = False
throughput.append(temp_throughput.copy())
response_length.append(temp_response_length.copy())
latency.append(temp_latency.copy())
energy.append(temp_energy.copy())
temp_throughput.clear()
temp_response_length.clear()
temp_latency.clear()
temp_energy.clear()
avg_throughput = [statistics.mean(row) for row in throughput]
avg_response_length = [statistics.mean(row) for row in response_length]
avg_latency = [statistics.mean(row) for row in latency]
avg_energy = [statistics.mean(row) for row in energy]
for i in range(len(model)):
print(model[i])
print(len(throughput[i]))
print(len(response_length[i]))
print(len(latency[i]))
print(len(energy[i]))
csv_file = "leaderboard.csv"
with open(csv_file, "w", newline="") as file:
writer = csv.writer(file)
writer.writerow(["model","throughput","response_length","latency","energy"])
for i in range(len(model)):
writer.writerow([model[i], avg_throughput[i], avg_response_length[i], avg_latency[i], avg_energy[i]])
|