$.inArray, _.indexOf, and a simple loop

JavaScript performance comparison

Revision 33 of this test case created

Preparation code

<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js">
</script>
<script>
Benchmark.prototype.setup = function() {
    var r;
    var array = ['2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','J','K','L','M','N','P','Q','R','S','T','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
   
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
_.indexOf isSorted
r = _.indexOf(array, 'p', true) > -1;
pending…
_.indexOf
r = _.indexOf(array, 'p') > -1;
pending…
[].indexOf
r = array.indexOf('p') >= 0;
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