Announcement

Collapse
No announcement yet.

Profiling

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Profiling

    I'm looking for hints, how I could realize something like profiling with a program coded in PB 3.2.

    Any halp would be appreciated.

    Regards Elek

  • #2
    It's simple enough in concept... if you are talking about the way PB/CC and PB/Win provide profiling facilities.

    In each Sub/Function, wrap the code like this:
    Code:
    SUB MySub()
      DIM X AS SINGLE
      X! = TIMER
      .
      . normal SUB code here
      .
      X! = TIMER - X!
      OPEN "Profile.txt" FOR APPEND AS #1
      WRITE #1, "MySub", X!
      CLOSE #1
    END SUB
    After running the program, you can open the disk file, and parse it, adding together all the times for subs/functions with the same names.

    Naturally, you'd be best to profile a DOS app under plain MSDOS so the effects of multi-tasking do not skew the results too much.

    If you take it one step further, you could write an app that takes the source code of an existing app and merges in the code (as shown above) into each Sub/Function in the program, and saves the file under a new name. This would make it much easier to profile existing programs without the need to manually copy/paste the code into each Sub/Function.

    I hope this helps!

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3

      Ok, THX.
      I will try it in such a way.

      But if I'm not wrong, I must use MTIMER instead of TIMER.


      Regards Elek

      ------------------
      this signature is no signature

      Comment


      • #4
        MTIMER has a resolution of approx 2 micro-seconds (µSec) and is accurate to periods of less than 54 milli-seconds (mSec). Any code that takes longer than 54 mSec should use TIMER instead.

        ------------------
        Lance
        PowerBASIC Support
        mailto:[email protected][email protected]</A>
        Lance
        mailto:[email protected]

        Comment


        • #5
          Ok, I will remember it.

          Thanks.

          Comment

          Working...
          X