Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.on('complete', function() {
// Time is measured in microseconds so 1000 = 1ms
var fastestMean = _.first(this.filter('fastest')).stats.mean * 1000;
var slowestMean = _.first(this.filter('slowest')).stats.mean * 1000;
var mean = {
fastest: Benchmark.formatNumber(fastestMean < 1 ? fastestMean.toFixed(2) : Math.round(fastestMean)),
slowest: Benchmark.formatNumber(slowestMean < 1 ? slowestMean.toFixed(2) : Math.round(slowestMean))
};
console.log('Fastest is ' + this.filter('fastest').map('name') + ' with an average of: ' + mean.fastest + 'ms');
console.log('Slowest is ' + this.filter('slowest').map('name') + ' with an average of: ' + mean.slowest + 'ms');
})
.run();
.on('complete', function() {
// Time is measured in microseconds so 1000 = 1ms
var fastestMean = _.first(this.filter('fastest')).stats.mean * 1000;
var slowestMean = _.first(this.filter('slowest')).stats.mean * 1000;
var mean = {
fastest: Benchmark.formatNumber(fastestMean < 1 ? fastestMean.toFixed(2) : Math.round(fastestMean)),
slowest: Benchmark.formatNumber(slowestMean < 1 ? slowestMean.toFixed(2) : Math.round(slowestMean))
};
console.log('Fastest is ' + this.filter('fastest').map('name') + ' with an average of: ' + mean.fastest + 'ms');
console.log('Slowest is ' + this.filter('slowest').map('name') + ' with an average of: ' + mean.slowest + 'ms');
return done(undefined, this);
})
.run();
.on('complete', function() {
// Time is measured in microseconds so 1000 = 1ms
var fastestMean = _.first(this.filter('fastest')).stats.mean * 1000;
var slowestMean = _.first(this.filter('slowest')).stats.mean * 1000;
var mean = {
fastest: Benchmark.formatNumber(fastestMean < 1 ? fastestMean.toFixed(2) : Math.round(fastestMean)),
slowest: Benchmark.formatNumber(slowestMean < 1 ? slowestMean.toFixed(2) : Math.round(slowestMean))
};
console.log('Fastest is ' + this.filter('fastest').map('name') + ' with an average of: ' + mean.fastest + 'ms');
console.log('Slowest is ' + this.filter('slowest').map('name') + ' with an average of: ' + mean.slowest + 'ms');
})
.run();
var pm = '\xb1',
mu = '\xb5'
size = this.stats.sample.length;
if(this.error){
console.log("not ok " + event.currentTarget.id + " " + this.name);
// show error
console.log(" ---");
console.log(" error: " + this.error);
console.log(" ...");
fail++;
} else {
var gflops = this.hz * 2 * M * N * K / 1e9;
var info = Benchmark.formatNumber(gflops.toFixed(3)) + ' GFlops/sec ' +
' ' + pm + this.stats.rme.toFixed(2) + '% ' +
' n = ' + size +
' ' + mu + " = " + (this.stats.mean * 1000).toFixed(0) + 'ms';
console.log("ok " + event.currentTarget.id + " " + this.name);
console.log("# " + info);
pass++;
}
});
// Calculate how much faster the fastest functions were than the second fastest
var timesFaster = (fastest.hz/secondFastest.hz);
var isAre = 'test is';
if (fastestTests.length > 1) {
isAre = 'tests are';
}
var message = "Fastest " + isAre + ' ' + [fastestNames].join(' and ' );
var decimalPlaces = timesFaster < 2 ? 2 : 1;
// Only bother if there wasn't a tie
if (fastestTests.length !== tests.length) {
message += ' at ' + Benchmark.formatNumber(timesFaster.toFixed(decimalPlaces))+'x faster than ' + secondFastestNames.join(' and ');
}
_logInfo(message);
}
});
}
options.onComplete = function (bench) {
const target = bench.target
const hz = target.hz
const stats = target.stats
const rme = stats.rme
const samples = stats.sample.length
const msg = sprintf(' %25s: %13s ops/sec \xb1 %s%% (%3d run(s) sampled)',
target.name,
Benchmark.formatNumber(hz.toFixed(2)),
rme.toFixed(2),
samples)
console.log(msg)
}
options.onError = function (bench) {
options.onComplete = function (bench) {
const target = bench.target
const hz = target.hz
const stats = target.stats
const rme = stats.rme
const samples = stats.sample.length
const msg = sprintf(' %25s: %13s ops/sec \xb1 %s%% (%3d run(s) sampled)',
target.name,
Benchmark.formatNumber(hz.toFixed(2)),
rme.toFixed(2),
samples)
console.log(msg)
}
options.onError = function (bench) {
function prettyNum(val, pad) {
var fast = 4500;
var slow = 900;
var color = 'yellow';
if (val >= fast) color = 'green';
if (val <= slow) color = 'red';
return rightPad(benchmark.formatNumber(val)[color], pad);
}
function toTableStr(par) {
if (par.error) {
return 'ERROR';
} else {
return Benchmark.formatNumber(par.hz.toFixed(par.hz < 100 ? 2 : 0)) + ' ops/sec';
}
}
stats.errors[testName] = 'baseline failed: ' + baseline;
} else if (typeof frequency === 'number') {
hz[testName] = ((frequency / baseline) * 100).toFixed(5) + '% (' + Benchmark.formatNumber(frequency.toFixed(0)) + ' ops/sec)';
stats.relative[testName] = frequency / baseline;
stats.raw[testName] = frequency;
} else {
stats.errors[testName] = frequency;
}
});
if (!supportsES6) {
hz.es6 = 'unsupported';
}
log(testName + ' - Baseline ' + (typeof baseline === 'number' ? 'is ' + Benchmark.formatNumber(baseline.toFixed(0)) + ' ops/sec' : 'errored ' + baseline));
log('Percentage of baseline: ' + JSON.stringify(hz, undefined, 2));
log('Duration: ' + JSON.stringify(elapsed, undefined, 2));
log('Count: ' + JSON.stringify(count, undefined, 2));
if (options.testDone) {
options.testDone();
}
done();
});
},