How to use the benchmark.invoke 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 posva / shapify / benchmark / index.js View on Github external
shapify(manyPropertiesArray, largeObject)
  }),
  new Benchmark('object:small', () => {
    shapify(fewPropertiesObject, largeObject)
  }),
  new Benchmark('object:medium', () => {
    shapify(somePropertiesObject, largeObject)
  }),
  new Benchmark('object:large', () => {
    shapify(manyPropertiesObject, largeObject)
  }),
]

// const variation = (a, b) => ((a - b) / b) * 100

Benchmark.invoke(benches, {
  name: 'run',
  onComplete ({ currentTarget: benches }) {
    benches.forEach(bench => {
      console.log(bench.toString())
      // console.log(bench.compare(loadedBench))
      // console.log(variation(bench.hz, loadedBench.hz))
      // console.log(JSON.stringify(bench))
    })
  },
})
github dvlsg / listed / perf / util / run.js View on Github external
function run(benchName, mappings) {

  console.log('');
  console.log(`Running \`${benchName}\` benchmarks...`);

  const benches = entries(mappings).map(([ name, fn ]) => {
    return new Benchmark({ name, fn, onComplete });
  });

  Benchmark.invoke(benches, {
    name: 'run',
    onCycle() {
      console.log(''); // make sure we get a newline
    },
    onComplete() {
      console.log(`Benchmarks for \`${benchName}\` completed!`);
    }
  });
}
github chaijs / type-detect / bench / index.js View on Github external
var filter = process.argv[2] || '';
Object.keys(fixtures).filter(function (key) {
  return key.indexOf(filter) !== -1;
}).forEach(function (test) {
  benches.push(new Benchmark(test, {
    fn: function () {
      typeDetect(fixtures[test]);
    },
    onCycle: function (event) {
      process.stdout.clearLine();
      process.stdout.cursorTo(0);
      process.stdout.write(event.target.toString());
    },
  }));
});
Benchmark.invoke(benches, {
  name: 'run',
  onCycle: function onCycle() {
    console.log('');
  },
  onComplete: function onComplete() {
    console.log('~Fin~');
  },
});
github chaijs / deep-eql / bench / index.js View on Github external
var kewlr = process.argv.indexOf('--kewlr') !== -1;
Object.keys(fixtures).filter(function (key) {
  return key.indexOf(filter) !== -1;
}).forEach(function (testName) {
  prepareBenchMark(fixtures[testName], testName + '         ');
  if (lodash) {
    prepareBenchMark(fixtures[testName], testName + ' (lodash)', lodashDeepEql);
  }
  if (nodeassert) {
    prepareBenchMark(fixtures[testName], testName + '   (node)', assertDeepeql);
  }
  if (kewlr) {
    prepareBenchMark(fixtures[testName], testName + '  (kewlr)', kewlrDeepeql);
  }
});
Benchmark.invoke(benches, {
  name: 'run',
  onCycle: function onCycle() {
    console.log('');
  },
  onComplete: function onComplete() {
    console.log('~Fin~');
  },
});
github wycats / handlebars.js / bench / util / benchwarmer.js View on Github external
bench: function(callback) {
    var self = this;

    this.printHeader('ops/msec', true);

    Benchmark.invoke(this.benchmarks, {
      name: 'run',
      onComplete: function() {
        self.scaleTimes();

        self.startLine('');

        print('\n');
        self.printHeader('scaled');
        _.each(self.scaled, function(value, name) {
          self.startLine(name);

          _.each(self.names, function(lang) {
            self.writeValue(value[lang] || '');
          });
        });
        print('\n');
github librenms / librenms / lib / handlebars / bench / util / benchwarmer.js View on Github external
bench: function(callback) {
    var self = this;

    this.printHeader('ops/msec', true);

    Benchmark.invoke(this.benchmarks, {
      name: "run",
      onComplete: function() {
        self.scaleTimes();

        self.startLine('');

        print('\n');
        self.printHeader('scaled');
        _.each(self.scaled, function(value, name) {
          self.startLine(name);

          _.each(self.names, function(lang) {
            self.writeValue(value[lang] || '');
          });
        });
        print('\n');
github lopatin / SnakeTron / old / public / libs / handlebars / bench / benchwarmer.js View on Github external
this.benchSize = 20;
    var horSize = 0;

    this.startLine("ops/msec");
    horSize = horSize + "ops/msec    ".length;
    for(i=0, l=names.length; i
github applitopia / immutable-sorted / resources / bench.js View on Github external
suite.add({
          fn: run.test,
          onStart: run.before,
          onCycle: run.before,
        });
      });

      suites.push(suite);
    });

    var onBenchComplete;
    var promise = new Promise(function(_resolve) {
      onBenchComplete = _resolve;
    });

    Benchmark.invoke(suites, 'run', { onComplete: onBenchComplete });

    return onBenchComplete;
  })
  .then(function() {