Time cost of simple function/method calls

BlitzMax Forums/BlitzMax Programming/Time cost of simple function/method calls

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I thought that using 'final' should speed things up just a bit.
but it actually slows it down a little. Strange....


All Blitz methods are what in C++ would be called 'virtual' - they use dynamic binding at runtime. The assembly code emitted for obj.DoStuff() is the same regardless of whether the method is abstract, final, extended in another type or a combination of those.

If you see a slowdown, it's probably because the GC starts collecting garbage from the first test during the second. Always use GCCollect between tests when profiling!

Edit: Oh, as for the actual question... if the function calling GetSomeField does anything remotely complicated, the overhead from a method call is probably insignificant. Eg. each string concatenation amounts to way more cycles than a method call. Still, why not call it once and store it to a local variable...