Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Development

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

Reply
 
Thread Tools Display Modes
  #1  
Old 01-13-2005, 01:23 PM
Branks
Sarnak
 
Join Date: May 2004
Posts: 58
Default

i understand these questions are rather rediculous and petty but in my opinion its something that should be in the back of your mind at all times, so thats why i ask, and i know a profiler is the only real answer to some of them and that the answer varries between different machines.

im not really trying to optimize little syntaxtical things, its that no matter what compiler your using there are situations syntax prevents the compiler from being able to do any optimization, and thats parts of what im unsure of, i know inline is only a suggestion however ive also read its almost 100% impossible for a compiler to inline a virtual function, and a compiler cannot unroll a variable loop, so i was hoping we maybe had a hardcore assembly guru around who could say " i found loop setup time to be slower than 100 conditional checks", so i could keep that in mind and simply let a loop go 100 passes when it would sometimes only need 50, so that the compiler could unroll it.

in the case of GetAA() its called often enough i think inlining it would to benificial in any case since theres maybe 4 times ive found its called within Mob() scope.

the functions pointer thing, i know when calling functions it has to throw all currently used variables temporarily to the stack, or wherever it saves them so i was curious if function pointers made it do this as well, since thats a small but also needless thing to have 3 copies or so of variables around and i would know to prevent having a lot of arguements/parameters when using function pointers.

anyway, ill check into this vtune thing, never heard of it before, and thanks for the advice, im just trying to establish the commonly know performance mistakes, not trying to optimize really but these small things add up quickly.

also, the question about static variables declared within a class method, are these created for every instance of a class or does every instance of a class use the same method and therefor the static variables only exsist once?
Reply With Quote
  #2  
Old 01-13-2005, 05:35 PM
animepimp
Dragon
 
Join Date: Jan 2004
Posts: 860
Default

Quote:
Originally Posted by Branks
accessing multi dimensional arrays, ive heard this is slow enough to be avoided when its possible, however some situations such as Mob::SpellEffect which various cases within, will need to access the array which holds AA spell IDs and recourses of AA spell Ids, would it be better to store these commonly checked spell IDs in global variables? instead of accessing the array each pass?
This has no overhead at all in C or C++. It may in Java or other languages, but in C the entire multidimensional array is stored linearly in one block of memory with each row immediately after the previous row. He said you could store it as a single dimensional array and refer to it with [column +(row*num_columns)] and you can if you want, but that is exactly what the program does when you put [row][column]. You can even declare it as two dimension and type cast it to one dimension and refer to it interchangably. So the only over head is a pointer look up and an addition and multiplication, if you worry over that then you should see a shrink.

Quote:
Originally Posted by Branks
also, the question about static variables declared within a class method, are these created for every instance of a class or does every instance of a class use the same method and therefor the static variables only exsist once?
I don't think you can declare a static variable inside a method, and even if you can it will do absolutely nothing because variables declared in a method cease to exist once the method stops running. Of course if you have two instances of the method running at the same time it may make them share the variables, but I have no idea.
Reply With Quote
  #3  
Old 01-14-2005, 01:47 AM
Yodason
Hill Giant
 
Join Date: Jan 2002
Posts: 205
Default

Quote:
This has no overhead at all in C or C++. It may in Java or other languages, but in C the entire multidimensional array is stored linearly in one block of memory with each row immediately after the previous row. He said you could store it as a single dimensional array and refer to it with [column +(row*num_columns)] and you can if you want, but that is exactly what the program does when you put [row][column]. You can even declare it as two dimension and type cast it to one dimension and refer to it interchangably. So the only over head is a pointer look up and an addition and multiplication, if you worry over that then you should see a shrink.
exactly.
Quote:
I don't think you can declare a static variable inside a method, and even if you can it will do absolutely nothing because variables declared in a method cease to exist once the method stops running. Of course if you have two instances of the method running at the same time it may make them share the variables, but I have no idea.
[Quote] Normally, variables defined local to a function disappear at the end of the function scope. When you call the function again, storage for the variables is created anew and the values are re-initialized. If you want a value to be extant throughout the life of a program, you can define a function
Reply With Quote
Reply

Thread Tools
Display Modes

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 11:59 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3