Warning: Division by zero in /var/customers/webs/stc/benchmark/index.php on line 256 Test: if vs. ternary large string

PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: if vs. ternary large string

Run Again Test Menu

Result

Unfortunately, no history for this test is available.

Code

The first test, "if", was:

for ($i = 0; $i < 100; $i++)
{
	if ($GLOBALS['dummy_true'])
		$GLOBALS['dummy'] = $GLOBALS['dummy_data'];
	else
		$GLOBALS['dummy'] = 6;
}

The second test, "ternary", was:

for ($i = 0; $i < 100; $i++)
	$GLOBALS['dummy'] = $GLOBALS['dummy_true'] ? $GLOBALS['dummy_data'] : 6;

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