File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed
pages/compare/compile/table Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change 1+ import { GraphData , GraphsSelector } from "./data" ;
2+ import { loadGraphs } from "./api" ;
3+
4+ export class GraphResolver {
5+ private cache : Dict < GraphData > = { } ;
6+
7+ public async loadGraph ( selector : GraphsSelector ) : Promise < GraphData > {
8+ const key = `${ selector . benchmark } ;${ selector . profile } ;${ selector . scenario } ;${ selector . start } ;${ selector . end } ;${ selector . stat } ;${ selector . kind } ` ;
9+ if ( ! this . cache . hasOwnProperty ( key ) ) {
10+ this . cache [ key ] = await loadGraphs ( selector ) ;
11+ }
12+
13+ return this . cache [ key ] ;
14+ }
15+ }
16+
17+ /**
18+ * This is essentially a global variable, but it makes the code simpler and
19+ * since we currently don't have any unit tests, we don't really need to avoid
20+ * global variables that much. If needed, it could be provided to Vue components
21+ * from a parent via props or context.
22+ */
23+ export const GRAPH_RESOLVER = new GraphResolver ( ) ;
Original file line number Diff line number Diff line change @@ -7,10 +7,11 @@ import {
77} from " ../common" ;
88import {computed , onMounted , Ref , ref } from " vue" ;
99import Tooltip from " ../../tooltip.vue" ;
10- import {loadGraphs } from " ../../../../graph/api" ;
1110import {ArtifactDescription } from " ../../types" ;
1211import {getDateInPast } from " ./utils" ;
1312import {renderPlots } from " ../../../../graph/render" ;
13+ import {GRAPH_RESOLVER } from " ../../../../graph/resolver" ;
14+ import {GraphKind } from " ../../../../graph/data" ;
1415
1516const props = defineProps <{
1617 testCase: CompileTestCase ;
@@ -27,9 +28,9 @@ async function renderGraph() {
2728 stat: props .metric ,
2829 start: getDateInPast (props .artifact ),
2930 end: props .artifact .commit ,
30- kind: " raw" ,
31+ kind: " raw" as GraphKind ,
3132 };
32- const graphData = await loadGraphs (selector );
33+ const graphData = await GRAPH_RESOLVER . loadGraph (selector );
3334 renderPlots (graphData , selector , chartElement .value , {
3435 renderTitle: false ,
3536 });
You can’t perform that action at this time.
0 commit comments