@@ -31,15 +31,26 @@ const testSuiteMap = {
31
31
*/
32
32
const afterStats = parseFile ( 'performance-results.json' ) ;
33
33
34
+ if ( ! afterStats . length ) {
35
+ console . error ( 'No results file found' ) ;
36
+ process . exit ( 1 ) ;
37
+ }
38
+
34
39
/**
35
40
* @type {Array<{file: string, title: string, results: Record<string,number[]>[]}> }
36
41
*/
37
42
const baseStats = parseFile ( 'base-performance-results.json' ) ;
38
43
44
+ if ( ! baseStats . length ) {
45
+ console . error ( 'No base results file found' ) ;
46
+ process . exit ( 1 ) ;
47
+ }
48
+
39
49
/**
40
50
* @type {Record<string, number> }
41
51
*/
42
52
const metrics = { } ;
53
+
43
54
/**
44
55
* @type {Record<string, number> }
45
56
*/
@@ -65,38 +76,14 @@ for ( const { title, results } of afterStats ) {
65
76
}
66
77
}
67
78
68
- process . exit ( 0 ) ;
69
-
70
- /**
71
- * Gets the array of metrics from a list of results.
72
- *
73
- * @param {Object[] } results A list of results to format.
74
- * @return {Object } Metrics.
75
- */
76
- const formatResults = ( results ) => {
77
- return results . reduce ( ( result , { key, file } ) => {
78
- return {
79
- ...result ,
80
- ...Object . fromEntries (
81
- Object . entries ( parseFile ( file ) ?? { } ) . map (
82
- ( [ metric , value ] ) => [
83
- key + '-' + metric ,
84
- median ( value ) ,
85
- ]
86
- )
87
- ) ,
88
- } ;
89
- } , { } ) ;
90
- } ;
91
-
92
79
const data = new TextEncoder ( ) . encode (
93
80
JSON . stringify ( {
94
81
branch,
95
82
hash,
96
83
baseHash,
97
84
timestamp : parseInt ( timestamp , 10 ) ,
98
- metrics : formatResults ( testResults ) ,
99
- baseMetrics : formatResults ( baseResults ) ,
85
+ metrics : metrics ,
86
+ baseMetrics : baseMetrics ,
100
87
} )
101
88
) ;
102
89
0 commit comments