Result: Discarded
The test labeled "preg_match()" was the faster by 0.0158 seconds, (2.907% faster)
The preg_match() test took 0.527 seconds.
The strpos() test took 0.5427 seconds.
Nitty-Gritty
Each test case ran 20 random code order iterations consisting of 149,130 loops for a total of 2,982,600 runs.
- Line execution difference (0.000005) milliseconds.
- Avg difference (0.789) milliseconds per 149,130 loops.
- Total difference 15.78 milliseconds for 2,982,600 loops
The iteration variablity for Code 1 was (0.9072) milliseconds and Code 2 was (1.2960) milliseconds. The lower and the closer together there values are the more accurate the results are.
Code
The first test, "preg_match()", was:
if (preg_match('~http://www\.google\.com/~', $GLOBALS['dummy']) != 0) $GLOBALS['dummy2'] = 42;
The second test, "strpos()", was:
if (strpos($GLOBALS['dummy'], 'http://wwww.google.com/') !== false) $GLOBALS['dummy2'] = 42;