diff options
Diffstat (limited to 'python/mozperftest/mozperftest/metrics/notebook/notebook-sections')
3 files changed, 112 insertions, 0 deletions
diff --git a/python/mozperftest/mozperftest/metrics/notebook/notebook-sections/compare b/python/mozperftest/mozperftest/metrics/notebook/notebook-sections/compare new file mode 100644 index 0000000000..f6870f0246 --- /dev/null +++ b/python/mozperftest/mozperftest/metrics/notebook/notebook-sections/compare @@ -0,0 +1,85 @@ +%% md +<div id="table-wrapper"> + <table id="compareTable" border="1"></table> +</div> + +%% py +from js import document, data_object +import json +import numpy as np + +split_data = {} +dir_names = set() +subtests = set() +newest_run_name = "" +for element in data_object: + name = element["name"] + if "- newest run" in name: + newest_run_name = name + subtest = element["subtest"] + dir_names.add(name) + subtests.add(subtest) + + data = [p["value"] for p in element["data"]] + split_data.setdefault(name, {}).update({ + subtest:{ + "data":data, + "stats":{ + "Mean": np.round(np.mean(data),2), + "Median": np.median(data), + "Std. Dev.": np.round(np.std(data),2) + } + } + }) + +table = document.getElementById("compareTable") +table.innerHTML='' + +# build table head +thead = table.createTHead() +throw = thead.insertRow() +for name in ["Metrics", "Statistics"] + list(dir_names): + th = document.createElement("th") + th.appendChild(document.createTextNode(name)) + throw.appendChild(th) + +def fillRow(row, subtest, stat): + row.insertCell().appendChild(document.createTextNode(stat)) + newest_run_val = split_data[newest_run_name][subtest]["stats"][stat] + for name in dir_names: + cell_val = split_data[name][subtest]["stats"][stat] + diff = np.round((cell_val - newest_run_val * 1.0)/newest_run_val * 100, 2) + color = "red" if diff>0 else "green" + row.insertCell().innerHTML = f"{cell_val}\n(<span style=\"color:{color}\">{diff}</span>%)" + +# build table body +tbody = document.createElement("tbody") +for subtest in subtests: + row1 = tbody.insertRow() + cell0 = row1.insertCell() + cell0.appendChild(document.createTextNode(subtest)) + cell0.rowSpan = 3; + a = split_data + fillRow(row1, subtest, "Mean") + + row2 = tbody.insertRow() + fillRow(row2, subtest, "Median") + + row3 = tbody.insertRow() + fillRow(row3, subtest, "Std. Dev.") + +table.appendChild(tbody) + +%% css +#table-wrapper { + height: 600px; + overflow: auto; +} + +#table { + display: table; +} + +td { + white-space:pre-line; +} diff --git a/python/mozperftest/mozperftest/metrics/notebook/notebook-sections/header b/python/mozperftest/mozperftest/metrics/notebook/notebook-sections/header new file mode 100644 index 0000000000..1a0f659e54 --- /dev/null +++ b/python/mozperftest/mozperftest/metrics/notebook/notebook-sections/header @@ -0,0 +1,12 @@ +%% md +# Welcome to PerftestNotebook + +press the :fast_forward: button on your top left corner to run whole notebook + +%% fetch + +text: data_string = http://127.0.0.1:5000/data + +%% js + +var data_object = JSON.parse(data_string); diff --git a/python/mozperftest/mozperftest/metrics/notebook/notebook-sections/scatterplot b/python/mozperftest/mozperftest/metrics/notebook/notebook-sections/scatterplot new file mode 100644 index 0000000000..f68b540236 --- /dev/null +++ b/python/mozperftest/mozperftest/metrics/notebook/notebook-sections/scatterplot @@ -0,0 +1,15 @@ +%% py +from js import data_object +import matplotlib.pyplot as plt + +plt.figure() + +for element in data_object: + data_array = element["data"] + x = [x["xaxis"] for x in data_array] + y = [x["value"] for x in data_array] + label = element["name"]+"\n"+element["subtest"] + plt.scatter(x,y,label=label) + +plt.legend() +plt.show() |