@@ -5,15 +5,15 @@ import {
55 CompileBenchmarkMetadata ,
66 CompileTestCase ,
77} from " ../common" ;
8- import {computed , onMounted , Ref , ref } from " vue" ;
8+ import {capitalize , computed , onMounted , Ref , ref } from " vue" ;
99import Tooltip from " ../../tooltip.vue" ;
1010import {ArtifactDescription } from " ../../types" ;
1111import {daysBetweenDates , getFutureDate , getPastDate } from " ./utils" ;
1212import {GraphRenderOpts , renderPlots } from " ../../../../graph/render" ;
13- import {GRAPH_RESOLVER } from " ../../../../graph/resolver" ;
14- import {GraphKind } from " ../../../../graph/data" ;
13+ import {GraphData , GraphKind , GraphsSelector } from " ../../../../graph/data" ;
1514import uPlot from " uplot" ;
1615import CachegrindCmd from " ../../../../components/cachegrind-cmd.vue" ;
16+ import {COMPILE_DETAIL_RESOLVER } from " ./detail-resolver" ;
1717
1818const props = defineProps <{
1919 testCase: CompileTestCase ;
@@ -98,16 +98,6 @@ function drawCurrentDate(opts: GraphRenderOpts, date: Date) {
9898
9999// Render both relative and absolute graphs
100100async function renderGraphs() {
101- // We want to be able to see noise "blips" vs. a previous artifact.
102- // The "percent relative from previous commit" graph should be the best to
103- // see these kinds of changes.
104- renderGraph (" percentrelative" as GraphKind , relativeChartElement );
105- // We also want to see whether a change maintained its value or whether it was noise and has since
106- // returned to steady state. Here, an absolute graph ("raw") is best.
107- renderGraph (" raw" as GraphKind , absoluteChartElement );
108- }
109-
110- async function renderGraph(kind : GraphKind , chartRef : Ref <HTMLElement | null >) {
111101 const {start, end, date} = graphRange .value ;
112102 const selector = {
113103 benchmark: props .testCase .benchmark ,
@@ -116,9 +106,68 @@ async function renderGraph(kind: GraphKind, chartRef: Ref<HTMLElement | null>) {
116106 stat: props .metric ,
117107 start ,
118108 end ,
119- kind ,
109+ kinds: [ " percentrelative " , " raw " ] as GraphKind [] ,
120110 };
121- const graphData = await GRAPH_RESOLVER .loadGraph (selector );
111+ const detail = await COMPILE_DETAIL_RESOLVER .loadDetail (selector );
112+ if (detail .commits .length === 0 ) {
113+ return ;
114+ }
115+
116+ function buildGraph(
117+ index : number ,
118+ kind : GraphKind
119+ ): [GraphData , GraphsSelector ] {
120+ const data = {
121+ commits: detail .commits ,
122+ benchmarks: {
123+ [selector .benchmark ]: {
124+ // The server returns profiles capitalized, so we need to match that
125+ // here, so that the graph code can find the expected profile.
126+ [capitalize (selector .profile )]: {
127+ [selector .scenario ]: detail .graphs [index ],
128+ },
129+ },
130+ },
131+ };
132+ const graphSelector = {
133+ benchmark: selector .benchmark ,
134+ profile: selector .profile ,
135+ scenario: selector .scenario ,
136+ stat: selector .stat ,
137+ start: selector .start ,
138+ end: selector .end ,
139+ kind ,
140+ };
141+
142+ return [data , graphSelector ];
143+ }
144+
145+ const [percentRelativeData, percentRelativeSelector] = buildGraph (
146+ 0 ,
147+ " percentrelative"
148+ );
149+ const [rawData, rawSelector] = buildGraph (1 , " raw" );
150+
151+ // We want to be able to see noise "blips" vs. a previous artifact.
152+ // The "percent relative from previous commit" graph should be the best to
153+ // see these kinds of changes.
154+ renderGraph (
155+ percentRelativeData ,
156+ percentRelativeSelector ,
157+ date ,
158+ relativeChartElement
159+ );
160+ // We also want to see whether a change maintained its value or whether it was noise and has since
161+ // returned to steady state. Here, an absolute graph ("raw") is best.
162+ renderGraph (rawData , rawSelector , date , absoluteChartElement );
163+ }
164+
165+ async function renderGraph(
166+ graphData : GraphData ,
167+ selector : GraphsSelector ,
168+ date : Date | null ,
169+ chartRef : Ref <HTMLElement | null >
170+ ) {
122171 const opts: GraphRenderOpts = {
123172 width: Math .min (window .innerWidth - 40 , 465 ),
124173 renderTitle: false ,
0 commit comments