-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathget_total_runtime_and_emissions.py
More file actions
38 lines (28 loc) · 1.11 KB
/
get_total_runtime_and_emissions.py
File metadata and controls
38 lines (28 loc) · 1.11 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
"""
Add up the running time and emissions of all the experiments.
"""
# STD
import os
# EXT
import pandas as pd
# PROJECT
from src.constants import EMISSION_DIR
if __name__ == "__main__":
# Get all the experiment emissions directories
experiment_dirs = os.listdir(EMISSION_DIR)
# Loop through directories, extract time and emissions
total_time, total_emissions, total_kWH = 0, 0, 0
for dir in experiment_dirs:
try:
data = pd.read_csv(os.path.join(EMISSION_DIR, dir, "emissions.csv"))
total_time += data["duration"].values[0]
total_emissions += data["emissions"].values[0]
total_kWH += data["energy_consumed"].values[0]
except FileNotFoundError:
# print(f"No emissions.csv found in {dir}")
...
minutes, seconds = divmod(total_time, 60)
hours, minutes = divmod(minutes, 60)
print(f"Total time: {hours} hours, {minutes} minutes, {int(seconds)} seconds.")
print(f"Total emissions: {total_emissions:.2f} kgCo2eq.")
print(f"Total carbon efficiency: {total_emissions / total_kWH:.2f} kgCo2eq / kWH.")