Result: Discarded
The test labeled "callback" was the faster by 0.0257 seconds, (2.654% faster)
The callback test took 0.9419 seconds.
The call_user_func() test took 0.9676 seconds.
Nitty-Gritty
Each test case ran 20 random code order iterations consisting of 257,082 loops for a total of 5,141,640 runs.
- Line execution difference (0.000005) milliseconds.
- Avg difference (1.284) milliseconds per 257,082 loops.
- Total difference 25.68 milliseconds for 5,141,640 loops
The iteration variablity for Code 1 was (3.7477) milliseconds and Code 2 was (5.1832) 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);