home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / misc / update / tpasc302.cpt / Profiler / Profile.p < prev   
Encoding:
Text File  |  1990-04-21  |  3.8 KB  |  74 lines

  1.  
  2. { The Code Profiler gives you statistics about the execution behavior of your programs.            }
  3. { This tool measures the time spent in each routine, as well as the number of statements         }
  4. { executed in each routine .                                                                                 }
  5.  
  6. { To use the profiler, you must add it to your project.  Both the library file 'Profile.Lib'            }
  7. { and the interface file 'Profile.p' must be added.  You also must have a 'USES Profiler'             }
  8. { in your program .                                                                                         }
  9.  
  10. { WARNING:     Profile.lib must be put in the same segment as your main program.                    }
  11. {             If it is not, a LoadSeg may occur which may scramble your heap at a most                 }
  12. {            inopportune time.                                                                                 }
  13.  
  14. { The profiler is controlled by procedure calls made from your program.  There is a call             }
  15. { to initialize and install the profiler, a call to dump the statistics at the point you                 }
  16. { need them, and a call to de-install the profiler where you are done with it (typically,            }
  17. { the end of your program).  There is also a call to reset the profiler, so that you can             }
  18. { collect two different sets of statistics in the same run of your program.                             }
  19.  
  20. { The profiler only measures routines that have been compiled with the Debug option on.          }
  21. { The profiler identifies routines in your program with the name stored                             }
  22. { in the code when a routine is compiled with the Names option on.  If the Names option             }
  23. { is not on, eight question marks (i.e. '????????') are used for the name.                             }
  24.  
  25. { Up to two hundred active procedures may be profiled.  If more procedures are activated         }
  26. { (as might happen in a heavily recursive program), the profiler de-installs itself.                 }
  27.  
  28. { Up to two hundred routine names can be tracked by the profiler.  If more than two                  }
  29. { hundred procedures are called, statistics for the extra procedures will appear at the end of    }
  30. { the profile listing.                                                                                         }
  31.  
  32. { You can save memory, or allocate room for more procedures, by using "InitProfiler" instead    }
  33. { of "InitProfile". Each activation requires 14 bytes of memory, and each procedure record        }
  34. { requires 94 bytes of memory.                                                                            }
  35.  
  36. { To summarize, call InitProfile at he start of the code you want profiled.  When you                 }
  37. { want to display the profiling information, call DumpProfile.  After dumping statistics,            }
  38. { if you want to restart the profiler, call ResetProfiler.  When you are all done, call                 }
  39. { TerminateProfile.                                                                                         }
  40.  
  41. unit Profiler;
  42. interface
  43.  
  44.     procedure InitProfile;
  45.     { This routine must be called first to initialize the profiler.  It causes the                     }
  46.     { profiler to start gathering execution statistics.  All subsequent routine calls in             }
  47.     { your program will be measured.                                                                 }
  48.  
  49.     procedure DumpProfile;
  50.     { This routine causes the profiler to dump the current information about your program    }
  51.     { to the Text Window.                                                                            }
  52.  
  53.     procedure DumpProfileToFile (fileName: Str255);
  54.     {    This routine causes the profiler to dump the current profiler statistics to the file        }
  55.     {    specified by "fileName", in the default volume (usually the same directory as the        }
  56.     {    running project, unless the program has done a SetVol). If the file already exists,        }
  57.     {    it will be deleted and overwritten.                                                            }
  58.  
  59.     procedure ResetProfile;
  60.     { This routine reinitializes all the statistical information. }
  61.  
  62.     procedure TerminateProfile;
  63.     { This routine de-installs the profiler from the executing program.     }
  64.  
  65.     function InitProfiler (nEntries: Integer): Boolean;
  66.     {    "InitProfiler" is a more flexible form of "InitProfile"; it will enable the profiler to    }
  67.     {    measure an arbitrary (up to 32,768) number of routines. InitProfiler will return        }
  68.     {    TRUE if the initialization completed successfully, FALSE if not.                            }
  69.  
  70. implementation
  71.  
  72.     {    All of the above routines are externally defined in Profile.Lib.                            }
  73.  
  74. end.