belt vs underscore indexof

JavaScript performance comparison

Revision 2 of this test case created by John Cockrell

Preparation code

<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.3/underscore-min.js"></script>
<script src="http://sjhcockrell.s3.amazonaws.com/downloads/belt.js"></script>
<script>
Benchmark.prototype.setup = function() {
    var a = [];
   
    for (var i = 0; i < 1000; i += 1) {
        a[i] = i;
    }
};
</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
Belt.indexOf
B.indexOf(a, 500);
pending…
Underscore.contains
_.contains(a, 500);
pending…
B.complexIndexOf
B.complexIndexOf(a, 500);
pending…
Array.indexOf
a.indexOf(500);
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