Profiler.txt
Warning: if you clip this code into your program, look out for possible html code slipping in.
REM Execution profiler for VSTB REM REM Author: Steven R. Wheeler REM REM Copyright 2000 Vesta Technology, Inc. REM All rights reserved. REM REM Revision history: REM June 23, 2000 srw REM First version. REM How do you know where your program is spending its time? That's a REM complicated question. This file is intended to provide some data REM which may help. This file MUST BE INCLUDED with an INCLUDE statement. REM If you just copy this file into your application, you won't get any REM useful information. REM What this application will do is to set up a timer interrupt. This REM timer interrupt will print the line number of the line which was REM executing when the timer interrupt fires (currently to the COM port). REM You will need to capture the text for data reduction on a host PC. REM Limitations of the code: REM 1. You MUST compile with debug. REM 2. You cannot track execution in VITAL subroutines and functions. REM 3. You cannot track execution of code in INCLUDEd files. REM 4. Time spent in any code in limitations 2 and 3 will be reported REM as belonging to the line of code which called them. REM This sets the periodicity of the reports. Do not set it to a value REM which is so small that it interferes with your application. CONSTANT ProfileRate AS INTEGER = 10 REM This routine uses VSTB Timer 1. Your application should set up the REM interrupt handler, and start it up. REM REM If you have a way to correlate pcode addresses with source code lines REM (no such way is currently available), you can comment out the lines REM which refer to LineNumber, and uncomment the lines which refer to REM FramePointer. The report will then be reporting pcode addresses, and REM you will no longer have to compile with debug. You will still not be REM able to track execution within VITAL subroutines and functions, but REM you will be able to track execution of code within INCLUDEd files. VITAL SUBROUTINE Profile(which AS INTEGER) REM CONSTANT FramePointer AS INTEGER = 0x0049 CONSTANT LineNumber AS INTEGER = 0x002B SET TIMER1 TO ProfileRate PIPE PRINT COMM0 REM PRINT DPEEK(PEEK(FramePointer)), "\013\010" PRINT DPEEK(LineNumber), "\013\010" END