Math.floor, parseInt and left shift (v7)

Revision 7 of this benchmark created on


Description

Measuring performance of removing the fraction off a float using three different methods, Math.floor(), parseInt() and a left shift (<<)

Setup

i = Math.random() * 10000;

Teardown


    i = undefined;
  

Test runner

Ready to run.

Testing in
TestOps/sec
Math.floor()
Math.floor(i);
ready
parseInt()
parseInt(i);
ready
left shift
i << 0;
ready
bitwise not
~~i;
ready
bitwise or
i | 0
ready

Revisions

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