How to use the benchmark.Deferred 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 stefanpenner / promise_benchmarks / lib / main.js View on Github external
import Benchmark from 'benchmark';
import { implementations, lookupFeature } from './config/implementations';
import { group, groupEnd, log } from './polyfills';
import tests from './config/tests';

// JDD will be making this change for 2.0
Benchmark.Deferred.prototype.end = Benchmark.Deferred.prototype.resolve;
var distributions = [1, 2, 10, 50, 100, 1000, 10000];
var runs = [];

function runRest() {
  if (runs.length > 0) {
    runs.shift().run({
      async: true
    });
  }
}

export function run(customTestPatterns, customImplementations, customIterations) {
  tests.forEach(function(testObj) {
    var prefix = typeof process === 'object' ? './tests/' : '';
    var test = require(prefix + testObj).test;
    var fn = test.run;