PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: === null vs. is_null

No Description

Run this test again Return to test menu

Result: Discarded

The test labeled "is_null()" was the faster by 0.0084 seconds, (0.837% faster)

is_null() 100%
=== null 99.163%

The is_null() test took 0.9941 seconds.
The === null test took 1.0025 seconds.

Nitty-Gritty

Each test case ran 20 random code order iterations consisting of 273,645 loops for a total of 5,472,900 runs.

  • Line execution difference (0.000002) milliseconds.
  • Avg difference (0.419) milliseconds per 273,645 loops.
  • Total difference 8.39 milliseconds for 5,472,900 loops

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

Code

The first test, "=== null", was:

for ($j = 0; $j < 100; $j++)
{
	$GLOBALS['dummy3'] = $GLOBALS['dummy1'] === null;
	$GLOBALS['dummy3'] += $GLOBALS['dummy2'] === null;
}

The second test, "is_null()", was:

for ($j = 0; $j < 100; $j++)
{
	$GLOBALS['dummy3'] = is_null($GLOBALS['dummy1']);
	$GLOBALS['dummy3'] += is_null($GLOBALS['dummy2']);
}

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