native sort vs underscore sortBy (v5)

Revision 5 of this benchmark created by austin on


Preparation HTML

<script src="http://documentcloud.github.com/underscore/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() {
    _.sortBy(labels, function(label) {
      return label.name;
    });
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
native sort
nativeSort();
ready
underscore sortBy
uSort();
ready

Revisions

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