math round vs tilda

Benchmark created on


Setup

function roundTilda(x) {
      return~~ (x + 0.5);
    }
    
    var roundMath = Math.round;
    var x = 0.345;

Test runner

Ready to run.

Testing in
TestOps/sec
Math.round
Math.round(x);
x += 0.5;
ready
roundMath
roundMath(x);
x += 0.5;
ready
tilda
roundTilda(x);
x += 0.5;
ready

Revisions

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