How to use the benchmark.js.Suite function in benchmark

To help you get started, we’ve selected a few benchmark examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github paldepind / flyd / perf / perf.js View on Github external
Benchmark.Suite.options.onCycle = function(event) {
  console.log('  ' + event.target);
};

Benchmark.Suite.options.onComplete = function() {
  printFastest(this);
  suites.shift();
  if (suites.length) {
    suites[0].run({async: true});
  }
};

// ************************************************
// Benchmarks!

suites.push(Benchmark.Suite('dynamic dependencies').add('New', {
  setup: function() {
    var s = stream();
    stream(function() {
      return s();
    });
  },
  fn: function() {
    s(12);
  },
}).add('Old', {
  setup: function() {
    var s = oldStream();
    oldStream(function() {
      return s();
    });
  },
github paldepind / flyd / perf / perf.js View on Github external
setup: function() {
    var flyd = global.flyd;
    var stream = global.flyd.stream;
    function f(x) { return x; }
    var s1 = stream();
    var s2 = s1.map(f);
    var s3 = s2.map(f);
    var s4 = s3.map(f);
    var s5 = s4.map(f);
  },
  fn: function() {
    s1(12);
  },
}));

suites.push(Benchmark.Suite('dynamic dependency graph').add('New', {
  setup: function() {
    var s1 = stream();
    var s2 = stream(function() {
      s1(); s1();
    });
    var s3 = stream(function() {
      s1(); s2(); s1();
    });
    var s4 = stream(function() {
      s1(); s2(); s3(); s1(); s3();
    });
    stream(function() {
      s3(); s2(); s1(); s3(); s4();
    });
  },
  fn: function() {
github paldepind / flyd / perf / perf.js View on Github external
fn: function() {
    s(12);
  },
}).add('Old', {
  setup: function() {
    var s = oldStream();
    oldStream([s], function() {
      return s();
    });
  },
  fn: function() {
    s(12);
  },
}));

suites.push(Benchmark.Suite('map').add('First', {
  setup: function() {
    var flyd = global.flyd;
    var stream = global.flyd.stream;
    function f(x) { return x; }
    var s1 = stream();
    var s2 = s1.map(f);
    var s3 = s2.map(f);
    var s4 = s3.map(f);
    var s5 = s4.map(f);
  },
  fn: function() {
    s1(12);
  },
}).add('Second', {
  setup: function() {
    var flyd = global.flyd;
github paldepind / flyd / perf / perf.js View on Github external
fn: function() {
    s(12);
  },
}).add('Old', {
  setup: function() {
    var s = oldStream();
    oldStream(function() {
      return s();
    });
  },
  fn: function() {
    s(12);
  },
}));

suites.push(Benchmark.Suite('static dependencies').add('New', {
  setup: function() {
    var s = stream();
    stream([s], function() {
      return s();
    });
  },
  fn: function() {
    s(12);
  },
}).add('Old', {
  setup: function() {
    var s = oldStream();
    oldStream([s], function() {
      return s();
    });
  },