Re: [PHP] Performance: While or For loop
On 3/27/07, Travis Doherty <[EMAIL PROTECTED]> wrote: Jake Gardner wrote: > He said if you run the /script/ itself 1000 times, not a loop with 1000 > iterations. This is quite possible; I am fairly certain there are > websites > out there that get accessed well over 1000 times a minute, yes? > > So every minute, that website is saving a total of 2.6 seconds to do... > whatever it is websites do in their free time. > > In reality, scripts rarely get executed once and then are deleted; > they are > used repetitively, and the more a script is used, the more significant > the > gain. Claiming to look practically on a small gain /within one > execution of > a script/ is impractical in itself. I still wouldn't go around telling people to re-write all of their code to use for loops instead of while loops (or whatever was faster for whatever architecture.) While loops came out faster :) Keep in mind that .000xx seconds in performance improvement certainly does make a difference on a site that is accessed millions of times a day, however, one bug caused by writing code that reads poorly instead of writing clean code can cost a *lot* more in the end. - Use what reads easier when deciding if a for/while loop is best. - Profile your code and find the right places to optimize. Optimizing code that takes .0001 seconds to run down to .1 seconds is great, 10x improvement! Who cares. Find the chunk that takes 0.5 seconds to run and optimize that to 0.05 seconds. 10x improvement still, except that this time it actually makes a practical difference. Travis Doherty I'm not telling people to rewrite the code, but if you need to choose, and both are good for the job, choose while :) Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Performance: While or For loop
Jake Gardner wrote: > He said if you run the /script/ itself 1000 times, not a loop with 1000 > iterations. This is quite possible; I am fairly certain there are > websites > out there that get accessed well over 1000 times a minute, yes? > > So every minute, that website is saving a total of 2.6 seconds to do... > whatever it is websites do in their free time. > > In reality, scripts rarely get executed once and then are deleted; > they are > used repetitively, and the more a script is used, the more significant > the > gain. Claiming to look practically on a small gain /within one > execution of > a script/ is impractical in itself. I still wouldn't go around telling people to re-write all of their code to use for loops instead of while loops (or whatever was faster for whatever architecture.) Keep in mind that .000xx seconds in performance improvement certainly does make a difference on a site that is accessed millions of times a day, however, one bug caused by writing code that reads poorly instead of writing clean code can cost a *lot* more in the end. - Use what reads easier when deciding if a for/while loop is best. - Profile your code and find the right places to optimize. Optimizing code that takes .0001 seconds to run down to .1 seconds is great, 10x improvement! Who cares. Find the chunk that takes 0.5 seconds to run and optimize that to 0.05 seconds. 10x improvement still, except that this time it actually makes a practical difference. Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Performance: While or For loop
He said if you run the /script/ itself 1000 times, not a loop with 1000 iterations. This is quite possible; I am fairly certain there are websites out there that get accessed well over 1000 times a minute, yes? So every minute, that website is saving a total of 2.6 seconds to do... whatever it is websites do in their free time. In reality, scripts rarely get executed once and then are deleted; they are used repetitively, and the more a script is used, the more significant the gain. Claiming to look practically on a small gain /within one execution of a script/ is impractical in itself. On 3/26/07, Richard Lynch <[EMAIL PROTECTED]> wrote: On Sat, March 24, 2007 4:52 am, Tijnema ! wrote: >> That means that at 1000 iterations, you are "saving" how much time? >> >> .00026 seconds? >> .4 seconds? >> >> Puhleaze. > > Well, if you execute this script 1000 times, you would get a > difference of 2.6 seconds? > But if every microseconds counts for your script, then you should now > about this. No. Re-read the benchmards. At 1000 iterations you're looking at .000xx seconds. At a MILLION iterations, you're looking at 0.xx seconds At a TEN MILLION iterations, you've broken the 1-second barrier. How many PHP scripts do a for or while loop 10 million iterations? xx is either 26 or 4, depending on whose benchmarks you believe. Running tests with 10 million iterations to benchmark is great for removing overhead margin of error. It's also great to look at exactly how many times you'd have to do something to make a significant savings. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Performance: While or For loop
On Sat, March 24, 2007 4:52 am, Tijnema ! wrote: >> That means that at 1000 iterations, you are "saving" how much time? >> >> .00026 seconds? >> .4 seconds? >> >> Puhleaze. > > Well, if you execute this script 1000 times, you would get a > difference of 2.6 seconds? > But if every microseconds counts for your script, then you should now > about this. No. Re-read the benchmards. At 1000 iterations you're looking at .000xx seconds. At a MILLION iterations, you're looking at 0.xx seconds At a TEN MILLION iterations, you've broken the 1-second barrier. How many PHP scripts do a for or while loop 10 million iterations? xx is either 26 or 4, depending on whose benchmarks you believe. Running tests with 10 million iterations to benchmark is great for removing overhead margin of error. It's also great to look at exactly how many times you'd have to do something to make a significant savings. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Performance: While or For loop
On Sat, 2007-03-24 at 14:38 -0400, tedd wrote: > At 2:24 PM -0400 3/24/07, Robert Cummings wrote: > >On Sat, 2007-03-24 at 10:21 -0400, tedd wrote: > >> At 7:47 PM -0500 3/23/07, Richard Lynch wrote: > >> >Folks: > >> > > >> >How often do you use a loop of any kind in PHP with enough iterations > >> >that this is even significant? > >> > > >> >Write the code that makes sense. > >> > > >> >Optimize the biggest bottleneck until performance is acceptable. > >> > >> Absolutely -- the time we take discussing these types of concerns > >> probably cost more cycles than the sum total of all the "optimized" > >> savings in the lifetime of all the computers on earth. > > > >I highly doubt it. Computers run a lot these days. There are times when > >squeezing that last nanosecond makes a difference and the devotion to > >finding how to squeeze it out is well worth it. Admittedly they may be > >few and far between, but they do exist. > > And, I highly doubt that the difference is worth considering -- and > it's becoming less of a consideration each day. > > Remember, we were talking about the differences between a "for" vs > "while" loop. Ahh, but it was the pre-increment versus post-increment that made the difference. every bit counts, it's the same problem as energy savings. If you only do it in one place you don't really see a savings, if you do it everywhere, it begins to have an impact. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Performance: While or For loop
At 2:24 PM -0400 3/24/07, Robert Cummings wrote: On Sat, 2007-03-24 at 10:21 -0400, tedd wrote: At 7:47 PM -0500 3/23/07, Richard Lynch wrote: >Folks: > >How often do you use a loop of any kind in PHP with enough iterations >that this is even significant? > >Write the code that makes sense. > >Optimize the biggest bottleneck until performance is acceptable. Absolutely -- the time we take discussing these types of concerns probably cost more cycles than the sum total of all the "optimized" savings in the lifetime of all the computers on earth. I highly doubt it. Computers run a lot these days. There are times when squeezing that last nanosecond makes a difference and the devotion to finding how to squeeze it out is well worth it. Admittedly they may be few and far between, but they do exist. And, I highly doubt that the difference is worth considering -- and it's becoming less of a consideration each day. Remember, we were talking about the differences between a "for" vs "while" loop. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Performance: While or For loop
On Sat, 2007-03-24 at 10:21 -0400, tedd wrote: > At 7:47 PM -0500 3/23/07, Richard Lynch wrote: > >Folks: > > > >How often do you use a loop of any kind in PHP with enough iterations > >that this is even significant? > > > >Write the code that makes sense. > > > >Optimize the biggest bottleneck until performance is acceptable. > > Absolutely -- the time we take discussing these types of concerns > probably cost more cycles than the sum total of all the "optimized" > savings in the lifetime of all the computers on earth. I highly doubt it. Computers run a lot these days. There are times when squeezing that last nanosecond makes a difference and the devotion to finding how to squeeze it out is well worth it. Admittedly they may be few and far between, but they do exist. > The time you spend trying to make something faster in those terms > clearly cost more time in development and maintenance. It's a > trade-off that's not worth it. The time you spend can be large, but here we all know now how to speed things up, if we just apply the principles that are easy to apply in all the code we write, then such things will already be optimal and so in hindsight we will already be reaping the rewards without any extra effort. > Q: Do they teach this stuff in college now or are the teachers still > only measuring performance in myopic terms of saving memory and time? > Not a criticism, just a question. They generally teach algorithmic analysis that improves the algorithm's order of magnitude in contrast to teaching constant multiplicative gains. However, that's not to say writing efficient code isn't a good thing. If I have an algorithm that runs in X time, I'm sure if X is 2 years and I can shrink it to x/2 then nobody will quibble about the constant gain since it happens to be 1 year of savings. Now depending on the calculations you're doing, shaving off a nanosecond can indeed have a large enough impact to make it worth your time. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Performance: While or For loop
At 7:47 PM -0500 3/23/07, Richard Lynch wrote: Folks: How often do you use a loop of any kind in PHP with enough iterations that this is even significant? Write the code that makes sense. Optimize the biggest bottleneck until performance is acceptable. Absolutely -- the time we take discussing these types of concerns probably cost more cycles than the sum total of all the "optimized" savings in the lifetime of all the computers on earth. The time you spend trying to make something faster in those terms clearly cost more time in development and maintenance. It's a trade-off that's not worth it. Q: Do they teach this stuff in college now or are the teachers still only measuring performance in myopic terms of saving memory and time? Not a criticism, just a question. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Performance: While or For loop
Hi, I'm using so much FOR loops in my code, after seeing discussion I try to test. My findigs it was giving %2 to %10 percent performance boost. So ? My recent template addon to this code cost me around %5 to %10 percent of total page process.. I think It was nice trade off. Thank you guys. Just changing two chars. Regards Sancar -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Performance: While or For loop
On 3/24/07, Richard Lynch <[EMAIL PROTECTED]> wrote: On Fri, March 23, 2007 7:54 pm, Tijnema ! wrote: > On 3/24/07, Richard Lynch <[EMAIL PROTECTED]> wrote: >> Folks: >> >> How often do you use a loop of any kind in PHP with enough >> iterations >> that this is even significant? >> >> Write the code that makes sense. >> >> Optimize the biggest bottleneck until performance is acceptable. > > It was more likely to get an idea if there was a real difference or > not, and apparently there is not really a big difference. > > But well if you are going to create a script where 1000+ loops are, > you might get a few seconds faster script :) I believe we are seeing times for 1000 iterations around 4 seconds? Or was it 26 seconds? Whatever. That means that at 1000 iterations, you are "saving" how much time? .00026 seconds? .4 seconds? Puhleaze. Well, if you execute this script 1000 times, you would get a difference of 2.6 seconds? But if every microseconds counts for your script, then you should now about this. Tijnema -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Performance: While or For loop
On Fri, March 23, 2007 7:54 pm, Tijnema ! wrote: > On 3/24/07, Richard Lynch <[EMAIL PROTECTED]> wrote: >> Folks: >> >> How often do you use a loop of any kind in PHP with enough >> iterations >> that this is even significant? >> >> Write the code that makes sense. >> >> Optimize the biggest bottleneck until performance is acceptable. > > It was more likely to get an idea if there was a real difference or > not, and apparently there is not really a big difference. > > But well if you are going to create a script where 1000+ loops are, > you might get a few seconds faster script :) I believe we are seeing times for 1000 iterations around 4 seconds? Or was it 26 seconds? Whatever. That means that at 1000 iterations, you are "saving" how much time? .00026 seconds? .4 seconds? Puhleaze. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Performance: While or For loop
On Sat, 2007-03-24 at 01:54 +0100, Tijnema ! wrote: > On 3/24/07, Richard Lynch <[EMAIL PROTECTED]> wrote: > > On Thu, March 22, 2007 5:14 pm, Tijnema ! wrote: > > > On 3/22/07, Jon Anderson <[EMAIL PROTECTED]> wrote: > > >> Your test isn't exactly fair. The for loop has no statements in it, > > >> and > > >> the while loop has one. Your tests show while as approx 7% faster, > > >> while > > >> a modified test shows an approximate 30% speed improvement: > > >> > > >> Do this: > > >> > > >> for ($i=0;$i<1000;$i++) {} > > >> > > >> v.s.: > > >> > > >> $i = 0; > > >> while ($i++ < 1000) {} > > >> > > >> The above while loop is 30% faster than the for. A little teaking on > > >> the > > >> for loop, it's faster still: > > > > Folks: > > > > How often do you use a loop of any kind in PHP with enough iterations > > that this is even significant? > > > > Write the code that makes sense. > > > > Optimize the biggest bottleneck until performance is acceptable. It's not optimization if you just happen to write optimal code out of habit. It's already done. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Performance: While or For loop
On 3/24/07, Richard Lynch <[EMAIL PROTECTED]> wrote: On Thu, March 22, 2007 5:14 pm, Tijnema ! wrote: > On 3/22/07, Jon Anderson <[EMAIL PROTECTED]> wrote: >> Your test isn't exactly fair. The for loop has no statements in it, >> and >> the while loop has one. Your tests show while as approx 7% faster, >> while >> a modified test shows an approximate 30% speed improvement: >> >> Do this: >> >> for ($i=0;$i<1000;$i++) {} >> >> v.s.: >> >> $i = 0; >> while ($i++ < 1000) {} >> >> The above while loop is 30% faster than the for. A little teaking on >> the >> for loop, it's faster still: Folks: How often do you use a loop of any kind in PHP with enough iterations that this is even significant? Write the code that makes sense. Optimize the biggest bottleneck until performance is acceptable. It was more likely to get an idea if there was a real difference or not, and apparently there is not really a big difference. But well if you are going to create a script where 1000+ loops are, you might get a few seconds faster script :) Tijnema -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Performance: While or For loop
On Thu, March 22, 2007 5:14 pm, Tijnema ! wrote: > On 3/22/07, Jon Anderson <[EMAIL PROTECTED]> wrote: >> Your test isn't exactly fair. The for loop has no statements in it, >> and >> the while loop has one. Your tests show while as approx 7% faster, >> while >> a modified test shows an approximate 30% speed improvement: >> >> Do this: >> >> for ($i=0;$i<1000;$i++) {} >> >> v.s.: >> >> $i = 0; >> while ($i++ < 1000) {} >> >> The above while loop is 30% faster than the for. A little teaking on >> the >> for loop, it's faster still: Folks: How often do you use a loop of any kind in PHP with enough iterations that this is even significant? Write the code that makes sense. Optimize the biggest bottleneck until performance is acceptable. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Performance: While or For loop
On 3/23/07, Mario Guenterberg <[EMAIL PROTECTED]> wrote: On Fri, Mar 23, 2007 at 12:24:45AM -0500, Travis Doherty wrote: > After multiple runs I see that the for pre-increment loop is fastest. > Note that the while loop with a post-increment runs once more than with > a pre-increment. > > Everytime I run, the results are *very* different, though still fall > within similar comparitive domains. Hi... I used your script and my results are different from yours. The post-while increment is generally the fastest result on my machine (Core 2 Duo, php 5.2.1 and apache 2.2.4). I ran the script multiple times: [schnipp ] For pre-increment (10): 0.066 For post-increment (10): 0.066 While pre-increment (10): 0.028 While post-increment (11): 0.025 [schnipp ] Greetings Mario Well, myh results are a little bit confusing again, if using pre-increment, for shows up faster now. But while post-increment is the fastest :) Is there any logic why we all have different results? does it has to do something with the type of CPU, i'm using AMD Athlon. 1800+ (clocked down from 133 to 100 * 11.5) For pre-increment (10): 0.026 For post-increment (10): 0.030 While pre-increment (10): 0.029 While post-increment (11): 0.023 Tijnema ps. @ Mario: Youre C2D got owned by a AMD 1.15Ghz :) -- - | havelsoft.com - Ihr Service Partner für Open Source | | Tel: 033876-21 966 | | Notruf: 0173-277 33 60 | | http://www.havelsoft.com| | | | Inhaber: Mario Günterberg | | Mützlitzer Strasse 19 | | 14715 Märkisch Luch | - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Performance: While or For loop
On Fri, Mar 23, 2007 at 12:24:45AM -0500, Travis Doherty wrote: > After multiple runs I see that the for pre-increment loop is fastest. > Note that the while loop with a post-increment runs once more than with > a pre-increment. > > Everytime I run, the results are *very* different, though still fall > within similar comparitive domains. Hi... I used your script and my results are different from yours. The post-while increment is generally the fastest result on my machine (Core 2 Duo, php 5.2.1 and apache 2.2.4). I ran the script multiple times: [schnipp ] For pre-increment (10): 0.066 For post-increment (10): 0.066 While pre-increment (10): 0.028 While post-increment (11): 0.025 [schnipp ] Greetings Mario -- - | havelsoft.com - Ihr Service Partner für Open Source | | Tel: 033876-21 966 | | Notruf: 0173-277 33 60 | | http://www.havelsoft.com| | | | Inhaber: Mario Günterberg | | Mützlitzer Strasse 19 | | 14715 Märkisch Luch | - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Performance: While or For loop
Tijnema ! wrote: > On 3/22/07, Jon Anderson <[EMAIL PROTECTED]> wrote: > >> Your test isn't exactly fair. The for loop has no statements in it, and >> the while loop has one. Your tests show while as approx 7% faster, while >> a modified test shows an approximate 30% speed improvement: >> >> Do this: >> >> for ($i=0;$i<1000;$i++) {} >> >> v.s.: >> >> $i = 0; >> while ($i++ < 1000) {} > This has been asked many times, probably likewise for every language. Search for the same question on the C programming language for a more in depth discussion of this and to find out why one way is faster than the other... Major factor: Don't forget the difference between pre and post increment operators. $i++ and ++$i. For reference this is my PHP test script and results: {{{ [EMAIL PROTECTED] tdoherty $ cat ./forwhile.php [EMAIL PROTECTED] tdoherty $ php ./forwhile.php For pre-increment (10): 0.035 For post-increment (10): 0.060 While pre-increment (10): 0.029 While post-increment (11): 0.056 }}} After multiple runs I see that the for pre-increment loop is fastest. Note that the while loop with a post-increment runs once more than with a pre-increment. Everytime I run, the results are *very* different, though still fall within similar comparitive domains. Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Performance: While or For loop
On 3/22/07, Jon Anderson <[EMAIL PROTECTED]> wrote: Your test isn't exactly fair. The for loop has no statements in it, and the while loop has one. Your tests show while as approx 7% faster, while a modified test shows an approximate 30% speed improvement: Do this: for ($i=0;$i<1000;$i++) {} v.s.: $i = 0; while ($i++ < 1000) {} The above while loop is 30% faster than the for. A little teaking on the for loop, it's faster still: I was comparing the way people normal use while and for. But this does confirms what i said, while is faster. for ($i=1000;$i--;) {} A little tweaking on the while, and it's faster yet: $i = 1000; while ($i--) {} The last while loop is around 60% faster on my hardware than the first for loop. jon Tijnema ! wrote: > On 3/22/07, Jake McHenry <[EMAIL PROTECTED]> wrote: >> does this help? >> >> http://www.php.lt/benchmark/phpbench.php >> >> Jake > > Well, there wasn't a test between For and While, so i did it myself, > and i'm quite confused about the result. > I let PHP count from 0 to 1 on my 1ghz AMD Athlon. > While did it in a average time of 55 seconds. > For did it in a average time of 59 seconds. > It's not a big difference, if you see what number it needs to go to, > but there is a difference. > > code used: > set_time_limit(10); > echo date("H:i:s"); > for($i = 0; $i < 1;$i++) > { > } > echo date("H:i:s"); > $x = 0; > while($x < 1) > { > $x++; > } > echo date("H:i:s"); > ?> > > So, use while loops instead of for loops ;) > > Tijnema > > ps. I also did the while loop before the for loop, doesn't matter. > >> >> >> >> > -Original Message- >> > From: Tijnema ! [mailto:[EMAIL PROTECTED] >> > Sent: Thursday, March 22, 2007 4:38 PM >> > To: PHP >> > Subject: [PHP] Performance: While or For loop >> > >> > Hi, >> > >> > Does somebody has benchmarks of what is faster, while or for loop? >> > >> > Thanks, >> > >> > Tijnema >> > >> > -- >> > PHP General Mailing List (http://www.php.net/) >> > To unsubscribe, visit: http://www.php.net/unsub.php >> > >> > -- >> > No virus found in this incoming message. >> > Checked by AVG Free Edition. >> > Version: 7.5.446 / Virus Database: 268.18.17/730 - Release >> > Date: 3/22/2007 7:44 AM >> > >> > >> >> -- >> No virus found in this outgoing message. >> Checked by AVG Free Edition. >> Version: 7.5.446 / Virus Database: 268.18.17/730 - Release Date: >> 3/22/2007 >> 7:44 AM >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Performance: While or For loop
On 3/22/07, Jake McHenry <[EMAIL PROTECTED]> wrote: does this help? http://www.php.lt/benchmark/phpbench.php Jake Well, there wasn't a test between For and While, so i did it myself, and i'm quite confused about the result. I let PHP count from 0 to 1 on my 1ghz AMD Athlon. While did it in a average time of 55 seconds. For did it in a average time of 59 seconds. It's not a big difference, if you see what number it needs to go to, but there is a difference. code used: So, use while loops instead of for loops ;) Tijnema ps. I also did the while loop before the for loop, doesn't matter. > -Original Message- > From: Tijnema ! [mailto:[EMAIL PROTECTED] > Sent: Thursday, March 22, 2007 4:38 PM > To: PHP > Subject: [PHP] Performance: While or For loop > > Hi, > > Does somebody has benchmarks of what is faster, while or for loop? > > Thanks, > > Tijnema > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- > No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.5.446 / Virus Database: 268.18.17/730 - Release > Date: 3/22/2007 7:44 AM > > -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.446 / Virus Database: 268.18.17/730 - Release Date: 3/22/2007 7:44 AM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Performance: While or For loop
does this help? http://www.php.lt/benchmark/phpbench.php Jake > -Original Message- > From: Tijnema ! [mailto:[EMAIL PROTECTED] > Sent: Thursday, March 22, 2007 4:38 PM > To: PHP > Subject: [PHP] Performance: While or For loop > > Hi, > > Does somebody has benchmarks of what is faster, while or for loop? > > Thanks, > > Tijnema > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- > No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.5.446 / Virus Database: 268.18.17/730 - Release > Date: 3/22/2007 7:44 AM > > -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.446 / Virus Database: 268.18.17/730 - Release Date: 3/22/2007 7:44 AM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Performance: While or For loop
Hi, Does somebody has benchmarks of what is faster, while or for loop? Thanks, Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php