Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Alternative to suite.filter('fastest') #87

Open
paldepind opened this issue Mar 4, 2015 · 0 comments
Open

Alternative to suite.filter('fastest') #87

paldepind opened this issue Mar 4, 2015 · 0 comments
Labels

Comments

@paldepind
Copy link
Contributor

I must say I find it quite odd how Benchmark.js handles finding the slowest and fastest benchmark by hard coding named callbacks into it's filter method.

What about automatically adding a fastest and slowest property here when a suite completes? They would have the same value as calling suite.filter('slowest'). Then, instead of something like this:

var fastest = suite.filter('fastest'),
    slowest = suite.filter('slowest'),
if (fastest.length > 1) {
  console.log('It\'s too close to call.');
} else {
  console.log(fastest[0].name + ' was fastest');
}

One could simply write this:

if (suite.fastest > 1) {
  console.log('It\'s too close to call.');
} else {
  console.log(suite.fastest[0].name + ' was fastest');
}

The current filter behavior could be kept for backward compatibility or it could be changed into a normal special case free filter?

What do you think? I can submit a pull request.

@jdalton jdalton added the change label Mar 4, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

2 participants