Sugar vs Underscore!

JavaScript performance comparison

Test case created by Ceane Lamerez

Info

What's faster?

I really like Sugar.JS however Underscore.js is very popular and seems to have stronger following. Now it's time to see which is faster!

Preparation code

<script src="//underscorejs.org/underscore-min.js">
</script>
<script src="//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

Test runner

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

Java applet disabled.

Testing in unknown unknown
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. Here’s a list of current revisions for this page:

0 comments

Add a comment