How to use the benchmark.js.formatNumber 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
function printFastest(suite) {
  var formatNumber = Benchmark.formatNumber,
      fastest = suite.filter('fastest'),
      fastestHz = getHz(fastest[0]),
      slowest = suite.filter('slowest'),
      slowestHz = getHz(slowest[0]),
      aHz = getHz(suite[0]),
      bHz = getHz(suite[1]);
  if (fastest.length > 1) {
    console.log('It\'s too close to call.');
    aHz = bHz = slowestHz;
  } else {
    var percent = ((fastestHz / slowestHz) - 1) * 100;
    console.log('  ' + fastest[0].name + ' is ' +
        formatNumber(percent < 1 ? percent.toFixed(2) : Math.round(percent)) +
        '% faster.');
  }
}