PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: else if vs. elseif

No Description

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

Result: Discarded

The test labeled "else if" was the faster by 0.0055 seconds, (0.567% faster)

else if 100%
elseif 99.433%

The else if test took 0.9671 seconds.
The elseif test took 0.9726 seconds.


Each test case ran 20 random code order iterations consisting of 259,227 loops for a total of 5,184,540 runs.

  • Line execution difference (0.000001) milliseconds.
  • Avg difference (0.276) milliseconds per 259,227 loops.
  • Total difference 5.51 milliseconds for 5,184,540 loops

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


The first test, "else if", was:

if ($GLOBALS['dummy_false'])
	$GLOBALS['dummy_false'] = true;
else if ($GLOBALS['dummy_true'])
	$GLOBALS['dummy_true'] = true;

The second test, "elseif", was:

if ($GLOBALS['dummy_false'])
	$GLOBALS['dummy_false'] = true;
elseif ($GLOBALS['dummy_true'])
	$GLOBALS['dummy_true'] = true;

Running: Linux (x86_64:1 GB) PHP (