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: Discarded

The test labeled "multiply" was the faster by 0.0259 seconds, (2.563% faster)

multiply 100%
add 97.437%

The multiply test took 0.9862 seconds.
The add test took 1.0122 seconds.

Nitty-Gritty

Each test case ran 20 random code order iterations consisting of 232,435 loops for a total of 4,648,700 runs.

  • Line execution difference (0.000006) milliseconds.
  • Avg difference (1.297) milliseconds per 232,435 loops.
  • Total difference 25.94 milliseconds for 4,648,700 loops

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