ternary operator vs. if statement (v13)

Revision 13 of this benchmark created on


Setup

var x;
  var sum = 0;

Test runner

Ready to run.

Testing in
TestOps/sec
ternary operator (true case)
sum += (x === true ? 0 : 1);
x = ! x;
ready
if statement (true case)
if (x === true)
{
  sum += 0;
  x = false;
}
else
{
  sum += 1;
  x = ! x;
}
ready

Revisions

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