str vs int vs float

JavaScript performance comparison

Revision 2 of this test case created by tomByrer

Info

The last test had STRings & NUMbers mis-labeled. I also added new variables to check against, as well as a false test case. Might as well add Integer vs Float to the mix (though numbers in JS are all 64bit floats, I want to see if decimal places do anything).

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var sA = '123',
        sB = '123',
        sC = '456';
    var iA = 123,
        iB = 123,
        iC = 456;
    var fA = 0.12,
        fB = 0.12,
        fC = 0.34;
};
</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
str
if (sA === sB) return true;
if (sA === sC) return true;
pending…
int
if (iA === iB) return true;
if (iA === iC) return true;
pending…
flt
if (fA === fB) return true;
if (fA === fC) return true;
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