1
1
import { GraphKind , Series } from "../../../../graph/data" ;
2
2
import { getJson } from "../../../../utils/requests" ;
3
- import { COMPARE_COMPILE_DETAIL_DATA_URL } from "../../../../urls" ;
3
+ import {
4
+ COMPARE_COMPILE_DETAIL_GRAPHS_DATA_URL ,
5
+ COMPARE_COMPILE_DETAIL_SECTIONS_DATA_URL ,
6
+ } from "../../../../urls" ;
7
+ import { CachedDataLoader } from "./utils" ;
4
8
5
- export interface CompileDetailSelector {
9
+ export interface CompileDetailGraphsSelector {
6
10
start : string ;
7
11
end : string ;
8
12
stat : string ;
@@ -13,44 +17,58 @@ export interface CompileDetailSelector {
13
17
}
14
18
15
19
// Compile benchmark detail received from the server
16
- export interface CompileDetail {
20
+ export interface CompileDetailGraphs {
17
21
commits : Array < [ number , string ] > ;
18
22
// One Series for each GraphKind in the CompileDetailSelector
19
23
graphs : Series [ ] ;
24
+ sections_before : CompilationSections | null ;
25
+ sections_after : CompilationSections | null ;
20
26
}
21
27
22
- /**
23
- * Compile benchmark detail resolver that contains a cache of downloaded details.
24
- * This is important for Vue components that download the benchmark detail on mount.
25
- * Without a cache, they would download the detail each time they are destroyed
26
- * and recreated.
27
- */
28
- export class CompileBenchmarkDetailResolver {
29
- private cache : Dict < CompileDetail > = { } ;
28
+ export interface CompileDetailSectionsSelector {
29
+ start : string ;
30
+ end : string ;
31
+ benchmark : string ;
32
+ scenario : string ;
33
+ profile : string ;
34
+ }
30
35
31
- public async loadDetail (
32
- selector : CompileDetailSelector
33
- ) : Promise < CompileDetail > {
34
- const key = `${ selector . benchmark } ;${ selector . profile } ;${ selector . scenario } ;${ selector . start } ;${ selector . end } ;${ selector . stat } ;${ selector . kinds } ` ;
35
- if ( ! this . cache . hasOwnProperty ( key ) ) {
36
- this . cache [ key ] = await loadDetail ( selector ) ;
37
- }
36
+ export interface CompileDetailSections {
37
+ before : CompilationSections | null ;
38
+ after : CompilationSections | null ;
39
+ }
40
+
41
+ export interface CompilationSection {
42
+ name : string ;
43
+ value : number ;
44
+ }
38
45
39
- return this . cache [ key ] ;
40
- }
46
+ export interface CompilationSections {
47
+ sections : CompilationSection [ ] ;
41
48
}
42
49
43
50
/**
51
+ * Compile benchmark detail resolver that contains a cache of downloaded details.
52
+ * This is important for Vue components that download the benchmark detail on mount.
53
+ * Without a cache, they would download the detail each time they are destroyed
54
+ * and recreated.
44
55
* This is essentially a global variable, but it makes the code simpler and
45
56
* since we currently don't have any unit tests, we don't really need to avoid
46
57
* global variables that much. If needed, it could be provided to Vue components
47
58
* from a parent via props or context.
48
59
*/
49
- export const COMPILE_DETAIL_RESOLVER = new CompileBenchmarkDetailResolver ( ) ;
60
+ export const COMPILE_DETAIL_GRAPHS_RESOLVER : CachedDataLoader <
61
+ CompileDetailGraphsSelector ,
62
+ CompileDetailGraphs
63
+ > = new CachedDataLoader (
64
+ ( key : CompileDetailGraphsSelector ) =>
65
+ `${ key . benchmark } ;${ key . profile } ;${ key . scenario } ;${ key . start } ;${ key . end } ;${ key . stat } ;${ key . kinds } ` ,
66
+ loadGraphsDetail
67
+ ) ;
50
68
51
- async function loadDetail (
52
- selector : CompileDetailSelector
53
- ) : Promise < CompileDetail > {
69
+ async function loadGraphsDetail (
70
+ selector : CompileDetailGraphsSelector
71
+ ) : Promise < CompileDetailGraphs > {
54
72
const params = {
55
73
start : selector . start ,
56
74
end : selector . end ,
@@ -60,5 +78,34 @@ async function loadDetail(
60
78
profile : selector . profile ,
61
79
kinds : selector . kinds . join ( "," ) ,
62
80
} ;
63
- return await getJson < CompileDetail > ( COMPARE_COMPILE_DETAIL_DATA_URL , params ) ;
81
+ return await getJson < CompileDetailGraphs > (
82
+ COMPARE_COMPILE_DETAIL_GRAPHS_DATA_URL ,
83
+ params
84
+ ) ;
85
+ }
86
+
87
+ // The same thing, but for sections
88
+ export const COMPILE_DETAIL_SECTIONS_RESOLVER : CachedDataLoader <
89
+ CompileDetailSectionsSelector ,
90
+ CompileDetailSections
91
+ > = new CachedDataLoader (
92
+ ( key : CompileDetailGraphsSelector ) =>
93
+ `${ key . benchmark } ;${ key . profile } ;${ key . scenario } ;${ key . start } ;${ key . end } ` ,
94
+ loadSectionsDetail
95
+ ) ;
96
+
97
+ async function loadSectionsDetail (
98
+ selector : CompileDetailSectionsSelector
99
+ ) : Promise < CompileDetailSections > {
100
+ const params = {
101
+ start : selector . start ,
102
+ end : selector . end ,
103
+ benchmark : selector . benchmark ,
104
+ scenario : selector . scenario ,
105
+ profile : selector . profile ,
106
+ } ;
107
+ return await getJson < CompileDetailSections > (
108
+ COMPARE_COMPILE_DETAIL_SECTIONS_DATA_URL ,
109
+ params
110
+ ) ;
64
111
}
0 commit comments