How to use the benchmark.filter 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 shama / grunt-benchmark / tasks / lib / benchmark.js View on Github external
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';
github hiddentao / gulp-bench / lib / benchmark.js View on Github external
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;
github hiddentao / gulp-bench / lib / benchmark.js View on Github external
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;
github shama / grunt-benchmark / tasks / lib / benchmark.js View on Github external
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;
github shama / grunt-benchmark / tasks / lib / benchmark.js View on Github external
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;
github hiddentao / gulp-bench / lib / benchmark.js View on Github external
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';
github lopatin / SnakeTron / old / public / libs / handlebars / bench / benchwarmer.js View on Github external
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 {
github ecomfe / zrender / benchmark / js / area.js View on Github external
suite.on('complete', function() {
        var benches = Benchmark.filter(suite.benchmarks, 'successful');
    });
});
github librenms / librenms / lib / handlebars / bench / util / benchwarmer.js View on Github external
winners: function(benches) {
    return Benchmark.filter(benches, 'fastest');
  },
  suite: function(suite, fn) {
github wycats / handlebars.js / bench / util / benchwarmer.js View on Github external
winners: function(benches) {
    return Benchmark.filter(benches, 'fastest');
  },
  suite: function(suite, fn) {