Skip to content

Commit d29433f

Browse files
committed
Add benchmark/scenario/profile filters to graphs page and graph history link to compare page
1 parent 9b5505b commit d29433f

File tree

4 files changed

+61
-22
lines changed

4 files changed

+61
-22
lines changed

site/src/api.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ pub mod graphs {
7474
pub end: Bound,
7575
pub stat: String,
7676
pub kind: GraphKind,
77+
pub benchmark: Option<String>,
78+
pub scenario: Option<String>,
79+
pub profile: Option<String>,
7780
}
7881

7982
#[derive(Debug, PartialEq, Copy, Clone, Serialize, Deserialize)]

site/src/request_handlers/graph.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ pub async fn handle_graphs(
3030
end: Bound::None,
3131
stat: String::from("instructions:u"),
3232
kind: graphs::GraphKind::Raw,
33+
benchmark: None,
34+
scenario: None,
35+
profile: None,
3336
};
3437

3538
if is_default_query {
@@ -80,12 +83,23 @@ async fn create_graphs(
8083
let artifact_ids = Arc::new(artifact_ids_for_range(ctxt, request.start, request.end));
8184
let mut benchmarks = HashMap::new();
8285

86+
let create_selector = |filter: &Option<String>| -> Selector<String> {
87+
filter
88+
.as_ref()
89+
.map(|value| Selector::One(value.clone()))
90+
.unwrap_or(Selector::All)
91+
};
92+
93+
let benchmark_selector = create_selector(&request.benchmark);
94+
let profile_selector = create_selector(&request.profile);
95+
let scenario_selector = create_selector(&request.scenario);
96+
8397
let interpolated_responses: Vec<_> = ctxt
8498
.statistic_series(
8599
Query::new()
86-
.set::<String>(Tag::Benchmark, Selector::All)
87-
.set::<String>(Tag::Profile, Selector::All)
88-
.set::<String>(Tag::Scenario, Selector::All)
100+
.set::<String>(Tag::Benchmark, benchmark_selector)
101+
.set::<String>(Tag::Profile, profile_selector)
102+
.set::<String>(Tag::Scenario, scenario_selector)
89103
.set::<String>(Tag::Metric, Selector::One(request.stat)),
90104
artifact_ids.clone(),
91105
)
@@ -94,9 +108,10 @@ async fn create_graphs(
94108
.map(|sr| sr.interpolate().map(|series| series.collect::<Vec<_>>()))
95109
.collect();
96110

97-
let summary_benchmark = create_summary(ctxt, &interpolated_responses, request.kind)?;
98-
99-
benchmarks.insert("Summary".to_string(), summary_benchmark);
111+
if request.benchmark.is_none() {
112+
let summary_benchmark = create_summary(ctxt, &interpolated_responses, request.kind)?;
113+
benchmarks.insert("Summary".to_string(), summary_benchmark);
114+
}
100115

101116
for response in interpolated_responses {
102117
let benchmark = response.path.get::<Benchmark>()?.to_string();

site/static/compare.html

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -612,17 +612,19 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
612612
title="Primary"
613613
:cases="testCases.filter(c => c.category === 'primary')"
614614
:show-raw-data="showRawData"
615-
:commit-a="data.a.commit"
616-
:commit-b="data.b.commit"
615+
:commit-a="data.a"
616+
:commit-b="data.b"
617+
:stat="stat"
617618
:before="before"
618619
:after="after"></test-cases-table>
619620
<hr />
620621
<test-cases-table
621622
title="Secondary"
622623
:cases="testCases.filter(c => c.category === 'secondary')"
623624
:show-raw-data="showRawData"
624-
:commit-a="data.a.commit"
625-
:commit-b="data.b.commit"
625+
:commit-a="data.a"
626+
:commit-b="data.b"
627+
:stat="stat"
626628
:before="before"
627629
:after="after"></test-cases-table>
628630
<br />
@@ -989,16 +991,28 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
989991
});
990992

991993
app.component('test-cases-table', {
992-
props: ['cases', 'showRawData', 'commitA', 'commitB', 'before', 'after', 'title'],
994+
props: ['cases', 'showRawData', 'commitA', 'commitB', 'before', 'after', 'title', 'stat'],
993995
methods: {
994996
detailedQueryLink(commit, testCase) {
995-
return `/detailed-query.html?commit=${commit}&benchmark=${testCase.benchmark + "-" + testCase.profile}&scenario=${testCase.scenario}`;
997+
return `/detailed-query.html?commit=${commit.commit}&benchmark=${testCase.benchmark + "-" + testCase.profile}&scenario=${testCase.scenario}`;
996998
},
997999
percentLink(commit, baseCommit, testCase) {
998-
return `/detailed-query.html?commit=${commit}&base_commit=${baseCommit}&benchmark=${testCase.benchmark + "-" + testCase.profile}&scenario=${testCase.scenario}`;
1000+
return `/detailed-query.html?commit=${commit.commit}&base_commit=${baseCommit.commit}&benchmark=${testCase.benchmark + "-" + testCase.profile}&scenario=${testCase.scenario}`;
9991001
},
10001002
benchmarkLink(benchmark) {
10011003
return "https://github.com/rust-lang/rustc-perf/tree/master/collector/benchmarks/" + benchmark;
1004+
},
1005+
graphLink(commit, stat, testCase) {
1006+
let date = new Date(commit.date);
1007+
// Move to `two weeks ago` to display history of the test case
1008+
date.setUTCDate(date.getUTCDate() - 14);
1009+
let year = date.getUTCFullYear();
1010+
let month = (date.getUTCMonth() + 1).toString().padStart(2, '0');
1011+
let day = date.getUTCDate().toString().padStart(2, '0');
1012+
let start = `${year}-${month}-${day}`;
1013+
1014+
let end = commit.commit;
1015+
return `/index.html?start=${start}&end=${end}&benchmark=${testCase.benchmark}&profile=${testCase.profile}&scenario=${testCase.scenario}&stat=${stat}`;
10021016
}
10031017
},
10041018
template: `
@@ -1039,7 +1053,11 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
10391053
{{ testCase.benchmark }}
10401054
</a>
10411055
</td>
1042-
<td>{{ testCase.profile }}</td>
1056+
<td>
1057+
<a v-bind:href="graphLink(commitB, stat, testCase)" target="_blank" class="silent-link">
1058+
{{ testCase.profile }}
1059+
</a>
1060+
</td>
10431061
<td>{{ testCase.scenario }}</td>
10441062
<td>
10451063
<a v-bind:href="percentLink(commitB, commitA, testCase)">

site/static/index.html

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ <h3>This may take a while!</h3>
102102

103103
const otherCacheStateColors = ["#8085e9", "#f15c80", "#e4d354", "#2b908f", "#f45b5b", "#91e8e1"];
104104
const interpolatedColor = "#fcb0f1";
105+
const basicProfiles = ["Check", "Debug", "Opt"];
105106

106107
function tooltipPlugin({ onclick, commits, isInterpolated, absoluteMode, shiftX = 10, shiftY = 10 }) {
107108
let tooltipLeftOffset = 0;
@@ -380,6 +381,8 @@ <h3>This may take a while!</h3>
380381
});
381382
}
382383

384+
let indices = cacheStates[Object.keys(cacheStates)[0]].interpolated_indices;
385+
383386
let plotOpts = genPlotOpts({
384387
title: benchName + "-" + benchKind,
385388
width: Math.floor(window.innerWidth / 3) - 16,
@@ -389,7 +392,7 @@ <h3>This may take a while!</h3>
389392
commits: data.commits,
390393
stat: state.stat,
391394
isInterpolated(dataIdx) {
392-
return cacheStates.full.interpolated_indices.has(dataIdx);
395+
return indices.has(dataIdx);
393396
},
394397
absoluteMode: state.kind == "raw",
395398
});
@@ -414,19 +417,19 @@ <h3>This may take a while!</h3>
414417
let benchmarks = {};
415418

416419
function optInterpolated(profile) {
417-
for (let cacheState in profile)
418-
profile[cacheState].interpolated_indices = new Set(profile[cacheState].interpolated_indices);
420+
for (let scenario in profile)
421+
profile[scenario].interpolated_indices = new Set(profile[scenario].interpolated_indices);
419422

420423
return profile;
421424
}
422425

423426
sortedBenchNames.forEach(name => {
424-
const { Check, Debug, Opt } = data.benchmarks[name];
427+
benchmarks[name] = {};
425428

426-
benchmarks[name] = {
427-
check: optInterpolated(Check),
428-
debug: optInterpolated(Debug),
429-
opt: optInterpolated(Opt),
429+
for (let profile of basicProfiles) {
430+
if (data.benchmarks[name].hasOwnProperty(profile)) {
431+
benchmarks[name][profile.toLowerCase()] = optInterpolated(data.benchmarks[name][profile]);
432+
}
430433
}
431434
});
432435

0 commit comments

Comments
 (0)