Raised This Month: $ Target: $400
 0% 

Infinite loops


Post New Thread Reply   
 
Thread Tools Display Modes
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 02-12-2009 , 23:04   Re: Infinite loops
Reply With Quote #21

Quote:
Originally Posted by danielkza View Post
The only thing we learned from all this is that AMXX's compiler sucks.
I thought that was self evident.

Also, I'm wrong for once. Very refreshing.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 02-13-2009 , 00:51   Re: Infinite loops
Reply With Quote #22

In C++, use:

PHP Code:
while (true
instead of

PHP Code:
while (1
Because in C++, bool (1 byte) is smaller than int (4 bytes). Always take your types into account when making optimizations.
Spunky is offline
Send a message via AIM to Spunky
Pro Patria Finland
Senior Member
Join Date: Apr 2006
Location: BaronPub.com
Old 02-13-2009 , 00:53   Re: Infinite loops
Reply With Quote #23

Quote:
Originally Posted by Sean D View Post
experience? sure i guess... as danielkza was getting at, any modern compiler is going to know that the condition is always true so it will compile down to a jump. how much code it takes in the language doesn't determine how fast the machine code is; modern compilers are pretty smart. if you want proof then compile each and disassemble the executables in ida. by the way, if you're trying to optimize your code, you really should be using a profiler to pinpoint the bottleneck of your software so you don't have to waste time guessing.

also don't listen to anything hawk says, he doesn't know what he's talking about
This answer suffices for me, I think. Stupid me, I didn't even check the hex codes my compilers give me. I'll check later today if I have time what the AVR GCC -compiler outputs. I guess it should be similar to the tables posted earlier. I should start writing in Assembly anyhow.
__________________
I am not a number. I am Gordon Freeman!
Pro Patria Finland is offline
Pro Patria Finland
Senior Member
Join Date: Apr 2006
Location: BaronPub.com
Old 02-13-2009 , 00:57   Re: Infinite loops
Reply With Quote #24

Quote:
Originally Posted by danielkza View Post
The only thing we learned from all this is that AMXX's compiler sucks.
No, I learned that from Bailopans blagblog last year. Although very interesting information still.
__________________
I am not a number. I am Gordon Freeman!
Pro Patria Finland is offline
Sean D
Junior Member
Join Date: Apr 2006
Old 02-13-2009 , 10:30   Re: Infinite loops
Reply With Quote #25

Quote:
Originally Posted by Spunky View Post
Because in C++, bool (1 byte) is smaller than int (4 bytes). Always take your types into account when making optimizations.
we have already been over this: it will compile down into the same code. in any case, i'm pretty sure using booleans could actually end up being slower sometimes, because using anything smaller than the size of a word (4 bytes on 32-bit architectures) can cause a loss in speed due to the machine operations being slower.

@ pro patria finland: yeah the object code i posted was compiled with gcc without any extra optimization flags.

PS: sonata arctica owns
Sean D is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:25.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode