note 39790 rejected from language.operators.increment by vincent

From: Date: Tue, 10 Feb 2004 19:23:19 +0000
Subject: note 39790 rejected from language.operators.increment by vincent
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-64977@lists.php.net to get a copy of this message
Note Submitter: jukkissh@hotmail.com ---- As we all know, decrement is faster than increment ;) Take this speed test script for example: <?php echo "<html><head><title>Speed testing</title></head><body>"; $run_cycles = 1000000; echo "\n<!--\n\n"; $pts = microtime(); # time calculation start-point ################################## # one time executions ################################## for ($lap = $run_cycles; $lap > 0; --$lap) { ################################## # The actual test-cycle ################################## } // for loop ################################## list($use, $se) = explode(" ", microtime()); # time calculation end-point list($uss, $ss) = explode(" ", $pts); $pts = $uss + $ss; $pte = $use + $se; $pt = $pte - $pts; echo "\n\n-->\n"; echo "\n\nProcessing time: " . substr($pt, 0, 7) . " seconds for " . $run_cycles . " run cycles."; echo "</body></html>"; ?> With my P2 350 MHz, Windows 2000, IIS webserver the empty loop got more than one second faster by changing loop from adding to decreasing the counter $lap. Please notice 1 000 000 empty cycles :) I want to develop a perfect speed testing script, if you can help me out with this one, please mail me. Also, as I'm a speed freak, if PHP could develop in a way, that you could speed up script execution by declaring (at least some) variables fixed to some type, and win some speed there, it would be very reasonable. I've noticed that using for example "(integer)" into some statements can increase the speed greatly. But where is the documentation for this? When did this feature come available? I found this out by axident when trying it "for fun" after I learned it from C. I wonder if other speed tricks from C apply in PHP...

« previous php.notes (#64977) next »