ternary operator vs. if statement (v14)

Revision 14 of this benchmark created by Moisés Baddini on


Setup

var x = false
  var sum = 0

Test runner

Ready to run.

Testing in
TestOps/sec
ternary operator
sum += (x ? 0 : 1)
x = !x
ready
if statement
if (x)
  sum += 0
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.