Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
ParseInt vs conditional ~~ vs toFixed
ParseInt vs conditional ~~
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:126.0) Gecko/20100101 Firefox/126.0
Browser:
Firefox 126
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
ParseInt
429066080.0 Ops/sec
Bitwise invert2
431077280.0 Ops/sec
Bitwise conditional invert2
402293792.0 Ops/sec
Number.toFixed
12921972.0 Ops/sec
Script Preparation code:
var num = Math.random() * 2^32;
Tests:
ParseInt
parseInt(num);
Bitwise invert2
~~(num);
Bitwise conditional invert2
num > 2147483648 ? parseInt(num) : ~~(num);
Number.toFixed
num.toFixed(0);