+9 vs parseInt(9)

JavaScript performance comparison

Revision 2 of this test case created by benekastah

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var int = '9'
    var float = '9.87654'
    var num
};
</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
parseInt
num = parseInt(int)
pending…
castInt
num = +int
pending…
parseFloat
num = parseFloat(float)
pending…
castFloat
num = +float
pending…
NumberInt
num = Number(int)
pending…
NumberFloat
num = Number(float)
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