Sugar vs Underscore!

JavaScript performance comparison

Test case created by Ceane Lamerez

Preparation code

<script src="https://underscorejs.org/underscore-min.js">
</script>
<script src="https://sugarjs.com/current/sugar-full.min.js">
</script>
<script>
  Benchmark.prototype.setup = function() {

    Arr = [0, 3, 1, 6, 0];

    applier = function(num) {
      return num * 2;
    }

    var o = function(arr, fn) {
        var lit = new Array(arr.length);
        for (var n = 0, lt = arr.length; n < lt; n++) {
          lit[n] = fn(arr[n]);
        }
        return lit;
        }
        
        
        
    map = o;

  }
</script>
    

Preparation code output

<script src="https://sugarjs.com/current/sugar-full.min.js"> </script> <script> Benchmark.prototype.setup = function() { Arr = [0, 3, 1, 6, 0]; applier = function(num) { return num * 2; } var o = function(arr, fn) { var lit = new Array(arr.length); for (var n = 0, lt = arr.length; n < lt; n++) { lit[n] = fn(arr[n]); } return lit; } map = o; } </script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
_.map
var result = _.map(Arr, applier)
pending…
Object.map
var result = Object.map(Arr, applier)
pending…
map()
var result = map(Arr, applier)
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL.

0 Comments