Warning: Division by zero in /var/customers/webs/stc/benchmark/index.php on line 256 Test: array_walk vs. array_walk_recursive

PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: array_walk() vs. array_walk_recursive()

Does the recursive variant have any benefit over rolling our own recursion?

Run Again Test Menu

Result

Unfortunately, no history for this test is available.

Code

The first test, "array_walk()", was:

/*
function foo_manual(&$v)
{
	if (is_array($v))
		array_walk($v, 'foo_manual');
	else
		$v++;
}
*/

array_walk($GLOBALS['dummy'], 'foo_manual');

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

/*
function foo_auto(&$v)
{
	$v++;
}
*/

array_walk_recursive($GLOBALS['dummy'], 'foo_auto');

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