Skip to content

Commit

Permalink
ui: contest: support displaying and sorting by exec time
Browse files Browse the repository at this point in the history
Support showing exec time. Let's see which tests are slow.

Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
kuba-moo committed Aug 17, 2024
1 parent afd7786 commit e142015
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 33 deletions.
1 change: 1 addition & 0 deletions ui/contest.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
<th>Test</th>
<th>Result</th>
<th>Retry</th>
<th onclick="nipa_sort_key_set('time')">Time</th>
<th colspan="3">Links</th>
</tr>
</table>
Expand Down
36 changes: 29 additions & 7 deletions ui/contest.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ function load_result_table(data_raw)
let warn_box = document.getElementById("fl-warn-box");
warn_box.innerHTML = "";

let row_count = 0;

let form = "";
if (document.getElementById("ld-cases").checked)
form = "&ld-cases=1";

let rows = [];

$.each(data_raw, function(i, v) {
if (row_count >= 5000) {
if (rows.length >= 5000) {
warn_box.innerHTML = "Reached 5000 rows. Set an executor, branch or test filter. Otherwise this page will set your browser on fire...";
return 0;
}
Expand All @@ -65,6 +65,26 @@ function load_result_table(data_raw)
if (pw_n == false && nipa_pw_reported(v, r) == false)
return 1;

rows.push({"v": v, "r": r});
});
});

let sort_time = nipa_sort_get('time');
if (sort_time)
rows.sort(function(a, b) {
if (a.r.time === undefined && b.r.time === undefined)
return 0;
if (a.r.time === undefined)
return 1;
if (b.r.time === undefined)
return -1;
return sort_time * (b.r.time - a.r.time);
});

for (const result of rows) {
const r = result.r;
const v = result.v;

var row = table.insertRow();

var date = row.insertCell(0);
Expand All @@ -76,6 +96,7 @@ function load_result_table(data_raw)
var res = row.insertCell(6);
let row_id = 7;
var retry = row.insertCell(row_id++);
var time = row.insertCell(row_id++);
var outputs = row.insertCell(row_id++);
var flake = row.insertCell(row_id++);
var hist = row.insertCell(row_id++);
Expand All @@ -88,14 +109,13 @@ function load_result_table(data_raw)
test.innerHTML = "<b>" + r.test + "</b>";
if ("retry" in r)
retry.innerHTML = colorify_str(r.retry);
if ("time" in r)
time.innerHTML = nipa_msec_to_str(Math.round(r.time) * 1000);
res.innerHTML = colorify_str(r.result);
outputs.innerHTML = "<a href=\"" + r.link + "\">outputs</a>";
hist.innerHTML = "<a href=\"contest.html?test=" + r.test + form + "\">history</a>";
flake.innerHTML = "<a href=\"flakes.html?min-flip=0&tn-needle=" + r.test + form + "\">matrix</a>";

row_count++;
});
});
}
}

function find_branch_urls(loaded_data)
Expand Down Expand Up @@ -228,6 +248,8 @@ function do_it()
document.getElementById("ld_cnt").value = 1;
}

nipa_sort_cb = results_update;

/*
* Please remember to keep these assets in sync with `scripts/ui_assets.sh`
*/
Expand Down
69 changes: 69 additions & 0 deletions ui/nipa.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
function nipa_msec_to_str(msec) {
const convs = [
[1, "ms"],
[1000, "s"],
[60, "m"],
[60, "h"],
[24, "d"],
[7, "w"]
];

if (msec <= 0)
return msec.toString();

for (i = 0; i < convs.length; i++) {
if (msec < convs[i][0]) {
var full = Math.floor(msec) + convs[i - 1][1];
if (i > 1) {
var frac = Math.round(msec * convs[i - 1][0] % convs[i - 1][0]);
if (frac)
full += " " + frac + convs[i - 2][1];
}
return full;
}
msec /= convs[i][0];
}

return "TLE";
}

function nipa_test_fullname(v, r)
{
return v.remote + "/" + v.executor + "/" + r.group + "/" + r.test;
Expand Down Expand Up @@ -135,3 +164,43 @@ function nipa_load_sitemap()
$("#sitemap").load("sitemap.html")
});
}

// ------------------

var nipa_sort_cb = null;
let nipa_sort_keys = [];
let nipa_sort_polarity = [];

function nipa_sort_key_set(what)
{
const index = nipa_sort_keys.indexOf(what);
let polarity = 1;

if (index != -1) {
polarity = -1 * nipa_sort_polarity[index];
// delete it
nipa_sort_keys.splice(index, 1);
nipa_sort_polarity.splice(index, 1);

// We flipped back to normal polarity, that's a reset
if (polarity == 1) {
nipa_sort_cb();
return;
}
}

// add it
nipa_sort_keys.unshift(what);
nipa_sort_polarity.unshift(polarity);

nipa_sort_cb();
}

function nipa_sort_get(what)
{
const index = nipa_sort_keys.indexOf(what);

if (index == -1)
return 0;
return nipa_sort_polarity[index];
}
27 changes: 1 addition & 26 deletions ui/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,32 +361,7 @@ function status_system(data_raw)
}

function msec_to_str(msec) {
const convs = [
[1, "ms"],
[1000, "s"],
[60, "m"],
[60, "h"],
[24, "d"],
[7, "w"]
];

if (msec <= 0)
return msec.toString();

for (i = 0; i < convs.length; i++) {
if (msec < convs[i][0]) {
var full = Math.floor(msec) + convs[i - 1][1];
if (i > 1) {
var frac = Math.round(msec * convs[i - 1][0] % convs[i - 1][0]);
if (frac)
full += " " + frac + convs[i - 2][1];
}
return full;
}
msec /= convs[i][0];
}

return "TLE";
return nipa_msec_to_str(msec);
}

function colorify_str_psf(str_psf, name, value, color)
Expand Down

0 comments on commit e142015

Please sign in to comment.