PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: strpos/strtolower vs. stripos

No Description

Run this test again Return to test menu

Historical Results

Based on (4) saved test runs, The test labeled "strpos()/strtolower()" was (on average) the faster by 0.0307 seconds, (3.265% faster)

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

The strpos()/strtolower() test took 0.9087 seconds.
The stripos() test took 0.9393 seconds.

Nitty-Gritty

Each test case ran 20 random code order iterations consisting of 242,897 loops for a total of 4,857,940 runs.

  • Line execution difference (0.000006) milliseconds.
  • Avg difference (0.000) milliseconds per 242,897 loops.
  • Total difference 30.67 milliseconds for 4,857,940 loops

The iteration variablity for Code 1 was (0.0000) milliseconds and Code 2 was (0.0000) 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)