Page MenuHomec4science

plot-times.py
No OneTemporary

File Metadata

Created
Tue, Sep 17, 06:33

plot-times.py

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- py-which-shell: "python"; -*-
import BlackDynamite as BD
import os
import datetime
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
thresold = 0.1 * 0.0015
parser = BD.BDParser()
params = parser.parseBDParameters()
# if ("host" not in params):
# params["host"] = "lsmssrv1.epfl.ch"
if ("job_constraints" not in params):
params["job_constraints"] = []
if ("run_constraints" not in params):
params["run_constraints"] = ['state != CREATED']
mybase = BD.Base(**params)
myrunselector = BD.RunSelector(mybase)
run_list = myrunselector.selectRuns(params["run_constraints"] + params["job_constraints"])
fig = plt.figure()
axe = fig.add_subplot(1,1,1)
values = []
revisions = []
dates = []
time_labels = [
# "bound_cond",
# "init_full",
# "distribute",
# "read_mesh",
"solve_step",
# "time_step",
"energies",
# "paraview"
]
prev_compile = True
prev_test_compile = True
for r, j in run_list:
revision = j["revision"]
try:
revision_date = datetime.datetime.fromtimestamp(int(r.getScalarQuantity('revision_date')[1][0,0]))
except:
continue
if r['state'] == 'SUBTREE':
continue
compile = not (r['state'] in ["COMPILED", 'FAIL_CONFIG_AKANTU', 'FAIL_MAKE_AKANTU', 'FAIL_CONFIG_TEST', 'FAIL_MAKE_TEST'])
run = compile and (not r['state'] in ['COMPILED', 'FAIL_TO_RUN', "RAN_TEST"])
if (not compile) or (not run):
if(prev_compile):
prev_compile = False
first_not_compile = revision_date
last_not_compile = revision_date
last_not_compile = max(last_not_compile, revision_date)
continue
elif not prev_compile:
rect = plt.Rectangle((first_not_compile, 0), last_not_compile - first_not_compile, 0.0016, facecolor="#eeaaaa", edgecolor="#eeaaaa")
plt.gca().add_patch(rect)
prev_compile = True
revisions.append(revision)
dates.append(revision_date)
value_ = [float(r.getScalarQuantity(f"time_{t}")[1][0]) for t in time_labels]
values.append(value_)
values = np.array(values)
print(values.shape)
diffs = np.diff(values, axis=0)
revisions = np.array([rev[:6] for rev in revisions])
plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d'))
plt.gca().xaxis.set_major_locator(mdates.DayLocator(interval=100))
for timer in range(len(time_labels)):
diff = diffs[:,timer]
for i, d in enumerate(diff):
if d > thresold:
for val in range(2):
r = revisions[i + val]
x = dates[i + val]
y = values[i + val, timer]
plt.text(x.date(), y, r)
#times = np.row_stack((values[:,1],
# values[:,2],
# values[:,3],
# values[:,4],
# values[:,5],
# ))
#polys = axe.stackplot(revisions, times)
#legendProxies = [ plt.Rectangle((0, 0), 1, 1, fc=poly.get_facecolor()[0]) for poly in polys ]
legendProxies = [
axe.plot(dates, values[:, i], "o", markersize=1.5) for i in range(len(time_labels))
]
plt.legend(["not compiling"] + time_labels, loc="upper left")
plt.xticks(rotation=45) # Rotates X-Axis Ticks by 45-degrees
#axe.set_xlim([0,0.05])
#axe.set_title(title + ", nbin = " + str(nbin))
axe.set_xlabel("revisions [-]")
axe.set_ylabel("time [ms]")
#axe.set_yscale('log')
plt.show()
fig.savefig("toto.pdf")

Event Timeline