Math.floor vs Math.round vs parseInt

JavaScript performance comparison

Revision 23 of this test case created by Michael Programs

Info

Using radix

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
     function toInt(value) {
         return parseInt(value, 10);
    }
};
</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
Math.floor
Math.floor(89.938 / 293.3);
Math.floor(83784 / 9289.2);
Math.floor(7 / 60);
pending…
Math.round
Math.round(89.938 / 293.3);
Math.round(83784 / 9289.2);
Math.round(7 / 60);
pending…
parseInt
parseInt(89.938 / 293.3, 10);
parseInt(83784 / 9289.2, 10);
parseInt(7 / 60, 10);
pending…
parseInt in function
toInt(89.938 / 293.3);
toInt(83784 / 9289.2);
toInt(7 / 60);
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