Thread: C++ questions
View Single Post
  #2  
Old 01-13-2005, 02:46 AM
Yodason
Hill Giant
 
Join Date: Jan 2002
Posts: 205
Default

I normally don't bother posting to these boards, but this is a interesting topic I like talking about. =) The real key is that you shouldn't be trying to optimize little syntaxtical things. Thats what the compiler is good for. Don't go through a ton of extra effort trying to optimize UNLESS you've already run a profiller such as vtune or what not. Chances are what you are trying to optimize is really negligable. Virtual points for example are a single pointer lookup. Granted, thats not something you want in a vector3 class or what not, but in a mob class its perfectly fine and will not effect performance at all. I don't see why a multidimensional array would have a high perforamncee penalty, but if it does just put it into a 1d array and offset by the col length. Inline is highly desirable, but remember its just a suggestion, the compiler doesn't nessesarily follow it. It does help some things (like vector classes. get variable functions, etc) but by and large if your doing stuff with loops or if statements, there isn't going to be a performance gain worth rewriting for even if the compiler does inline it. Feel free to use function pointers, I doubt what you are doing will have any effect and may even slow things down by not using them. THE BEST place to optimize is algorithms : I remember I once killed aoe lag disconnect here by just moving a single check for valid target before a huge switch loop. THATS where you make gains, not these little tweaks. I HIGHLY recommend getting a profiler like intel vtune before you do ANY optimizing at this level. I guarentee that there are much "sweeter" spots to optimize in eqemu then worrying about the performance of one pointer lookup (which is all a virtual function is. Its virtually (pardon the pun) free for 99.9% of cases). I hope this answered your question.
Reply With Quote