Android Question Overhead of calling empty sub?

Discussion in 'Android Questions' started by Troberg, Mar 25, 2015.

  1. Troberg

    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:

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

    DonManfred Expert Licensed User

    i dont think that you will feel any permomance loss
     
    Erel likes this.
  3. Troberg

    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.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice