Historical ResultsBased on (2) saved test runs, The test labeled "key" was (on average) the faster by 0.0101 seconds, (1.019% faster)
The key test took 0.9846 seconds.
The in_array() test took 0.9947 seconds.
Each test case ran 20 random code order iterations consisting of 248,745 loops for a total of 4,974,900 runs.
- Line execution difference (0.000002) milliseconds.
- Avg difference (0.000) milliseconds per 248,745 loops.
- Total difference 10.14 milliseconds for 4,974,900 loops
The iteration variablity for Code 1 was (0.0000) milliseconds and Code 2 was (0.0000) milliseconds. The lower and the closer together there values are the more accurate the results are.
The first test, "in_array()", was:
for ($i = 0; $i < 10; $i++) $GLOBALS['dummy2'] = in_array($i * 20, $GLOBALS['dummy']);
The second test, "key", was:
for ($i = 0; $i < 10; $i++) $GLOBALS['dummy2'] = isset($GLOBALS['dummy'][$i * 20]);