From 212d2130e040fd70a867ab5551e976afbd9bb61a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Madon?= <mael.madon@irit.fr> Date: Mon, 31 Jan 2022 09:42:22 +0100 Subject: [PATCH] fix bug concurrent read of user_description_file --- instance1.py | 2 +- scripts/util.py | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/instance1.py b/instance1.py index 364811c..1dbe897 100755 --- a/instance1.py +++ b/instance1.py @@ -41,7 +41,7 @@ def run_expe(expe_num, user_category, window_size, clean_log): wl_folder = f'{WL_DIR}/expe{expe_num}' pf = f"{ROOT_DIR}/platform/average_metacentrum.xml" wl = f"{WL_DIR}/empty_workload.json" - uf = f"{ROOT_DIR}/sched_input/user_description_file.json" + uf = f"{EXPE_DIR}/cmd/user_description_file.json" # Demand response window, from 12 to (12 + window_size) on day2 dm_window = [(24+12)*3600, (int) ((24+12+window_size)*3600)] diff --git a/scripts/util.py b/scripts/util.py index d5801a7..d2dc481 100644 --- a/scripts/util.py +++ b/scripts/util.py @@ -2,6 +2,8 @@ import os import os.path import subprocess +import numpy as np +import pandas from matplotlib import figure, pyplot as plt from evalys.jobset import JobSet from evalys.metrics import compute_load @@ -90,4 +92,37 @@ def plot_load_and_details(expe_file): plt.xlim(begin, end) fig.savefig(expe_file + '_viz.png') plt.show() - plt.close(fig) \ No newline at end of file + plt.close(fig) + +def energy_consumed_in(window, OUT_DIR): + """Return the energy consumed during the time window (in kWh).""" + # The problem is that batsim time series don't always have the specific + # timestamp, we need to extrapolate + data = pandas.read_csv(OUT_DIR + "/_consumed_energy.csv") + energy = [0, 0] + for i in range(2): + first_greater = data[data['time'].ge(window[i])].index[0] + df_entry = data.iloc[first_greater] + energy[i] = df_entry['energy'] + delta_energy = (df_entry['time'] - window[i]) * df_entry['epower'] + energy[i] -= delta_energy + + return (energy[1] - energy[0]) / 3600 / 1000 + + +def scheduling_metrics_in(window, OUT_DIR): + """Return the usual scheduling metrics for the subpart of jobs that have their submission time within the time window.""" + [inf, sup] = window + data = pandas.read_csv(OUT_DIR + "/_jobs.csv") + data_in_window = data[(data.submission_time + >= inf) & (data.submission_time <= sup)] + + out = {} + out["makespan"] = data_in_window["finish_time"].max() - inf + out["#jobs"] = len(data_in_window.index) + out["mean_waiting_time"] = data_in_window["waiting_time"].mean() + out["max_waiting_time"] = data_in_window["waiting_time"].max() + out["mean_slowdown"] = data_in_window["stretch"].mean() + out["max_slowdown"] = data_in_window["stretch"].max() + + return out \ No newline at end of file -- GitLab