Test: array_walk vs. array_walk_recursive
Does the recursive variant have any benefit over rolling our own recursion?
Run this test again Return to test menuHistorical Results
Based on (17) saved test runs, The test labeled "array_walk()" was (on average) the faster by 0.0186 seconds, (2.608% faster)
The array_walk() test took 0.6948 seconds.
The array_walk_recursive() test took 0.7134 seconds.
Nitty-Gritty
Each test case ran 20 random code order iterations consisting of 179,169 loops for a total of 3,583,375 runs.
- Line execution difference (0.000005) milliseconds.
- Avg difference (0.000) milliseconds per 179,169 loops.
- Total difference 18.60 milliseconds for 3,583,375 loops
The iteration variablity for Code 1 was (0.0000) milliseconds and Code 2 was (0.0000) milliseconds. The lower and the closer together there values are the more accurate the results are.
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');