PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: multiply vs. add

No Description

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

Result: Saved

The test labeled "multiply" was the faster by 0.0449 seconds, (4.614% faster)

multiply 100%
add 95.386%

The multiply test took 0.9282 seconds.
The add test took 0.9731 seconds.

Nitty-Gritty

Each test case ran 20 random code order iterations consisting of 230,266 loops for a total of 4,605,320 runs.

  • Line execution difference (0.000010) milliseconds.
  • Avg difference (2.245) milliseconds per 230,266 loops.
  • Total difference 44.90 milliseconds for 4,605,320 loops

The iteration variablity for Code 1 was (4.2249) milliseconds and Code 2 was (4.3551) 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.19-1+ubuntu16.04.1+deb.sury.org+1)