Rounding

Benchmark created on


Setup

function round(x){ 
 return x + (x > 0 ? 0.5 : -0.5) << 0;
}

Test runner

Ready to run.

Testing in
TestOps/sec
Math round

for (var i = 0; i <= 10000; i++) {
	Math.round(-16.937194719);
}
ready
Binary round


for (var i = 0; i <= 10000; i++) {
	round(-16.937194719);
}
ready
force
for (var i = 0; i <= 10000; i++) {
	parseInt(-16.937194719, 10);
}
ready

Revisions

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