PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: strpos/strtolower vs. stripos

No Description

View test history (4) Run this test again Return to test menu

Result: Discarded

The test labeled "stripos()" was the faster by 0.0002 seconds, (0.023% faster)

stripos() 100%
strpos()/strtolower() 99.977%

The stripos() test took 0.8261 seconds.
The strpos()/strtolower() test took 0.8263 seconds.

Nitty-Gritty

Each test case ran 20 random code order iterations consisting of 220,694 loops for a total of 4,413,880 runs.

  • Line execution difference (0.000000) milliseconds.
  • Avg difference (0.010) milliseconds per 220,694 loops.
  • Total difference 0.19 milliseconds for 4,413,880 loops

The iteration variablity for Code 1 was (1.1485) milliseconds and Code 2 was (0.8933) milliseconds. The lower and the closer together there values are the more accurate the results are.

Code

The first test, "strpos()/strtolower()", was:

for ($j = 0; $j < 40; $j++)
	$GLOBALS['dummy'] = strpos(strtolower($GLOBALS['dummy_match']), '9abcd') === 5;
for ($j = 0; $j < 40; $j++)
	$GLOBALS['dummy'] = strpos(strtolower($GLOBALS['dummy_fail']), '9abcd') === 5;

The second test, "stripos()", was:

for ($j = 0; $j < 40; $j++)
	$GLOBALS['dummy'] = stripos($GLOBALS['dummy_match'], '9abcd') === 5;
for ($j = 0; $j < 40; $j++)
	$GLOBALS['dummy'] = stripos($GLOBALS['dummy_fail'], '9abcd') === 5;

Running: Linux (x86_64:1 GB) PHP (7.2.19-1+ubuntu16.04.1+deb.sury.org+1)