Math.round vs bitwise

Benchmark created by Paul Grenier on


Test runner

Ready to run.

Testing in
TestOps/sec
a
for (i = -5; i < 5; i += .01) {
  i > 0 ? i < ~~i + 0.5 ? ~~i : ~~i + 1 : i < ~~i - 0.5 ? ~~i - 1 : ~~i;
}
ready
b
for (i = -5; i < 5; i += .01) {
  Math.round(i);
}
ready

Revisions

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

  • Revision 1: published by Paul Grenier on