Move test/impact to tools/impact

master
Futago-za Ryuu 6 years ago
parent 32477337c1
commit 9c039ce79b

@ -2,7 +2,8 @@
"name": "pegjs-dev", "name": "pegjs-dev",
"private": true, "private": true,
"workspaces": [ "workspaces": [
"packages/*" "packages/*",
"tools/*"
], ],
"scripts": { "scripts": {
"lint": "gulp lint", "lint": "gulp lint",
@ -11,8 +12,8 @@
"build:parser": "gulp build:parser", "build:parser": "gulp build:parser",
"build:dist": "rollup -c", "build:dist": "rollup -c",
"clean": "gulp clean", "clean": "gulp clean",
"impact": "impact master",
"start": "node server.js", "start": "node server.js",
"test:impact": "node test/impact master",
"test": "nyc gulp", "test": "nyc gulp",
"coverage": "nyc report --reporter=text-lcov | coveralls" "coverage": "nyc report --reporter=text-lcov | coveralls"
}, },
@ -42,7 +43,6 @@
"dedent": "0.7.0", "dedent": "0.7.0",
"del": "3.0.0", "del": "3.0.0",
"eslint-config-futagozaryuu": "5", "eslint-config-futagozaryuu": "5",
"glob": "7.1.3",
"gulp-eslint": "5.0.0", "gulp-eslint": "5.0.0",
"mocha": "5.2.0", "mocha": "5.2.0",
"nyc": "13.1.0", "nyc": "13.1.0",

@ -0,0 +1,8 @@
This directory contains a tool used on the PEG.js repository that measures the impact of two git commits on a number of generated parsers, extracting the benchmark speeds and generated parser sizes, comparing the results of each commit against the other before finally displaying the overall results in the console.
From the root of the repository:
```sh
yarn impact <commit>
yarn impact <commit_before> <commit_after>
```

@ -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 ) {
} }
let PEGJS_BIN = binfile( "packages/pegjs/bin/peg.js", "bin/peg.js", "bin/pegjs" ); const PEGJS_BIN = binfile( "packages/pegjs/bin/peg.js", "bin/peg.js", "bin/pegjs" );
let BENCHMARK_BIN = binfile( "test/benchmark/run", "benchmark/run" ); const 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 /test/impact with Node.js ${ process.version } - Measured by /tools/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();

@ -0,0 +1,10 @@
{
"name": "impact",
"version": "2.1.0",
"private": true,
"bin": "index.js",
"dependencies": {
"dedent": "0.7.0",
"glob": "7.1.3"
}
}
Loading…
Cancel
Save