for or while odd (v2)

Revision 2 of this benchmark created by mpalpha on


Test runner

Ready to run.

Testing in
TestOps/sec
reverse while modulus
var i = 100;
while (i--, !! i) {
  return (i % 2) && i;
}
ready
for add
for (i = 1; i < 100; i + 2) {
  return i;
}
ready
recursion
function is_odd(i) {
  var n = i / 2
  if (i != 0 && (n === +n && n !== (n | 0))) {
    return i;
  }
  i-- && is_odd(i);
}
is_odd(100);
ready

Revisions

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

  • Revision 1: published by mpalpha on
  • Revision 2: published by mpalpha on