Giter Club home page Giter Club logo

uubench's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

moos lmnbeyond

uubench's Issues

numbers off?

hey, im doing

    var persec = 1000 / stats.elapsed
      , ops = stats.iterations * persec;

where i'd expect setTimeout(next, 1000) to give 1 op/s, however it seems to be around 10 etc

The implementation of "minimum runtime" is inaccurate

@akdubya

According to README.md:

var suite = new uubench.Suite({
  min: 1000, // each benchmark should run for at least 1000ms
  ...
 });

I looked up the source code:

function adaptive() {
    if (--pend === 0) {
      var elapsed = new Date() - start;
      if (elapsed < min) {
        self.run(iter*2);
      } else {
        self.callback({iterations: iter, elapsed: elapsed});//since "start" is reset whenever "Bench.run" is invoked, then the stats is inaccurate
      }
    }
  }

The key point is that the value of "start" is reset whenever "Bench.run" is invoked:

Bench.prototype.run = function(iter) {
  var self = this, fn = self.test,
      checkfn = self.options.type === "adaptive" ? adaptive : fixed,
      i = iter, pend = i,
      min = self.options.min, start;

  if (self.loop) {
    pend = 1;
    start = new Date();  //start is reset
    fn(checkfn, i);
  } else {
    start = new Date();   //start is reset
    while (i--) {
      fn(checkfn);
    }
  }

So the stats is inaccurate, I think the value of "start" should be set at the very begining of "Suite.prototype.runOne", and don't reset it in Bench.run:

Suite.prototype.runOne = function(idx) {
  var self = this;
  setTimeout(function() {
    self.tests[idx].start = new Date().getTime();  //set "start" value here, so "min" is the accumulative runtime for benchmark
    self.tests[idx].run(self.options.iterations);
  }, self.options.delay);
}

I'm very curious to this issue. Please give me a hint!

Finally, many thanks to you for your great work and the sharing :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.