PHP Performance & Benchmarking: Testing String Variables

Though various development books have their own opinion of using strlen(), empty(), and isset() (most say don't use strlen to validate strings because of performance considerations), I have always wondered as to their factual validity now that PHP is in its fifth incantation. This server unfortunately does not use the latest stable version of PHP, PHP5, but rather the tried and tested PHP4 which is still in wide use.

Test Environment: Linux, Apache, PHP 5.2.17.

Test Setup: Code constructs listed below. For loops used to have enough iterations to make the script execution time calculatable. Each test was run 3000 times to get the average.

Comparisons

Using strlen():

$var="password";

for($i=0; $i<10000; $i++)
{
     if(strlen($var)>0)
     {
          //do something
     }
}

Using empty():

$var="password";

for($i=0; $i<10000; $i++)
{
     if(!empty($var))
     {
          //do something
     }
}

Using isset():

$var="password";

for($i=0; $i<10000; $i++)
{
     if(isset($var))
     {
          //do something
     }
}
Results
Test Avg Execution Time Comparative Graph - (longer is slower, 100% is the fastest time)
strlen() 8.80 ms Performance Graph 249%
empty() 4.49 ms Performance Graph 127%
isset() 3.54 ms Performance Graph 100%