Result: DiscardedThe test labeled "foreach" was the faster by 0.1155 seconds, (8.662% faster)
The foreach test took 1.218 seconds.
The for test took 1.3335 seconds.
Each test case ran 20 random code order iterations consisting of 291,625 loops for a total of 5,832,500 runs.
- Line execution difference (0.000020) milliseconds.
- Avg difference (5.775) milliseconds per 291,625 loops.
- Total difference 115.51 milliseconds for 5,832,500 loops
The iteration variablity for Code 1 was (13.1800) milliseconds and Code 2 was (16.8197) milliseconds. The lower and the closer together there values are the more accurate the results are.
The first test, "foreach", was:
$range = range(0, 100); foreach ($range as $n) $GLOBALS['dummy'] = $n;
The second test, "for", was:
for ($n = 0; $n <= 100; $n++) $GLOBALS['dummy'] = $n;