Float to int 3

Benchmark created on


Setup

var len = 100000;
  var a = new Array();
  for (var i=0; i<len; i++)
  {
      a[i] = i * 3.1415926;
  }

Test runner

Ready to run.

Testing in
TestOps/sec
Math.floor
for (var i=0; i<len; i+=4)
{
    a[i] = Math.floor(a[i]);
    a[i+1] = Math.floor(a[i+1]);
    a[i+2] = Math.floor(a[i+2]);
    a[i+3] = Math.floor(a[i+3]);
}
ready
Bitwise OR
for (var i=0; i<len; i+=4)
{
    a[i] = a[i] | 0;
    a[i+1] = a[i+1] | 0;
    a[i+2] = a[i+2] | 0;
    a[i+3] = a[i+3] | 0;
}
ready

Revisions

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