Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
my round vs toFixed
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Browser:
Chrome 121
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
test 1
3103977.5 Ops/sec
test 2
4285733.0 Ops/sec
Tests:
test 1
function round1( value, decimals) { let _decimals = decimals || 0; let roundedValue = parseInt(value * Math.pow(10,_decimals) + 0.5) / Math.pow(10,_decimals); if (roundedValue % 1 == 0) { roundedValue = parseInt(roundedValue); } return roundedValue; } return round1(4.55, 1);
test 2
function round2( value, precisione) { // formato 1,234.56 / F° return Number.parseFloat(value).toFixed( precisione); } return round2(4.55, 1);