Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (tests.length <= 1) {
return;
}
// Get the testest test
var fastest = fastestTests[0];
// Extract their names
var fastestNames = Benchmark.pluck(fastestTests, 'name');
// Get the second fastest
var secondFastestTests;
var secondFastest;
var secondFastestNames;
if (fastestTests.length > 1) {
secondFastestTests = Benchmark.filter(fastestTests.slice(1), 'fastest');
secondFastest = secondFastestTests[0];
secondFastestNames = Benchmark.pluck(secondFastestTests, 'name');
}
else {
var slowerTests = grunt.util._.reject(tests, function(obj) {
return ~fastestNames.indexOf(obj.name);
});
secondFastestTests = Benchmark.filter(slowerTests, 'fastest').reverse();
secondFastest = secondFastestTests[0];
secondFastestNames = Benchmark.pluck(secondFastestTests, 'name');
}
// Calculate how much faster the fastest functions were than the second fastest
var timesFaster = (fastest.hz/secondFastest.hz);
var isAre = 'test is';
var fastestNames = Benchmark.pluck(fastestTests, 'name');
// Get the second fastest
var secondFastestTests;
var secondFastest;
var secondFastestNames;
if (fastestTests.length > 1) {
secondFastestTests = Benchmark.filter(fastestTests.slice(1), 'fastest');
secondFastest = secondFastestTests[0];
secondFastestNames = Benchmark.pluck(secondFastestTests, 'name');
}
else {
var slowerTests = _.reject(tests, function(obj) {
return ~fastestNames.indexOf(obj.name);
});
secondFastestTests = Benchmark.filter(slowerTests, 'fastest').reverse();
secondFastest = secondFastestTests[0];
secondFastestNames = Benchmark.pluck(secondFastestTests, 'name');
}
// 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;
runnable.on('complete', function() {
if (!this.error) {
// Get the tests
var tests = _.sortBy(this, 'hz');
// Get the top fastest tests
var fastestTests = Benchmark.filter(this, 'fastest');
// Only bother if more than one test
if (tests.length <= 1) {
return;
}
// Get the testest test
var fastest = fastestTests[0];
// Extract their names
var fastestNames = Benchmark.pluck(fastestTests, 'name');
// Get the second fastest
var secondFastestTests;
var secondFastest;
var secondFastestNames;
var fastestNames = Benchmark.pluck(fastestTests, 'name');
// Get the second fastest
var secondFastestTests;
var secondFastest;
var secondFastestNames;
if (fastestTests.length > 1) {
secondFastestTests = Benchmark.filter(fastestTests.slice(1), 'fastest');
secondFastest = secondFastestTests[0];
secondFastestNames = Benchmark.pluck(secondFastestTests, 'name');
}
else {
var slowerTests = grunt.util._.reject(tests, function(obj) {
return ~fastestNames.indexOf(obj.name);
});
secondFastestTests = Benchmark.filter(slowerTests, 'fastest').reverse();
secondFastest = secondFastestTests[0];
secondFastestNames = Benchmark.pluck(secondFastestTests, 'name');
}
// 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 + ' ' + grunt.log.wordlist([fastestNames], { separator: ' and ' });
// Give increases color based on size of increase
var increaseColor = false;
runnable.on('complete', function() {
if (!this.error) {
// Get the tests
var tests = grunt.util._.sortBy(this, 'hz');
// Get the top fastest tests
var fastestTests = Benchmark.filter(this, 'fastest');
// Only bother if more than one test
if (tests.length <= 1) {
return;
}
// Get the testest test
var fastest = fastestTests[0];
// Extract their names
var fastestNames = Benchmark.pluck(fastestTests, 'name');
// Get the second fastest
var secondFastestTests;
var secondFastest;
var secondFastestNames;
if (tests.length <= 1) {
return;
}
// Get the testest test
var fastest = fastestTests[0];
// Extract their names
var fastestNames = Benchmark.pluck(fastestTests, 'name');
// Get the second fastest
var secondFastestTests;
var secondFastest;
var secondFastestNames;
if (fastestTests.length > 1) {
secondFastestTests = Benchmark.filter(fastestTests.slice(1), 'fastest');
secondFastest = secondFastestTests[0];
secondFastestNames = Benchmark.pluck(secondFastestTests, 'name');
}
else {
var slowerTests = _.reject(tests, function(obj) {
return ~fastestNames.indexOf(obj.name);
});
secondFastestTests = Benchmark.filter(slowerTests, 'fastest').reverse();
secondFastest = secondFastestTests[0];
secondFastestNames = Benchmark.pluck(secondFastestTests, 'name');
}
// Calculate how much faster the fastest functions were than the second fastest
var timesFaster = (fastest.hz/secondFastest.hz);
var isAre = 'test is';
winners: function(benches) {
var result = Benchmark.filter(benches, function(bench) { return bench.cycles; });
if (result.length > 1) {
result.sort(function(a, b) { return b.compare(a); });
first = result[0];
last = result[result.length - 1];
var winners = [];
Benchmark.each(result, function(bench) {
if (bench.compare(first) === 0) {
winners.push(bench);
}
});
return winners;
} else {
suite.on('complete', function() {
var benches = Benchmark.filter(suite.benchmarks, 'successful');
});
});
winners: function(benches) {
return Benchmark.filter(benches, 'fastest');
},
suite: function(suite, fn) {
winners: function(benches) {
return Benchmark.filter(benches, 'fastest');
},
suite: function(suite, fn) {