native sort vs underscore sortBy

JavaScript performance comparison

Revision 15 of this test case created

Preparation code

<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.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.sort(function(a, b) {
  return a.name <= b.name ? -1 : 1;
});
pending…
underscore sortBy
_(a).sortBy(function(label) {
  return label.name;
});
pending…
sort alpha
a.sort(function(a, b) {
  return a.name.localeCompare(b.name);
});
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