PHP 4.0 Bug #9260 Updated: Strange effects ...
| From: | derick@php.net | Date: | Wed, 14 Feb 2001 14:18:02 +0000 |
| Subject: | PHP 4.0 Bug #9260 Updated: Strange effects ... | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-46562@lists.php.net to get a copy of this message | ||
ID: 9260
Updated by: derick
Reported By: stefan@digiconcept.net
Old-Status: Open
Status: Closed
Bug Type: Performance problem
Assigned To:
Comments:
This is not a performance problem, but a bug in the microtime function. It was recently fixed in
CVS. Please try a snapshot from snaps.php.net. If the problem persists, please reopen this
bugreport.
Previous Comments:
---------------------------------------------------------------------------
[2001-02-14 09:13:42] stefan@digiconcept.net
The following script only generates an array and walks through it with 2 different loops.
There are some strange effects while watching the durations of the loops.
1. Sometimes loop 1 is faster
1. Sometimes loop 2 is faster
1. Sometimes there is a negativ duration ... ?
PHP seems to behave in real bizarre way ... looks like it has a will of it's own ;-)
<?
function test()
{
for ($i=0;$i<30000;$i++)
{
$GLOBALS['myVar'][$i]=$i;
}
$a = microtime();
for ($i=0;$i<count($GLOBALS['myVar']);$i++)
{
$GLOBALS['myVar'][$i] = $GLOBALS['myVar'][$i] *2;
}
$b = microtime();
foreach($GLOBALS['myVar'] as $i => $d)
{
$GLOBALS['myVar'][$i] = $d * 2;
}
$c = microtime();
echo('Results ... <br>');
echo("<b>$a<br>$b<br>$c</b><br>");
list($m,$s)=explode(' ',$a);$a = doubleval($s)+doubleval($m);
list($m,$s)=explode(' ',$b);$b = doubleval($s)+doubleval($m);
list($m,$s)=explode(' ',$c);$c = doubleval($s)+doubleval($m);
echo("<b>$a | $b | $c</b><br><br>");
echo("Loop 1: ".($b-$a)." seconds<br>");
echo("Loop 2: ".($c-$b)." seconds<br>");
echo("<hr>");
}
test();test();test();test();test();
?>
---------------------------------------------------------------------------
ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=9260&edit=2