blob: ffd807f1c147dd57caeb5c12b7bf794d9ddea083 (
plain)
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
39
40
41
|
# scripts/lib/render-timing.awk
# Render a per-test timing HTML report from sorted TSV rows.
# Input TSV (already sorted slowest-first): "<seconds>\t<suite>\t<test>".
# Variables: -v TITLE="..."
function esc(s) {
gsub(/&/, "\\&", s); gsub(/</, "\\<", s); gsub(/>/, "\\>", s)
return s
}
BEGIN { FS = "\t"; n = 0; total = 0 }
{
n++
sec[n] = $1 + 0
suite[n] = $2
name[n] = $3
total += $1 + 0
if (n == 1) maxv = $1 + 0
}
END {
print "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"utf-8\">"
print "<title>" esc(TITLE) "</title>"
print "<style>body{font:14px/1.5 sans-serif;margin:0;padding:1.5rem;color:#111}"
print "h1{font-size:18px}.meta{color:#555;margin-bottom:1rem}"
print "table{border-collapse:collapse;width:100%}"
print "th,td{padding:.3rem .5rem;text-align:left;border-bottom:1px solid #eee}"
print "td.num{text-align:right;font-variant-numeric:tabular-nums}"
print ".bar{height:.7em;background:#4c8bf5;border-radius:2px}"
print "</style></head><body>"
print "<h1>" esc(TITLE) "</h1>"
printf "<div class=\"meta\">%d tests · %.3f s total</div>\n", n, total
print "<table><thead><tr><th>#</th><th>seconds</th><th>test</th><th></th></tr></thead><tbody>"
for (i = 1; i <= n; i++) {
w = (maxv > 0 ? (sec[i] * 100.0 / maxv) : 0)
printf "<tr><td class=\"num\">%d</td><td class=\"num\">%.3f</td><td>%s</td>", i, sec[i], esc(name[i])
printf "<td><div class=\"bar\" style=\"width:%.1f%%\"></div></td></tr>\n", w
}
print "</tbody></table></body></html>"
}
|