note 103947 added to control-structures.goto
| From: | KenanSulayman at osu1 dot php dot net | Date: | Fri, 13 May 2011 08:14:05 +0000 |
| Subject: | note 103947 added to control-structures.goto | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-179672@lists.php.net to get a copy of this message | ||
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 // somewhat copyright from the poster down here
$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
----
Server IP: 69.147.83.197
Probable Submitter: 217.41.238.168
----
Manual Page -- http://www.php.net/manual/en/control-structures.goto.php
Edit -- https://master.php.net/note/edit/103947
Del: integrated -- https://master.php.net/note/delete/103947/integrated
Del: useless -- https://master.php.net/note/delete/103947/useless
Del: bad code -- https://master.php.net/note/delete/103947/bad+code
Del: spam -- https://master.php.net/note/delete/103947/spam
Del: non-english -- https://master.php.net/note/delete/103947/non-english
Del: in docs -- https://master.php.net/note/delete/103947/in+docs
Del: other reasons-- https://master.php.net/note/delete/103947
Reject -- https://master.php.net/note/reject/103947
Search -- https://master.php.net/manage/user-notes.php