PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: commas vs. concat on short strings

No Description

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

Result: Discarded

The test labeled "concat" was the faster by 0.0346 seconds, (6.159% faster)

concat 100%
commas 93.841%

The concat test took 0.5275 seconds.
The commas test took 0.5621 seconds.

Nitty-Gritty

Each test case ran 20 random code order iterations consisting of 135,628 loops for a total of 2,712,560 runs.

  • Line execution difference (0.000013) milliseconds.
  • Avg difference (1.731) milliseconds per 135,628 loops.
  • Total difference 34.62 milliseconds for 2,712,560 loops

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

Code

The first test, "commas", was:

echo $GLOBALS['x'], ' test ', $GLOBALS['y'], $GLOBALS['z'], ' test ';

The second test, "concat", was:

echo $GLOBALS['x'] . ' test ' . $GLOBALS['y'] . $GLOBALS['z'] . ' test ';

Running: Linux (x86_64:1 GB) PHP (7.2.15-1+ubuntu16.04.1+deb.sury.org+1)