#Trace
#Trace Flag
 
Parameters:

    Flag = The ON/OFF flag to disable/enable the compilers STEP/TRACE mode
Returns: NONE
 

      #Trace allows the programmer to control over the compilers generation of special debugger information during the compile process.

      In case your unsure, when a program is compiled in Debug TRACE mode. The debugger requires PlayBASIC to compile code in a special way. It has insert special codes inside your program. These codes are normally embedded at the start of each line of code. What they do, is act as a communication bridge between your program while it's running and the debugger.

      While this allows for greater hands on control of running program, as the debugger and the program are interleaved together, the down side is that this extra code can add a great deal of overhead to your programs performance. So programs compiled in Debug/Trace mode, will often performance very slowly.

      This is where the #Trace detective really comes into it's own. #Trace allows you to manually enable/disable the compilers generation of these debugger codes at any point throughout your program. This lets you to run certain parts of your program with debugger codes embedded and other parts without them. Thus giving much greater performance and allows you to only focus your debugging efforts on any new code your working on, rather than your entire program.


      It's important to note, that the #TRACE directive is only available when your compiling a program in DEBUG TRACE. If not, PlayBASIC will ignore these statements completely.



FACTS:


      * #TRACE is only available when a program is compiled in a DEBUG TRACE mode, F6 is the keyboard short cut from in the IDE.



Mini Tutorial:


      In this example were going to use force the compile not to insert tracing debugger code inside a loop.

      NOTE: This code must be run in DEBUG TRACE mode in order for you to see the results.


  
  
  
  Do
   ; Clear the Screen to RGB(0,0,0) (black)
     Cls RGB(0,0,0)
     
   ; Display a message abuot this example
     Print "Testing Loop Speed With and Without Debugger Code added"
     
     
   ; Read the Current Timer value
     StartingTIME=Timer()
   ; set the counter variable to zero
     Counter=0
   ; start a FOR/NEXT loop from 0 to 100, using LP as counter variable
     For lp=0 To 100
      ; Add one to the counter variable
        Inc counter
      ; continue the FOR/NEXT loop until LP is Greater than 100
     Next
     
   ; Get the Current Timer value and place it in the Ending Variable
     EndingTIME=Timer()
   ; Display a message show how long this loop took to run in milliseconds
     Print "This Loop Took "+Str$(EndingTime-StartingTime)+"  Milliseconds)"
     
     
   ; TURN OFF the INSERTION OF TRACE MODE DEBUGGER CODE from here on
     #Trace off
   ; Read the Current Timer value
     StartingTIME=Timer()
   ; set the counter variable to zero
     Counter=0
   ; start a FOR/NEXT loop from 0 to 100, using LP as counter variable
     For lp=0 To 100
      ; Add one to the counter variable
        Inc counter
      ; continue the FOR/NEXT loop until LP is Greater than 100
     Next
     
   ; Get the Current Timer value and place it in the Ending Variable
     EndingTIME=Timer()
   ; Display a message show how long this loop took to run in milliseconds
     Print "This Loop Took "+Str$(EndingTime-StartingTime)+"  Milliseconds)"
     
   ; TURN ON THE INSERTION OF TRACE MODE DEBUGGER CODES FROM HERE ON
     #Trace on
     
     
     
   ; Display the Screen and loop back to the DO statement
     Sync
  Loop
  



      When compiled in DEBUG TRACE mode this example outputs the following on my test machine. The result will vary for different machines

Screen Output
  
  Testing Loop Speed With And Without Debugger Code added
  This Loop Took 19 Milliseconds)
  This Loop Took 0 Milliseconds)
  



 
Related Info: #Break | #Print :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com