Math.floor vs Math.round vs parseInt vs Bitwise

JavaScript performance comparison

Revision 116 of this test case created

Info

Rounding in all form possible

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var u = Date.now() / 1000;
    var f = Math.floor;
    var r = Math.round;
   
};
</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
f(u);
pending…
Math.round
r(u);
pending…
Bitwise |
u | 0;
pending…
Bitwise >>
u >> 0;
pending…
Bitwise ~~
~~u;
pending…
Bitwise <<
u << 0;
pending…
Bitwise >>>
u >>> 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