Result: Discarded
The test labeled "eval()" was the faster by 0.0424 seconds, (3.867% faster)
The eval() test took 1.0536 seconds.
The create_function() test took 1.0959 seconds.
Nitty-Gritty
Each test case ran 20 random code order iterations consisting of 292,642 loops for a total of 5,852,840 runs.
- Line execution difference (0.000007) milliseconds.
- Avg difference (2.119) milliseconds per 292,642 loops.
- Total difference 42.38 milliseconds for 5,852,840 loops
The iteration variablity for Code 1 was (1.5408) milliseconds and Code 2 was (3.0766) milliseconds. The lower and the closer together there values are the more accurate the results are.
Code
The first test, "eval()", was:
eval(' $x = 0; $x += 5; if ($x >= 5) $x = 0; $x; $x;');
The second test, "create_function()", was:
/* $GLOBALS['dummy'] = create_function('', ' $x = 0; $x += 5; if ($x >= 5) $x = 0; $x; $x;'); */ $GLOBALS['dummy']();