Skip to content

Commit b10000c

Browse files
authored
Merge branch 'update-ui' into significant
2 parents 93a974c + 83d3c3e commit b10000c

File tree

1 file changed

+104
-61
lines changed

1 file changed

+104
-61
lines changed

site/static/compare.html

Lines changed: 104 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
#filters {
7070
border: 1px black;
7171
border-style: dotted;
72-
margin: 16px 0px;
72+
margin: 12px 0px;
7373
border-radius: 10px;
7474
}
7575

@@ -141,6 +141,29 @@
141141
visibility: visible;
142142
opacity: 1;
143143
}
144+
145+
.description-box {
146+
border: 1px solid;
147+
display: flex;
148+
}
149+
150+
.description-arrow {
151+
display: flex;
152+
flex-direction: column;
153+
justify-content: center;
154+
background: #8dcc8d;
155+
padding: 5px;
156+
}
157+
158+
#not-continuous {
159+
display: flex;
160+
flex-direction: column;
161+
justify-content: center;
162+
text-align: center;
163+
background: #cc3300;
164+
border: 1px solid;
165+
cursor: help;
166+
}
144167
</style>
145168
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
146169
</head>
@@ -152,8 +175,6 @@
152175
</div>
153176
<br />
154177
<div id="app">
155-
<h1>Comparing <span id="stat-header">instructions:u</span> between <span id="before">???</span> and <span
156-
id="after">???</span></h1>
157178
<fieldset id="settings">
158179
<legend id="search-toggle" class="section-heading">Do another comparison<span
159180
id="search-toggle-indicator"></span></legend>
@@ -179,6 +200,34 @@ <h1>Comparing <span id="stat-header">instructions:u</span> between <span id="bef
179200
</div>
180201
<input id="submit" type="submit" value="Submit" onclick="submitSettings(); return false;">
181202
</fieldset>
203+
<h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{{before}}</span> and
204+
<span id="after">{{after}}</span>
205+
</h2>
206+
<div v-if="data" style="margin: 12px 0;">
207+
<div style="display: flex;justify-content: center;">
208+
<div class="description-box">
209+
<div class="description-arrow"><a v-if="data.prev" v-bind:href="prevLink">&larr;</a></div>
210+
<div style="padding: 10px;">
211+
<a v-if="data.a.pr" v-bind:href="prLink(data.a.pr)">#{{data.a.pr}}</a>
212+
<span v-if="data.a.date">{{formatDate(data.a.date)}}</span>
213+
(<a v-bind:href="commitLink(data.a.commit)">{{short(data.a)}}</a>)
214+
</div>
215+
</div>
216+
<div v-if="notContinuous" id="not-continuous" title="WARNING! The commits are not continuous.">...
217+
</div>
218+
<div class="description-box">
219+
<div style="padding: 10px;">
220+
<a v-if="data.b.pr" v-bind:href="prLink(data.b.pr)">#{{data.b.pr}}</a>
221+
<span v-if="data.b.date">{{formatDate(data.b.date)}}</span>
222+
(<a v-bind:href="commitLink(data.b.commit)">{{short(data.b)}}</a>)
223+
</div>
224+
<div class="description-arrow"><a v-if="data.next" v-bind:href="nextLink">&rarr;</a></div>
225+
</div>
226+
</div>
227+
<div style="display: flex; justify-content: center;">
228+
<a v-bind:href="compareLink">🔎 compare commits</a>
229+
</div>
230+
</div>
182231
<fieldset id="filters">
183232
<legend id="filters-toggle" class="section-heading">Filters<span id="filters-toggle-indicator"></span>
184233
</legend>
@@ -244,40 +293,8 @@ <h1>Comparing <span id="stat-header">instructions:u</span> between <span id="bef
244293
</div>
245294
</div>
246295
</fieldset>
247-
<div id="content" style="margin-top: 15px">
248-
<table v-if="data" class="compare" style="font-size: medium !important;">
249-
<thead>
250-
<tr>
251-
<td v-if="notContinuous" colspan="4" style="text-align:center;"><b>Warning</b>: The start and
252-
end
253-
are not adjacent!</td>
254-
</tr>
255-
<tr>
256-
<th>
257-
<a v-bind:href="compareLink">compare</a>
258-
</th>
259-
<th>
260-
<a v-if="data.prev" v-bind:href="prevLink">&larr;</a>
261-
{{formatDate(data.a.date)}}
262-
(<a>{{short(data.a)}}</a>)
263-
</th>
264-
<th>
265-
{{formatDate(data.b.date)}}
266-
(<a>{{short(data.b)}}</a>)
267-
<a v-if="data.next" v-bind:href="nextLink">&rarr;</a>
268-
</th>
269-
<th>% change</th>
270-
</tr>
271-
<tr>
272-
<th></th>
273-
<th style="text-align: left;"><a v-if="data.a.pr"
274-
v-bind:href="prLink(data.a.pr)">#{{data.a.pr}}</a>
275-
</th>
276-
<th style="text-align: left;"><a v-if="data.b.pr"
277-
v-bind:href="prLink(data.b.pr)">#{{data.b.pr}}</a>
278-
</th>
279-
</tr>
280-
</thead>
296+
<div v-if="data" id="content" style="margin-top: 15px">
297+
<table class="compare" style="width: 80%; margin: 0 auto; font-size: medium !important;">
281298
<tbody>
282299
<template v-for="bench in benches">
283300
<tr data-field-start="true">
@@ -287,7 +304,9 @@ <h1>Comparing <span id="stat-header">instructions:u</span> between <span id="bef
287304
</details>
288305
</th>
289306
<td>min: <span v-bind:class="percentClass(bench.minPct)">{{bench.minPct}}%</span></td>
290-
<td>max: <span v-bind:class="percentClass(bench.maxPct)">{{bench.maxPct}}%</span></td>
307+
<td>max: <span
308+
v-bind:class="percentClass(bench.maxPct)">{{bench.maxPct}}%{{isDodgyBench(bench)
309+
? "?" : ""}}</span></td>
291310
<td></td>
292311
</tr>
293312
<template v-for="run in bench.variants">
@@ -350,6 +369,16 @@ <h1>Comparing <span id="stat-header">instructions:u</span> between <span id="bef
350369
<script src="https://cdnjs.cloudflare.com/ajax/libs/msgpack-lite/0.1.26/msgpack.min.js"></script>
351370
<script src="shared.js"></script>
352371
<script>
372+
function findQueryParam(name) {
373+
if (!window.location.search) {
374+
return null;
375+
}
376+
let urlParams = window.location.search.substring(1).split("&").map(x => x.split("="));
377+
let pair = urlParams.find(x => x[0] === name)
378+
if (pair) {
379+
return unescape(pair[1]);
380+
}
381+
}
353382
let app = new Vue({
354383
el: '#app',
355384
data: {
@@ -471,6 +500,38 @@ <h1>Comparing <span id="stat-header">instructions:u</span> between <span id="bef
471500
};
472501
}).sort((a, b) => Math.abs(b.percent) - Math.abs(a.percent));
473502
},
503+
before() {
504+
if (!this.data) {
505+
const start = findQueryParam("start");
506+
return start ? start.substring(0, 7) : "???";
507+
}
508+
if (this.data.a.pr) {
509+
return `#${this.data.a.pr}`;
510+
}
511+
if (this.data.a.date) {
512+
return this.formatDate(this.data.a.date);
513+
}
514+
515+
return this.data.a.commit.substring(0, 7);
516+
},
517+
after() {
518+
if (!this.data) {
519+
const end = findQueryParam("end");
520+
return end ? end.substring(0, 7) : "???";
521+
}
522+
523+
if (this.data.b.pr) {
524+
return `#${this.data.b.pr}`;
525+
}
526+
if (this.data.b.date) {
527+
return this.formatDate(this.data.b.date);
528+
}
529+
530+
return this.data.b.commit.substring(0, 7);
531+
},
532+
stat() {
533+
return findQueryParam("stat") || "instructions:u";
534+
}
474535
},
475536
methods: {
476537
short(comparison) {
@@ -499,6 +560,9 @@ <h1>Comparing <span id="stat-header">instructions:u</span> between <span id="bef
499560
percentLink(commit, baseCommit, bench, run) {
500561
return `/detailed-query.html?commit=${commit}&base_commit=${baseCommit}&benchmark=${bench}&run_name=${run}`;
501562
},
563+
commitLink(commit) {
564+
return `https://github.com/rust-lang/rust/commit/${commit}`;
565+
},
502566
formatDate(date) {
503567
date = new Date(date);
504568
function padStr(i) {
@@ -532,10 +596,10 @@ <h1>Comparing <span id="stat-header">instructions:u</span> between <span id="bef
532596
let styles = document.getElementById(id).style;
533597
let indicator = document.getElementById(toggle);
534598
if (styles.display != "none") {
535-
indicator.innerHTML = ""
599+
indicator.innerHTML = ""
536600
styles.display = "none";
537601
} else {
538-
indicator.innerHTML = "▼"
602+
indicator.innerHTML = " ▼"
539603
styles.display = "block";
540604
}
541605
}
@@ -564,31 +628,10 @@ <h1>Comparing <span id="stat-header">instructions:u</span> between <span id="bef
564628
stat: "instructions:u",
565629
}, state);
566630
makeRequest("/get", values).then(function (data) {
567-
updateHeader(data.a.commit, data.b.commit);
568631
app.data = data;
569632
});
570633
}
571634

572-
function updateHeader(a, b, stat) {
573-
let shorten = (text) => {
574-
return text.substring(0, 7);
575-
}
576-
a && (document.getElementById("before").innerHTML = shorten(a));
577-
b && (document.getElementById("after").innerHTML = shorten(b));
578-
stat && (document.getElementById("stat-header").innerHTML = stat);
579-
}
580-
581-
function findQueryParam(name) {
582-
let urlParams = window.location.search.substring(1).split("&").map(x => x.split("="));
583-
let pair = urlParams.find(x => x[0] === name)
584-
if (pair) {
585-
return unescape(pair[1]);
586-
}
587-
}
588-
let start = findQueryParam("start");
589-
let end = findQueryParam("end");
590-
let stat = findQueryParam("stat")
591-
updateHeader(start, end, stat);
592635

593636
function submitSettings() {
594637
let start = document.getElementById("start-bound").value;

0 commit comments

Comments
 (0)