@ -5,7 +5,7 @@
// speed and size. Makes sense to use only on PEG.js git repository checkout.
// speed and size. Makes sense to use only on PEG.js git repository checkout.
//
//
/* eslint prefer-const: 0 */
/* eslint -disable no-mixed-operators, prefer-const */
"use strict" ;
"use strict" ;
@ -18,7 +18,7 @@ const glob = require( "glob" );
// Current Working Directory
// Current Working Directory
const cwd = path . join ( _ _dirname , ".." ) ;
const cwd = path . join ( _ _dirname , ".." , ".." ) ;
if ( process . cwd ( ) !== cwd ) process . chdir ( cwd ) ;
if ( process . cwd ( ) !== cwd ) process . chdir ( cwd ) ;
// Execution Files
// Execution Files
@ -35,8 +35,8 @@ function binfile( ...files ) {
}
}
le t PEGJS _BIN = binfile ( "packages/pegjs/bin/peg.js" , "bin/peg.js" , "bin/pegjs" ) ;
cons t PEGJS _BIN = binfile ( "packages/pegjs/bin/peg.js" , "bin/peg.js" , "bin/pegjs" ) ;
le t BENCHMARK _BIN = binfile ( "test/benchmark/run" , "benchmark/run" ) ;
cons t BENCHMARK _BIN = binfile ( "test/benchmark/run" , "benchmark/run" ) ;
// Utils
// Utils
@ -46,6 +46,12 @@ function echo( message ) {
}
}
function print _empty _line ( ) {
console . log ( " " ) ;
}
function exec ( command ) {
function exec ( command ) {
return child _process . execSync ( command , { encoding : "utf8" } ) ;
return child _process . execSync ( command , { encoding : "utf8" } ) ;
@ -121,6 +127,7 @@ if ( argv.length === 1 ) {
} else {
} else {
print _empty _line ( ) ;
console . log ( dedent `
console . log ( dedent `
Usage :
Usage :
@ -132,6 +139,7 @@ if ( argv.length === 1 ) {
speed and size . Makes sense to use only on PEG . js Git repository checkout .
speed and size . Makes sense to use only on PEG . js Git repository checkout .
` );
` );
print _empty _line ( ) ;
process . exit ( 1 ) ;
process . exit ( 1 ) ;
}
}
@ -141,21 +149,24 @@ if ( argv.length === 1 ) {
const branch = exec ( "git rev-parse --abbrev-ref HEAD" ) ;
const branch = exec ( "git rev-parse --abbrev-ref HEAD" ) ;
let speed1 , size1 , speed2 , size2 ;
let speed1 , size1 , speed2 , size2 ;
print _empty _line ( ) ;
echo ( ` Measuring commit ${ commit _before } ... ` ) ;
echo ( ` Measuring commit ${ commit _before } ... ` ) ;
prepare ( commit _before ) ;
prepare ( commit _before ) ;
speed1 = measureSpeed ( ) ;
speed1 = measureSpeed ( ) ;
size1 = measureSize ( ) ;
size1 = measureSize ( ) ;
echo ( " OK " + os . EOL ) ;
echo ( " done. " + os . EOL ) ;
echo ( ` Measuring commit ${ commit _after } ... ` ) ;
echo ( ` Measuring commit ${ commit _after } ... ` ) ;
prepare ( commit _after ) ;
prepare ( commit _after ) ;
speed2 = measureSpeed ( ) ;
speed2 = measureSpeed ( ) ;
size2 = measureSize ( ) ;
size2 = measureSize ( ) ;
echo ( " OK " + os . EOL ) ;
echo ( " done. " + os . EOL ) ;
// Finish
// Finish
prepare ( branch ) ;
prepare ( branch ) ;
print _empty _line ( ) ;
console . log ( dedent `
console . log ( dedent `
@ -173,7 +184,8 @@ console.log( dedent`
After : $ { size2 } b
After : $ { size2 } b
Difference : $ { difference ( size1 , size2 ) } %
Difference : $ { difference ( size1 , size2 ) } %
- Measured by / t est / impact with Node . js $ { process . version }
- Measured by / t ools / impact with Node . js $ { process . version }
- Your system : $ { os . type ( ) } $ { os . release ( ) } $ { os . arch ( ) } .
- Your system : $ { os . type ( ) } $ { os . release ( ) } $ { os . arch ( ) } .
` );
` );
print _empty _line ( ) ;