Test: list vs. [0]
These tests use an array with many values in it.
Run this test again Return to test menuResult: Discarded
The test labeled "$array[0]" was the faster by 0.0102 seconds, (1.945% faster)
The $array[0] test took 0.5142 seconds.
The list ($v) = test took 0.5244 seconds.
Nitty-Gritty
Each test case ran 20 random code order iterations consisting of 129,055 loops for a total of 2,581,100 runs.
- Line execution difference (0.000004) milliseconds.
- Avg difference (0.510) milliseconds per 129,055 loops.
- Total difference 10.20 milliseconds for 2,581,100 loops
The iteration variablity for Code 1 was (5.0531) milliseconds and Code 2 was (4.8990) milliseconds. The lower and the closer together there values are the more accurate the results are.
Code
The first test, "list ($v) =", was:
list ($v) = $GLOBALS['array'];
The second test, "$array[0]", was:
$v = $GLOBALS['array'][0];