native sort vs underscore sortBy

JavaScript performance comparison

Revision 9 of this test case created

Preparation code

<script src="http://documentcloud.github.com/underscore/underscore-min.js">
</script>
<script>
  var a = [{
    name: "elliot"
  }, {
    name: "steve"
  }, {
    name: "dhruv"
  }, {
    name: "guiga"
  }, {
    name: "rajat"
  }, {
    name: "rob"
  }]
</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
a.concat().sort(function(a, b) {
  return a.name <= b.name ? -1 : 1;
});
pending…
underscore sortBy
_(a.concat()).sortBy(function(label) {
  return label.name;
})
pending…
underscore sortBy field
_.sortBy(a.concat(), "name")
pending…
underscore sortBy identity
_.sortBy(a.concat(), _.identity)
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