note 103947 deleted from control-structures.goto by danbrown
| From: | danbrown@php.net | Date: | Sat, 11 Jun 2011 14:57:46 +0000 |
| Subject: | note 103947 deleted from control-structures.goto by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-180436@lists.php.net to get a copy of this message | ||
Note Submitter: Kenan Sulayman
----
Actually, on an Intel XEON X7560 ( 8 x 2.26 Ghz ), the slow down with this operation is huge.
Running the following code will actually show it.
<?php
//
for($xx=0;$xx<=1000;++$xx) {
$i = 0;
//a:
$z = microtime(1);
while($i <= 10000) {
//print "xx";
++$i;
}
$q = microtime(1);
$i = 0;
$$z = microtime(1);
a:
if ( $i >= 10000 ) goto z;
++$i; goto a;
z:
$$q = microtime(1);
($t = $q - $z) && ( $$t = $$q - $$z ) && $p = ( ($t / $$t) * 100 );
//print "\r\n" . ($t = $q - $z) . " <---> " . ( $$t = $$q - $$z )
. " ~ " . $p;
//goto a;
//print "\r\n";
}
print "Average: " . $p . "\r\n";
?>
<?PHP // Code originally written by (tweston AT coldsteelstudios DOT com) on 06-OCT-2010
$start = microtime(true);
$i = 0;
StartOfLoop:
++$i;
if($i < 10000000) goto StartOfLoop;
$start = microtime(true) - $start;
$$start = microtime(true);
$i = 0;
while($i < 10000000){
++$i;
}
$$start = microtime(true) - $$start;
print "\r\n";
print ( ( $$start / $start ) * 100 );
?>
Output, here:
Average: 51.841435141196 // for $i <= 10000
60.688755174503 // for $i <= 10000000