- microtime: documentation ( source)
- rand: documentation ( source)
<?php
$shortstring='hello';
$longstring='long';
for($run=0;$run<1000;$run++)
$longstring.='dsfsda'.rand(1000,2000);
$time=microtime(true);
for($run=0;$run<1000;$run++)
$temp=strlen($shortstring);
$time=microtime(true)-$time;
echo "strlen on short string took $time seconds\n";
$time=microtime(true);
for($run=0;$run<1000;$run++)
$temp2=strlen($longstring);
$time=microtime(true)-$time;
echo "strlen on long string took $time seconds\n";