PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: redefine constant

No Description

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

Result: Saved

The test labeled "!defined()" was the faster by 0.0044 seconds, (0.404% faster)

!defined() 100%
@define() 99.596%

The !defined() test took 1.0765 seconds.
The @define() test took 1.0809 seconds.


Each test case ran 20 random code order iterations consisting of 161,989 loops for a total of 3,239,780 runs.

  • Line execution difference (0.000001) milliseconds.
  • Avg difference (0.218) milliseconds per 161,989 loops.
  • Total difference 4.36 milliseconds for 3,239,780 loops

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


The first test, "@define()", was:

@define('CONSTANT', $GLOBALS['dummy']);

The second test, "!defined()", was:

if (!defined('CONSTANT'))
	define('CONSTANT', $GLOBALS['dummy']);

Running: Linux (x86_64:1 GB) PHP (