Skip to content

Commit

Permalink
getting ready to diff the benchmarks too
Browse files Browse the repository at this point in the history
  • Loading branch information
StoneCypher committed Apr 19, 2022
1 parent 1d15b0c commit 660d34f
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 4 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/nodejs.yml
Expand Up @@ -9,11 +9,11 @@ jobs:
strategy:
matrix:
include:
- node-version: 17.x # fastest, so run first, to error fast
- node-version: 18.x # fastest, so run first, to error fast
os: ubuntu-latest
- node-version: 17.x # slowest, so run next. sort by slowest from here to get earliest end through parallelism
- node-version: 18.x # slowest, so run next. sort by slowest from here to get earliest end through parallelism
os: macos-latest
- node-version: 17.x # finish check big-3 on latest current
- node-version: 18.x # finish check big-3 on latest current
os: windows-latest
- node-version: 10.x # lastly check just ubuntu on historic node versions because speed, oldest (slowest) first
os: ubuntu-latest
Expand All @@ -29,6 +29,8 @@ jobs:
os: ubuntu-latest
- node-version: 16.x
os: ubuntu-latest
- node-version: 17.x
os: ubuntu-latest

runs-on: ${{matrix.os}}

Expand All @@ -50,7 +52,7 @@ jobs:
path-to-lcov: ./coverage/spec/lcov.info

verify-version-bump-then-release:
if: (github.event.pusher.name == github.event.repository.owner.name)
if: (github.event.pusher.name == github.event.repository.owner.name) && (github.ref == 'refs/heads/main')
needs: build
runs-on: ubuntu-latest

Expand Down
56 changes: 56 additions & 0 deletions src/buildjs/benchmark_diff.js
@@ -0,0 +1,56 @@

const fs = require('fs');

const fileA = JSON.parse(fs.readFileSync(process.argv[2]).toString()),
fileB = JSON.parse(fs.readFileSync(process.argv[3]).toString());





const diffs = fileB.results.map( (resultB) => {

const oldResult = fileA.results.find(
(resultA) => resultA.name === resultB.name,
);

if (!oldResult) {
return { name: resultB.name, diff: null };
}

const diff = ((resultB.ops - oldResult.ops) / oldResult.ops) * 100;

return {
name: resultB.name,
diff,
};

});



console.log(

diffs
.map(
({ name, diff }) =>
`${name}: ${diff.toFixed(2)}% ${
diff > 0 ? 'faster' : diff < 0 ? 'slower' : 'same'
}`,
)
.join('\n')

);



const changed = diffs.filter((item) => item.diff !== null),
average = changed.reduce((a, b) => a + b.diff, 0) / changed.length;



console.log(
`Average: ${average.toFixed(2)}% ${
average > 0 ? 'faster' : average < 0 ? 'slower' : 'same'
}`,
)

0 comments on commit 660d34f

Please sign in to comment.