Page 1 of 2

Performance questions

PostPosted: May 27, 2002 @ 2:49am
by Malmer
Guess I'm to lazy to conduct as series of tests myself so I just ask here ;)

1) Does namespacing impact anything on performance. Like doing MyNS::Function1(i).

2) Say I have a class with some structs in it. Does this take any performance hit: oImage.oPos.x = 1. How much performance gain do I get if I create a pointer to oImage.oPos and then use that for my x and y values (or in other cases more subvalues depending on which struct). I hope it doesn't have to query the stack for each dot (.) I have...

3) Which is the fastest? Doing a switch statement or doing "else if":s? Guess switch is the fastest...

Thanks!

PostPosted: May 27, 2002 @ 9:51am
by refractor
A lot of it will be compiler specific.

However, my guesses would be:

1) No idea - I'd /presume/ no performance hit 'cos it's more a compiler directive than actual code.

2) In theory, creating a pointer to the structure only performs one dereference to the object, and will then use offsets to address the individual items.

The other way, you *might* be unlucky and have the compiler dereference the object twice... but any decent compiler should keep the dereferenced pointer cached for next use.

... it really does depend on the compiler. If you want to compile that bit of code as ARM and post it here, I/somebody can tell you which it's doing.

(Go to project ->C/C++->Category tab->Listing files-> Assembly with source code).. then look through the assembler files and chop and post the function.

3) We've been through this one before, IIRC. A switch will essentially compile to a large set of elseif statements. The best gain is to *order* the ifs/switches in the most frequent first.

If you've got quite a lot of items to check, use a switch - it's cleaner to read.

Cheers,

Refractor

PostPosted: May 27, 2002 @ 12:28pm
by Malmer

PostPosted: May 27, 2002 @ 1:43pm
by Phantom

PostPosted: May 27, 2002 @ 2:48pm
by Dan East

PostPosted: May 27, 2002 @ 4:51pm
by refractor

PostPosted: May 27, 2002 @ 4:58pm
by BurningSheep

PostPosted: May 28, 2002 @ 10:46am
by refractor

PostPosted: May 28, 2002 @ 1:31pm
by BurningSheep

PostPosted: May 29, 2002 @ 4:02pm
by Orpe

PostPosted: May 29, 2002 @ 7:21pm
by Jadam

PostPosted: May 29, 2002 @ 9:04pm
by refractor

PostPosted: May 29, 2002 @ 9:13pm
by Jadam
yeah, thats what i mean, order it from ARM... refractor, how fast is it? is the compiled code better than eVC++ or couldnt get your PocketPC to work with it??

Would ARM offer support if you purchased the full $4000 version?? And no, i didnt mean Warezed version. That way, you wouldnt really get any support anyways, and some new software is becoming really hard to warez, such as the $5000 software that uses USB Keychains for the Serial Number, the only one i know of is Discreet Combustion for Mac OS X

PostPosted: May 30, 2002 @ 2:02am
by Malmer

PostPosted: May 30, 2002 @ 9:10am
by refractor