Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
floor() vs trunc() vs bitwise hacks (~~, >> 0, etc) vs round()
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 136
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
<< 0
560K/s
Math.trunc()
557K/s
round()
547K/s
>> 0
545K/s
parseInt()
543K/s
| 0
528K/s
~~
524K/s
floor
477K/s
x - (x % 1)
464K/s
View exact numbers
Test name
Executions per second
✓
<< 0
560,085 Ops/sec
Math.trunc()
556,840 Ops/sec
round()
547,389 Ops/sec
>> 0
544,900 Ops/sec
parseInt()
543,337 Ops/sec
| 0
527,917 Ops/sec
~~
523,947 Ops/sec
floor
476,565 Ops/sec
x - (x % 1)
464,062 Ops/sec
Script Preparation code:
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;
Math.trunc()
y = Math.trunc(x);
x - (x % 1)
y = x - (x % 1);
parseInt()
y = parseInt(x);
round()
y = Math.round(x);