PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: multiply vs. add

No Description

Run this test again Return to test menu

Result: Discarded

The test labeled "add" was the faster by 0.0077 seconds, (1.476% faster)

add 100%
multiply 98.524%

The add test took 0.5117 seconds.
The multiply test took 0.5194 seconds.

Nitty-Gritty

Each test case ran 20 random code order iterations consisting of 122,694 loops for a total of 2,453,880 runs.

  • Line execution difference (0.000003) milliseconds.
  • Avg difference (0.383) milliseconds per 122,694 loops.
  • Total difference 7.67 milliseconds for 2,453,880 loops

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

Code

The first test, "multiply", was:

$GLOBALS['dummy'] = 0;
for ($j = 0; $j < 100; $j++)
	$GLOBALS['dummy'] = $GLOBALS['dummy_int'] * 2;

The second test, "add", was:

$GLOBALS['dummy'] = 0;
for ($j = 0; $j < 100; $j++)
	$GLOBALS['dummy'] = $GLOBALS['dummy_int'] + $GLOBALS['dummy_int'];

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