Android Question Overhead of calling empty sub?

Troberg

Well-Known Member
Licensed User
I'm making a profiling framework, which can be used to gather performance data of a running program.

However, there will be some overhead in using it, so I enclose the methods in it in #If Debug, so it will only be included in debug builds, in release builds, the methods will just be empty stubs.

Now, is there any significant performance overhead in calling an empty sub?

I know, I could just use the #If Debug on the call instead, but I want to keep usage of the framework as simple as possible. I like to have lots of diagnostics code in my projects, but I don't want it to hog attention when reading code.

Hmm, I just got an idea: Find some character, say "!", which can be used at the start of a line as a short from for #If Debug. In other words, these snippets would be identical:

B4X:
#If Debug
  DoDebugLogging()
#End If
 
'...would be the same as:
 
!DoDebugLogging()
That would be neat.
 

Troberg

Well-Known Member
Licensed User
I also doubt it, as long as it's sensibly used. If one tries to use it on the innermost level of a fast loop, then it might be noticeable.
 
Top