Skip to content

Commit 0070670

Browse files
committed
Add quick links to important metrics to compare page
1 parent 4614849 commit 0070670

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

site/static/compare.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@
4545
<input id="submit" type="submit" value="Submit" onclick="submitSettings(); return false;">
4646
</div>
4747
</fieldset>
48+
<div class="quick-links">
49+
<div>Quick links:</div>
50+
<div v-for="metric in [
51+
['Instructions', 'instructions:u'],
52+
['Cycles', 'cycles:u'],
53+
['Max RSS', 'max-rss']
54+
]" :class="{ active: stat === metric[1] }">
55+
<a :href="createUrlForMetric(metric[1])">{{ metric[0] }}</a>
56+
</div>
57+
</div>
4858
<h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{{before}}</span> and
4959
<span id="after">{{after}}</span>
5060
</h2>

site/static/compare/script.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,12 @@ const app = Vue.createApp({
325325
}
326326
return result;
327327
},
328+
createUrlForMetric(metric) {
329+
let start = findQueryParam("start");
330+
let end = findQueryParam("end");
331+
332+
return createUrlFromParams(createSearchParamsForMetric(metric, start, end));
333+
},
328334
},
329335
});
330336

@@ -486,14 +492,23 @@ function makeData(state, app) {
486492
});
487493
}
488494

489-
function submitSettings() {
490-
let start = document.getElementById("start-bound").value;
491-
let end = document.getElementById("end-bound").value;
492-
let stat = getSelected("stats");
495+
function createSearchParamsForMetric(stat, start, end) {
493496
let params = new URLSearchParams();
494497
params.append("start", start);
495498
params.append("end", end);
496499
params.append("stat", stat);
500+
return params.toString();
501+
}
502+
503+
function createUrlFromParams(params) {
504+
return window.location.protocol + "//" + window.location.host + window.location.pathname + "?" + params;
505+
}
506+
507+
function submitSettings() {
508+
let stat = getSelected("stats");
509+
let start = document.getElementById("start-bound").value;
510+
let end = document.getElementById("end-bound").value;
511+
let params = createSearchParamsForMetric(stat, start, end);
497512
window.location.search = params.toString();
498513
}
499514

site/static/compare/style.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,3 +284,15 @@ input[type="checkbox"] {
284284
.silent-link {
285285
color: inherit;
286286
}
287+
288+
.quick-links {
289+
display: flex;
290+
flex-direction: row;
291+
margin: 10px 0;
292+
}
293+
.quick-links div {
294+
margin-right: 10px;
295+
}
296+
.quick-links .active {
297+
font-weight: bold;
298+
}

0 commit comments

Comments
 (0)