Skip to content

Commit ae48b05

Browse files
committed
Improve the readability of the timer table generation
1 parent 79cdf26 commit ae48b05

File tree

1 file changed

+13
-2
lines changed
  • debug_toolbar/static/debug_toolbar/js

1 file changed

+13
-2
lines changed

debug_toolbar/static/debug_toolbar/js/timer.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,27 @@ function insertBrowserTiming() {
3131
}
3232
function addRow(tbody, stat, endStat) {
3333
const row = document.createElement("tr");
34+
const elapsed = performance.timing[stat] - timingOffset;
3435
if (endStat) {
36+
const duration =
37+
performance.timing[endStat] - performance.timing[stat];
3538
// Render a start through end bar
36-
row.innerHTML = `<td>${stat.replace("Start", "")}</td><td><svg class="djDebugLineChart" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 100 5" preserveAspectRatio="none"><rect y="0" height="5" fill="#ccc" /></svg></td><td>${performance.timing[stat] - timingOffset} (+${performance.timing[endStat] - performance.timing[stat]})</td>`;
39+
row.innerHTML = `
40+
<td>${stat.replace("Start", "")}</td>
41+
<td><svg class="djDebugLineChart" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 100 5" preserveAspectRatio="none"><rect y="0" height="5" fill="#ccc" /></svg></td>
42+
<td>${elapsed} (+${duration})</td>
43+
`;
3744
row.querySelector("rect").setAttribute(
3845
"width",
3946
getCSSWidth(stat, endStat)
4047
);
4148
} else {
4249
// Render a point in time
43-
row.innerHTML = `<td>${stat}</td><td><svg class="djDebugLineChart" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 100 5" preserveAspectRatio="none"><rect y="0" height="5" fill="#ccc" /></svg></td><td>${performance.timing[stat] - timingOffset}</td>`;
50+
row.innerHTML = `
51+
<td>${stat}</td>
52+
<td><svg class="djDebugLineChart" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 100 5" preserveAspectRatio="none"><rect y="0" height="5" fill="#ccc" /></svg></td>
53+
<td>${elapsed}</td>
54+
`;
4455
row.querySelector("rect").setAttribute("width", 2);
4556
}
4657
row.querySelector("rect").setAttribute("x", getLeft(stat));

0 commit comments

Comments
 (0)