Math.floor vs Math.round vs parseInt vs Bitwise (v100)

Revision 100 of this benchmark created on


Description

Rounding in all form possible

Preparation HTML

<script>
var num = Math.random() * 255;
function x(e) { return Math.floor(e)|0; }
</script>

Teardown


    num = Math.random() * 255;
  

Test runner

Ready to run.

Testing in
TestOps/sec
Math.floor
Math.floor(num);
ready
Math.round
Math.round(num);
ready
parseInt
parseInt(num,10);
ready
Bitwise |
num | 0;
ready
Bitwise
num >> 1;
ready
typed function
x(num);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.