@@ -70,7 +70,7 @@ function prepareRevision(revision) {
70
70
fs . copyFileSync ( from , to ) ;
71
71
}
72
72
execSync (
73
- `cp -R "${ LOCAL_DIR ( ) } /src/__fixtures__/" "${ dir } /src/__fixtures__/"`
73
+ `cp -R "${ LOCAL_DIR ( ) } /src/__fixtures__/" "${ dir } /src/__fixtures__/"` ,
74
74
) ;
75
75
76
76
return babelBuild ( dir ) ;
@@ -109,7 +109,7 @@ function findFiles(cwd, pattern) {
109
109
function runBenchmark ( benchmark , environments ) {
110
110
let benchmarkName ;
111
111
const benches = environments . map ( environment => {
112
- const module = require ( path . join ( environment . distPath , benchmark ) )
112
+ const module = require ( path . join ( environment . distPath , benchmark ) ) ;
113
113
benchmarkName = module . name ;
114
114
return new Benchmark ( environment . revision , module . measure ) ;
115
115
} ) ;
@@ -149,34 +149,50 @@ function beautifyBenchmark(results) {
149
149
function printBench ( bench ) {
150
150
const { name, ops, deviation, numRuns } = bench ;
151
151
console . log (
152
- ' ' + nameStr ( ) + grey ( ' x ' ) + opsStr ( ) + ' ops/sec ' +
153
- grey ( '\xb1' ) + deviationStr ( ) + cyan ( '%' ) +
154
- grey ( ' (' + numRuns + ' runs sampled)' )
152
+ ' ' +
153
+ nameStr ( ) +
154
+ grey ( ' x ' ) +
155
+ opsStr ( ) +
156
+ ' ops/sec ' +
157
+ grey ( '\xb1' ) +
158
+ deviationStr ( ) +
159
+ cyan ( '%' ) +
160
+ grey ( ' (' + numRuns + ' runs sampled)' ) ,
155
161
) ;
156
162
157
163
function nameStr ( ) {
158
164
const nameFmt = name . padEnd ( nameMaxLen ) ;
159
- return ( ops === opsTop ) ? green ( nameFmt ) : nameFmt ;
165
+ return ops === opsTop ? green ( nameFmt ) : nameFmt ;
160
166
}
161
167
162
168
function opsStr ( ) {
163
169
const percent = ops / opsTop ;
164
- const colorFn = percent > 0.95 ? green : ( percent > 0.80 ? yellow : red ) ;
170
+ const colorFn = percent > 0.95 ? green : percent > 0.8 ? yellow : red ;
165
171
return colorFn ( beautifyNumber ( ops ) . padStart ( opsMaxLen ) ) ;
166
172
}
167
173
168
174
function deviationStr ( ) {
169
- const colorFn = deviation > 5 ? red : ( deviation > 2 ? yellow : green ) ;
175
+ const colorFn = deviation > 5 ? red : deviation > 2 ? yellow : green ;
170
176
return colorFn ( deviation . toFixed ( 2 ) ) ;
171
177
}
172
178
}
173
179
}
174
180
175
- function red ( str ) { return '\u001b[31m' + str + '\u001b[0m' }
176
- function green ( str ) { return '\u001b[32m' + str + '\u001b[0m' }
177
- function yellow ( str ) { return '\u001b[33m' + str + '\u001b[0m' }
178
- function cyan ( str ) { return '\u001b[36m' + str + '\u001b[0m' }
179
- function grey ( str ) { return '\u001b[90m' + str + '\u001b[0m' }
181
+ function red ( str ) {
182
+ return '\u001b[31m' + str + '\u001b[0m' ;
183
+ }
184
+ function green ( str ) {
185
+ return '\u001b[32m' + str + '\u001b[0m' ;
186
+ }
187
+ function yellow ( str ) {
188
+ return '\u001b[33m' + str + '\u001b[0m' ;
189
+ }
190
+ function cyan ( str ) {
191
+ return '\u001b[36m' + str + '\u001b[0m' ;
192
+ }
193
+ function grey ( str ) {
194
+ return '\u001b[90m' + str + '\u001b[0m' ;
195
+ }
180
196
181
197
function beautifyNumber ( num ) {
182
198
return Number ( num . toFixed ( num > 100 ? 0 : 2 ) ) . toLocaleString ( ) ;
@@ -193,15 +209,15 @@ function prepareAndRunBenchmarks(benchmarkPatterns, revisions) {
193
209
if ( benchmarkPatterns . length !== 0 ) {
194
210
benchmarks = benchmarks . filter ( benchmark =>
195
211
benchmarkPatterns . some ( pattern =>
196
- path . join ( 'src' , benchmark ) . includes ( pattern )
197
- )
212
+ path . join ( 'src' , benchmark ) . includes ( pattern ) ,
213
+ ) ,
198
214
) ;
199
215
}
200
216
201
217
if ( benchmarks . length === 0 ) {
202
218
console . warn (
203
219
'No benchmarks matching: ' +
204
- `\u001b[1m${ benchmarkPatterns . join ( '\u001b[0m or \u001b[1m' ) } \u001b[0m`
220
+ `\u001b[1m${ benchmarkPatterns . join ( '\u001b[0m or \u001b[1m' ) } \u001b[0m` ,
205
221
) ;
206
222
return ;
207
223
}
@@ -234,7 +250,7 @@ function getArguments(argv) {
234
250
}
235
251
if ( assumeArgs ) {
236
252
console . warn (
237
- `Assuming you meant: \u001b[1mbenchmark ${ assumeArgs . join ( ' ' ) } \u001b[0m`
253
+ `Assuming you meant: \u001b[1mbenchmark ${ assumeArgs . join ( ' ' ) } \u001b[0m` ,
238
254
) ;
239
255
}
240
256
return { benchmarkPatterns, revisions } ;
0 commit comments