   Empty functions
  Is it expensive to iterate through a vast number of objects i.e 10.000 and call  a (empty) function for each object? I'm wandering about function call I assume itteration is pretty fast.   
  Hopefully your compiler will be wise enough to remove the call (might even get rid of the loop if it's the only thing you do).But if you know the function is empty, why bother iterate and call it?   ;  I'm worried about the function call speed.The function will check a bool or something.   ;  You can inline the function or make the bool public.   ;  If you really want to know, use a profiler. There's not much point trying to guess which part of your software is slow at that level. If it's slow because of an algorithm/design, sure, you can just think about it or run some tests. But for a function call, you need a profiler...   ;Quote:Original post by Black KnightYou can inline the function or make the bool public.Accesing the bool would be faster than calling a function?   ;  Every function call has an overhead so basically yes.But if the function is doing lots of stuff then this overhead is not very important.When you inline a method it is basically inserted to the place it is called so you save that overhead time.inline functions;  Thanks for your feedback guys   ;  10,000 is a pretty small number when we're talking about today's processors. You know how clock speeds are measured in GHz? That is billions of cycles per second. Now, calling a function and returning from it can take many cycles. But it doesn't take anywhere near (billions) / (10,000). It's realistically not even in the (millions) / (10,000), i.e. hundreds range, so you can expect the loop to take less than a millisecond to run. Of course, that is a very rough estimation technique, and today's processors are very complicated beasts, but still...   ;Quote:Original post by Zahlman so you can expect the loop to take less than a millisecond to run.Got that. What would be 10.000 objects memory footprint?[Edited by - Calin on April 6, 2009 4:42:38 AM]