@@ -2,16 +2,16 @@ import byteSize from './format-filesize.js'
22import { analyze as analyzeCss } from '../dist/analyzer.modern.js'
33import * as fs from 'fs'
44const files = [
5- [ 'bol-com-20190617' , 'Bol.com' , 130 ] ,
6- [ 'bootstrap-5.0.0' , 'Bootstrap 5.0.0' , 54 ] ,
7- [ 'cnn-20220403' , 'CNN' , 406 ] ,
5+ [ 'bol-com-20190617' , 'Bol.com' , 121 ] ,
6+ [ 'bootstrap-5.0.0' , 'Bootstrap 5.0.0' , 49 ] ,
7+ [ 'cnn-20220403' , 'CNN' , 376 ] ,
88 [ 'css-tricks-20190319' , 'CSS-Tricks' , 54 ] ,
9- [ 'facebook-20190319' , 'Facebook.com' , 79 ] ,
10- [ 'github-20210501' , 'GitHub.com' , 101 ] ,
11- [ 'gazelle-20210905' , 'Gazelle.nl' , 332 ] ,
12- [ 'lego-20190617' , 'Lego.com' , 63 ] ,
13- [ 'smashing-magazine-20190319' , 'Smashing Magazine.com' , 332 ] ,
14- [ 'trello-20190617' , 'Trello.com' , 86 ]
9+ [ 'facebook-20190319' , 'Facebook.com' , 76 ] ,
10+ [ 'github-20210501' , 'GitHub.com' , 93 ] ,
11+ [ 'gazelle-20210905' , 'Gazelle.nl' , 311 ] ,
12+ [ 'lego-20190617' , 'Lego.com' , 59 ] ,
13+ [ 'smashing-magazine-20190319' , 'Smashing Magazine.com' , 302 ] ,
14+ [ 'trello-20190617' , 'Trello.com' , 83 ]
1515]
1616
1717let maxLen = - 1
@@ -30,25 +30,28 @@ files.forEach(([filename, name, expectedDuration]) => {
3030 const css = fs . readFileSync ( `./src/__fixtures__/${ filename } .css` , 'utf-8' )
3131 const fileSize = byteSize ( css . length )
3232 suite . push ( [
33- `${ name . padEnd ( maxLen + 2 ) } ( ${ fileSize . padStart ( 7 ) } ) ` ,
33+ `${ name . padEnd ( maxLen + 2 ) } ${ fileSize . padStart ( 7 ) } ` ,
3434 ( ) => analyzeCss ( css ) ,
35- expectedDuration
35+ expectedDuration ,
36+ css . length ,
3637 ] )
3738} )
3839
3940const RUN_COUNT = 25
4041
41- suite . forEach ( ( [ name , fn , expectedDuration ] ) => {
42+ suite . forEach ( ( [ name , fn , expectedDuration , size ] ) => {
4243 const start = new Date ( )
4344 for ( let i = 0 ; i < RUN_COUNT ; i ++ ) {
4445 fn ( ) ;
4546 }
4647 const duration = Math . floor ( ( new Date ( ) - start ) / RUN_COUNT )
4748 const overtime = expectedDuration - duration
49+ const bytesPerSecond = Math . floor ( 1000 / duration * size )
4850 console . log (
4951 name ,
5052 `${ duration } ms` . padStart ( 6 , ' ' ) ,
51- `(${ overtime >= 0 ? '-' : '+' } ${ Math . abs ( overtime ) } ms ${ Math . round ( Math . abs ( overtime ) / duration * 100 ) } %)` ,
53+ `(${ overtime >= 0 ? '-' : '+' } ${ Math . abs ( overtime ) } ms ${ Math . round ( Math . abs ( overtime ) / duration * 100 ) } %)` . padStart ( 10 ) ,
54+ `${ byteSize ( bytesPerSecond ) } /s` . padStart ( 9 )
5255 )
5356} )
5457
0 commit comments