1
1
import { readJson } from 'fs-extra' ;
2
2
import { Metrics } from './shared/types' ;
3
- import { DefaultBenchCase , getMetricsPath } from './shared' ;
3
+ import { DefaultBenchCase , getCommitLink , getMetricsPath } from './shared' ;
4
4
5
5
const productName = process . argv [ 2 ] || 'MODERNJS_FRAMEWORK' ;
6
6
@@ -31,6 +31,7 @@ function generateTable(
31
31
base : Record < string , number > ,
32
32
current : Record < string , number > ,
33
33
) {
34
+ const overThresholdTags : string [ ] = [ ] ;
34
35
const properties = Object . keys ( base ) ;
35
36
36
37
const maxPropertyLength = Math . max ( ...properties . map ( p => p . length ) ) ;
@@ -58,9 +59,16 @@ function generateTable(
58
59
10 ,
59
60
) } | ${ formattedPercent . padEnd ( 10 ) } |`;
60
61
table . push ( row ) ;
62
+
63
+ if ( percent > 5 && ! property . includes ( 'InstallTime' ) ) {
64
+ overThresholdTags . push ( property ) ;
65
+ }
61
66
} ) ;
62
67
63
- return table . join ( '\n' ) ;
68
+ console . log ( '' ) ;
69
+ console . log ( table . join ( '\n' ) ) ;
70
+
71
+ return overThresholdTags ;
64
72
}
65
73
66
74
export async function compare ( productName : string ) {
@@ -74,10 +82,22 @@ export async function compare(productName: string) {
74
82
const baseKey = keys [ keys . length - 2 ] ;
75
83
const current = allMetrics [ currentKey as any ] ;
76
84
const base = allMetrics [ baseKey as any ] ;
85
+ const baseCommitLink = getCommitLink ( productName , baseKey ) ;
86
+ const currentCommitLink = getCommitLink ( productName , currentKey ) ;
77
87
78
- const formatTable = generateTable ( base , current ) ;
79
88
console . log ( `case: ${ caseName } ` ) ;
80
- console . log ( formatTable ) ;
89
+ console . log ( 'base: ' , baseCommitLink ) ;
90
+ console . log ( 'current: ' , currentCommitLink ) ;
91
+
92
+ const overThresholdTags = generateTable ( base , current ) ;
93
+
94
+ if ( overThresholdTags . length > 0 ) {
95
+ console . log ( '' ) ;
96
+ console . log (
97
+ `Threshold exceeded in ${ caseName } : ` ,
98
+ JSON . stringify ( overThresholdTags ) ,
99
+ ) ;
100
+ }
81
101
}
82
102
83
103
compare ( productName ) ;
0 commit comments