home *** CD-ROM | disk | FTP | other *** search
-
- { The Code Profiler gives you statistics about the execution behavior of your programs. }
- { This tool measures the time spent in each routine, as well as the number of statements }
- { executed in each routine . }
-
- { To use the profiler, you must add it to your project. Both the library file 'Profile.Lib' }
- { and the interface file 'Profile.p' must be added. You also must have a 'USES Profiler' }
- { in your program . }
-
- { WARNING: Profile.lib must be put in the same segment as your main program. }
- { If it is not, a LoadSeg may occur which may scramble your heap at a most }
- { inopportune time. }
-
- { The profiler is controlled by procedure calls made from your program. There is a call }
- { to initialize and install the profiler, a call to dump the statistics at the point you }
- { need them, and a call to de-install the profiler where you are done with it (typically, }
- { the end of your program). There is also a call to reset the profiler, so that you can }
- { collect two different sets of statistics in the same run of your program. }
-
- { The profiler only measures routines that have been compiled with the Debug option on. }
- { The profiler identifies routines in your program with the name stored }
- { in the code when a routine is compiled with the Names option on. If the Names option }
- { is not on, eight question marks (i.e. '????????') are used for the name. }
-
- { Up to two hundred active procedures may be profiled. If more procedures are activated }
- { (as might happen in a heavily recursive program), the profiler de-installs itself. }
-
- { Up to two hundred routine names can be tracked by the profiler. If more than two }
- { hundred procedures are called, statistics for the extra procedures will appear at the end of }
- { the profile listing. }
-
- { You can save memory, or allocate room for more procedures, by using "InitProfiler" instead }
- { of "InitProfile". Each activation requires 14 bytes of memory, and each procedure record }
- { requires 94 bytes of memory. }
-
- { To summarize, call InitProfile at he start of the code you want profiled. When you }
- { want to display the profiling information, call DumpProfile. After dumping statistics, }
- { if you want to restart the profiler, call ResetProfiler. When you are all done, call }
- { TerminateProfile. }
-
- unit Profiler;
- interface
-
- procedure InitProfile;
- { This routine must be called first to initialize the profiler. It causes the }
- { profiler to start gathering execution statistics. All subsequent routine calls in }
- { your program will be measured. }
-
- procedure DumpProfile;
- { This routine causes the profiler to dump the current information about your program }
- { to the Text Window. }
-
- procedure DumpProfileToFile (fileName: Str255);
- { This routine causes the profiler to dump the current profiler statistics to the file }
- { specified by "fileName", in the default volume (usually the same directory as the }
- { running project, unless the program has done a SetVol). If the file already exists, }
- { it will be deleted and overwritten. }
-
- procedure ResetProfile;
- { This routine reinitializes all the statistical information. }
-
- procedure TerminateProfile;
- { This routine de-installs the profiler from the executing program. }
-
- function InitProfiler (nEntries: Integer): Boolean;
- { "InitProfiler" is a more flexible form of "InitProfile"; it will enable the profiler to }
- { measure an arbitrary (up to 32,768) number of routines. InitProfiler will return }
- { TRUE if the initialization completed successfully, FALSE if not. }
-
- implementation
-
- { All of the above routines are externally defined in Profile.Lib. }
-
- end.