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

First bench is always slower. Need warmup? #22

Open
skratchdot opened this issue Jan 26, 2016 · 3 comments
Open

First bench is always slower. Need warmup? #22

skratchdot opened this issue Jan 26, 2016 · 3 comments

Comments

@skratchdot
Copy link

The first bench call always seems to be slower than other tests. I've included a simple test case below.

benchmark.js:

require('matcha');
[1, 2, 3, 4].forEach((num) => {
  suite(`Benchmark #${num}`, () => {
    bench('empty', () => {});
    bench('empty', () => {});
  });
});

command line:

npm install -g matcha
matcha ./benchmark.js

output:

                      Benchmark #1
     414,441,918 op/s » empty
     126,934,245 op/s » empty

                      Benchmark #2
     130,458,368 op/s » empty
     132,597,178 op/s » empty

                      Benchmark #3
     132,507,794 op/s » empty
     131,705,064 op/s » empty

                      Benchmark #4
     135,100,324 op/s » empty
     131,982,266 op/s » empty


  Suites:  4
  Benches: 8
  Elapsed: 10,695.31 ms

I would expect all the benchmarks to execute around the same amount of time.

Thanks for this library btw!

@EvanCarroll
Copy link

EvanCarroll commented Sep 27, 2016

@StevenLangbroek
Copy link

@EvanCarroll rather than bashing the project without any justification other than this bug (I followed your link, where you also don't give any other explanation), you could also help figure out what's causing this behavior.

@connor4312
Copy link

connor4312 commented Dec 22, 2019

As this issue (and other issues and PRs) have been open for years without update, I've created a newer rewrite of this tool. It uses the widely-used Benchmark.js, which includes warmup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants