PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: list vs. [0]

These tests use an array with many values in it.

View test history (6) Run this test again Return to test menu

Result: Discarded

The test labeled "$array[0]" was the faster by 0.0157 seconds, (1.519% faster)

$array[0] 100%
list ($v) = 98.481%

The $array[0] test took 1.0191 seconds.
The list ($v) = test took 1.0348 seconds.


Each test case ran 20 random code order iterations consisting of 271,476 loops for a total of 5,429,520 runs.

  • Line execution difference (0.000003) milliseconds.
  • Avg difference (0.786) milliseconds per 271,476 loops.
  • Total difference 15.72 milliseconds for 5,429,520 loops

The iteration variablity for Code 1 was (2.9402) milliseconds and Code 2 was (1.6380) milliseconds. The lower and the closer together there values are the more accurate the results are.


The first test, "list ($v) =", was:

list ($v) = $GLOBALS['array'];

The second test, "$array[0]", was:

$v = $GLOBALS['array'][0];

Running: Linux (x86_64:1 GB) PHP (