native sort vs underscore sortBy

JavaScript performance comparison

Revision 11 of this test case created

Preparation code

<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>

<script>
  var labels = [{name:"elliot"}, {name:"steve"}, {name:"dhruv"}, {name:"guiga"}, {name:"rajat"}, {name:"rob"}];
 
  function nativeSort() {
  labels.sort(function(a, b) {
   return a.name <= b.name ? -1 : 1;
  });
  }
 
  function uSort() {
  _(labels).sortBy(function(label) {
      return label.name;
  });
  }
</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
native sort
nativeSort();
pending…
underscore sortBy
uSort();
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