Page 1 of 1

Profiling your code with a macro

Posted: Thu May 30, 2013 6:13 pm
by uwekel
Hi,

here is a macro i wrote today to count the number of execution per second. I put the macro into a resident file to have it available all the time. Just call it with your code, e.g. the name of a procedure, like

Code: Select all

Profile(MyTestProc())
Here is the macro code:

Code: Select all

Macro Profile(Code)
  ;run test code and count number of calls within a second
  Define profile_count = 0
  Define profile_start = ElapsedMilliseconds()
  Repeat
    Code
    profile_count + 1
  Until ElapsedMilliseconds() - profile_start > 1000
  ;show result
  CompilerIf #PB_Compiler_Debugger
    Debug profile_count
  CompilerElse
    MessageRequester("Profile", Str(profile_count))
  CompilerEndIf
EndMacro
Btw, does anyone know how to get code completion working from resident files?

Best regards
Uwe

Re: Profiling your code with a macro

Posted: Thu May 30, 2013 8:11 pm
by luis
uwekel wrote: Btw, does anyone now how to get code completion working from resident files?
For Macros ? Sadly no.

http://www.purebasic.fr/english/viewtop ... 34#p370834