Result: Discarded
The test labeled "callback" was the faster by 0.0736 seconds, (9.806% faster)
The callback test took 0.6772 seconds.
The call_user_func() test took 0.7508 seconds.
Nitty-Gritty
Each test case ran 20 random code order iterations consisting of 158,950 loops for a total of 3,179,000 runs.
- Line execution difference (0.000023) milliseconds.
- Avg difference (3.681) milliseconds per 158,950 loops.
- Total difference 73.62 milliseconds for 3,179,000 loops
The iteration variablity for Code 1 was (4.1223) milliseconds and Code 2 was (6.5051) milliseconds. The lower and the closer together there values are the more accurate the results are.
Code
The first test, "callback", was:
/* function do_something($i) { for ($i = 0; $i < 20; $i++) $GLOBALS['dummy'] + $i; } */ $cb = 'do_something'; $cb(74);
The second test, "call_user_func()", was:
/* function do_something($i) { for ($i = 0; $i < 20; $i++) $GLOBALS['dummy'] + $i; } */ $cb = 'do_something'; call_user_func($cb, 74);