Author |
Message |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Fri Apr 01, 2005 11:55 pm Post maybe stupid Post subject: |
 |
|
|
|
That article wasn't really about optimizing loops, it was optimizing loops with AltiVec or whatever.
What Ekted said applies far more to the majority of us. (Those of us who don't use PowerPCs?)  _________________ This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him. |
|
Back to top |
|
 |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Sat Apr 02, 2005 12:15 am Post maybe stupid Post subject: |
 |
|
|
|
Shouldn't any decent optimizer fix that, ekted?
Besides, readability is far more important that efficiency in ~90% of cases. _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Sat Apr 02, 2005 12:42 am Post maybe stupid Post subject: |
 |
|
|
|
I would agree in most cases, but if you are writing something that absolutely has to be killer fast--maybe you would even go so far as to profile it--then this is something you would seriously consider. A thousand loops, no big deal, A million, you are starting to get iffy. |
|
Back to top |
|
 |
Maverick

Age:41 Gender: Joined: Feb 26 2005 Posts: 1521 Location: The Netherlands Offline
|
|
Back to top |
|
 |
D1st0rt Miss Directed Wannabe

Age:37 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Sat Apr 02, 2005 9:35 am Post maybe stupid Post subject: |
 |
|
|
|
It only has to do the conditional branch once. _________________
 |
|
Back to top |
|
 |
Maverick

Age:41 Gender: Joined: Feb 26 2005 Posts: 1521 Location: The Netherlands Offline
|
Posted: Sat Apr 02, 2005 9:41 am Post maybe stupid Post subject: |
 |
|
|
|
D1st0rt wrote: | It only has to do the conditional branch once. |
The if() takes longer then the for loop? 
Last edited by Maverick on Sat Apr 02, 2005 9:42 am, edited 1 time in total |
|
Back to top |
|
 |
D1st0rt Miss Directed Wannabe

Age:37 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Sat Apr 02, 2005 9:42 am Post maybe stupid Post subject: |
 |
|
|
|
In the first example, it has to do the if 1000000 times. In the second, it does it once. |
|
Back to top |
|
 |
Maverick

Age:41 Gender: Joined: Feb 26 2005 Posts: 1521 Location: The Netherlands Offline
|
Posted: Sat Apr 02, 2005 9:43 am Post maybe stupid Post subject: |
 |
|
|
|
aaaah... but two for loops of that size should still make up more cpu cycles then one (with the if() )? Or am I mistaken.. |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Sat Apr 02, 2005 11:07 am Post maybe stupid Post subject: |
 |
|
|
|
It'll be executing more than one command in ASM, if that's what you mean. But in both cases, the for loop commands stay the same, but the conditional code only has to be done once in the second, which obviously makes it faster no matter how long the for()s take. |
|
Back to top |
|
 |
D1st0rt Miss Directed Wannabe

Age:37 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Sat Apr 02, 2005 12:57 pm Post maybe stupid Post subject: |
 |
|
|
|
In the second example, only one of the loops gets run |
|
Back to top |
|
 |
SamHughes Server Help Squatter

Joined: Jun 30 2004 Posts: 251 Location: Greenwich Offline
|
Posted: Sat Apr 02, 2005 9:38 pm Post maybe stupid Post subject: |
 |
|
|
|
What should I do if looping through branches a million times is my favorite form of gambling? |
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
|
Back to top |
|
 |
Maverick

Age:41 Gender: Joined: Feb 26 2005 Posts: 1521 Location: The Netherlands Offline
|
Posted: Sun Apr 03, 2005 6:11 am Post maybe stupid Post subject: |
 |
|
|
|
SamHughes wrote: | What should I do if looping through branches a million times is my favorite form of gambling? |
Try russion roulette as your final gambling game. |
|
Back to top |
|
 |
|