Result: Discarded
The test labeled "ternary" was the faster by 0.0013 seconds, (0.155% faster)
The ternary test took 0.8409 seconds.
The if test took 0.8422 seconds.
Nitty-Gritty
Each test case ran 20 random code order iterations consisting of 222,097 loops for a total of 4,441,940 runs.
- Line execution difference (0.000000) milliseconds.
- Avg difference (0.065) milliseconds per 222,097 loops.
- Total difference 1.31 milliseconds for 4,441,940 loops
The iteration variablity for Code 1 was (3.9100) milliseconds and Code 2 was (3.5239) milliseconds. The lower and the closer together there values are the more accurate the results are.
Code
The first test, "if", was:
for ($i = 0; $i < 100; $i++) { if ($GLOBALS['dummy_true']) $GLOBALS['dummy'] = $GLOBALS['dummy_data']; else $GLOBALS['dummy'] = 6; }
The second test, "ternary", was:
for ($i = 0; $i < 100; $i++) $GLOBALS['dummy'] = $GLOBALS['dummy_true'] ? $GLOBALS['dummy_data'] : 6;