Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparison to previous results #7

Open
StoneCypher opened this issue Oct 22, 2019 · 5 comments
Open

Comparison to previous results #7

StoneCypher opened this issue Oct 22, 2019 · 5 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@StoneCypher
Copy link

Does benny have any mechanism to compare this benchmark to my last round, so that I can say something of the form "in this release the library is on average 2% faster" ?

@caderek caderek added the enhancement New feature or request label Oct 22, 2019
@caderek caderek self-assigned this Oct 22, 2019
@caderek
Copy link
Owner

caderek commented Oct 22, 2019

I'm planning to add this, but it is not ready yet. In the meanwhile you can use this script to diff two versions of the JSON results:

/* diff.js */
const fs = require('fs')

const fileA = JSON.parse(fs.readFileSync(process.argv[2]).toString())
const 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)
const average = changed.reduce((a, b) => a + b.diff, 0) / changed.length

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

Usage:

node diff.js path/to/oldBench.json path/to/newBench.json

Example output:

Case one: 0.22% faster
Other case: -2.50% slower
Average: -1.14% slower

https://gist.github.com/caderek/93394875730cc1b9f6750e527e7b9fcf

Hope this will help!

I will leave this issue open as a feature request.

@caderek caderek added the good first issue Good for newcomers label Oct 22, 2019
@StoneCypher
Copy link
Author

Wow I just now saw this

Ya this is actually pretty great

@luiscarbonell
Copy link

Any way to show results in a line graph? i.e. store to a .json and track historic

@StoneCypher
Copy link
Author

Please don't paint issues. Make a new one instead

@LetsMelon
Copy link

@caderek What's the current status for this enhancement?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants