Script Preparation code:
AخA
 
var x = Math.random() * 100000000;
var y;
Tests:
  • floor

     
    y = Math.floor(x);
  • ~~

     
    y = ~~x;
  • >> 0

     
    y = x >> 0;
  • | 0

     
    y = x | 0;
  • << 0

     
    y = x << 0;
  • & 0xFFFFFFFFFFFF

     
    y = x & 0xFFFFFFFFFFFF;
  • ^ 0x000000000000

     
    y = x ^ 0x000000000000;
  • Math.trunc()

     
    y = Math.trunc(x);
  • x - (x % 1)

     
    y = x - (x % 1);
  • parseInt()

     
    y = parseInt(x)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    floor
    ~~
    >> 0
    | 0
    << 0
    & 0xFFFFFFFFFFFF
    ^ 0x000000000000
    Math.trunc()
    x - (x % 1)
    parseInt()

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 21 hours ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 OPR/117.0.0.0 (Edition std-1)
Opera 117 on Windows
View result in a separate tab
Test name Executions per second
floor 15543850.0 Ops/sec
~~ 15639064.0 Ops/sec
>> 0 15485411.0 Ops/sec
| 0 15633187.0 Ops/sec
<< 0 15578008.0 Ops/sec
& 0xFFFFFFFFFFFF 15704023.0 Ops/sec
^ 0x000000000000 15565799.0 Ops/sec
Math.trunc() 15451303.0 Ops/sec
x - (x % 1) 13428259.0 Ops/sec
parseInt() 15511181.0 Ops/sec