If Statement Vs Short-Circuit Test

Benchmark created by Tyler Williams on


Description

Performance test between if and short circuit operators.

Preparation HTML

<script>
function doSomething( value ) {
    return value + " string concat";
}
</script>

Setup

var i = 0;

Teardown


    i = 0;
  

Test runner

Ready to run.

Testing in
TestOps/sec
If Statement Test
if ( i++ % 2 == 0 )
    doSomething(i);
ready
Short Circuit Test
(i++ % 2 == 0) && doSomething(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 Tyler Williams on