-
-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
153 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
|
||
name: Build Examples | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- 'src/**' | ||
- 'package.json' | ||
- 'benchmark/**' | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
benchmark: | ||
name: PR Benchmark | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'npm' | ||
|
||
- name: Install | ||
run: npm ci | ||
|
||
- name: Run PR Benchmark | ||
run: node ./benchmark/run-benchmark.js --json > pr-benchmark.json | ||
|
||
- name: Checkout master | ||
run: git checkout master | ||
|
||
- name: Run Master Benchmark | ||
run: node ./benchmark/run-benchmark.js --json > main-benchmark.json | ||
|
||
- name: Log Difference | ||
run: node ./benchmark/make-benchmark-log.js | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import fs from 'fs'; | ||
import { fileURLToPath } from 'url'; | ||
import { dirname, join } from 'path'; | ||
import { pad } from './utils.js'; | ||
|
||
const __filename = fileURLToPath( import.meta.url ); | ||
const __dirname = dirname( __filename ); | ||
|
||
const prData = JSON.parse( fs.readFileSync( join( __dirname, '../pr-benchmark.json' ) ) ); | ||
const maData = JSON.parse( fs.readFileSync( join( __dirname, '../master-benchmark.json' ) ) ); | ||
|
||
const info = []; | ||
let skipped = 0; | ||
for ( let i = 0; i < prData.length; i ++ ) { | ||
|
||
const prInfo = prData[ i ]; | ||
const maInfo = maData[ i ]; | ||
const key = prInfo.key.replace( /\t/g, ' ' ); | ||
|
||
if ( prInfo.key !== maInfo.key ) { | ||
|
||
skipped ++; | ||
|
||
} | ||
|
||
if ( prInfo.key === '' ) { | ||
|
||
continue; | ||
|
||
} | ||
|
||
if ( prInfo.value === null ) { | ||
|
||
info.push( { key: key } ); | ||
continue; | ||
|
||
} | ||
|
||
const maValue = parseFloat( maInfo.value ); | ||
const prValue = parseFloat( prInfo.value ); | ||
|
||
const unit = maInfo.value.replace( /[\s\d\.]+/g, '' ); | ||
const delta = prValue - maValue; | ||
const perc = delta / maValue; | ||
|
||
info.push( { | ||
key: key, | ||
before: maValue, | ||
after: prValue, | ||
delta: delta, | ||
perc: perc, | ||
unit: unit, | ||
} ); | ||
|
||
} | ||
|
||
const isOverThreshold = v => v.perc && v.perc > 0.03; | ||
info.forEach( v => { | ||
|
||
if ( isOverThreshold( v ) ) { | ||
|
||
const line = [ | ||
pad( v.key, 40 ), | ||
pad( `${ v.before.toFixed( 4 ) } ${ v.unit }`, 15 ), | ||
pad( `${ v.after.toFixed( 4 ) } ${ v.unit }`, 15 ), | ||
pad( `${ v.delta.toFixed( 4 ) } ${ v.unit }`, 15 ), | ||
pad( `${ ( 100 * v.perc ).toFixed( 3 ) } %`, 15 ), | ||
]; | ||
console.log( line.join( '| ' ) ); | ||
|
||
} | ||
|
||
} ); | ||
|
||
console.log(); | ||
console.log(); | ||
console.log(); | ||
|
||
info.forEach( v => { | ||
|
||
let line = [ | ||
pad( v.key, 40 ), | ||
pad( '', 15 ), | ||
pad( '', 15 ), | ||
pad( '', 15 ), | ||
pad( '', 15 ), | ||
]; | ||
|
||
if ( v.perc ) { | ||
|
||
line = [ | ||
( isOverThreshold( v ) ? '* ' : ' ' ) + pad( v.key, 40 ), | ||
pad( `${ v.before.toFixed( 4 ) } ${ v.unit }`, 15 ), | ||
pad( `${ v.after.toFixed( 4 ) } ${ v.unit }`, 15 ), | ||
pad( `${ v.delta.toFixed( 4 ) } ${ v.unit }`, 15 ), | ||
pad( `${ ( 100 * v.perc ).toFixed( 3 ) } %`, 15 ), | ||
]; | ||
|
||
} | ||
|
||
console.log( line.join( '| ' ) ); | ||
|
||
} ); | ||
|
||
// console.log( JSON.stringify( info, null, '\t' ) ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters