PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: foreach key vs. no key

No Description

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

Result: Saved

The test labeled "without key" was the faster by 0.0027 seconds, (0.417% faster)

without key 100%
with key 99.583%

The without key test took 0.6442 seconds.
The with key test took 0.6469 seconds.


Each test case ran 20 random code order iterations consisting of 142,542 loops for a total of 2,850,840 runs.

  • Line execution difference (0.000001) milliseconds.
  • Avg difference (0.135) milliseconds per 142,542 loops.
  • Total difference 2.70 milliseconds for 2,850,840 loops

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


The first test, "with key", was:

foreach ($GLOBALS['dummy'] as $k => $v)
	$v + array(1);

The second test, "without key", was:

foreach ($GLOBALS['dummy'] as $v)
	$v + array(1);

Running: Linux (x86_64:1 GB) PHP (