home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / profile1.zip / PROFILE.DOC < prev    next >
Text File  |  1991-01-26  |  3KB  |  71 lines

  1.                     *** OS/2 Profiler ***
  2.  
  3.   These files are the source code for very simple profiler for OS/2.  Yes,
  4. I admit, it's a kludge; but it works.
  5.  
  6.   The profiler itself runs as a process seperate from the program being
  7. profiled.  It creates a small shared memory segment and runs at a time-critical
  8. priority.  It keeps looking at a SHORT variable in the memory segment and
  9. maintains a histogram of the values found in the variable.  When it finds
  10. an exit code in the variable, or it receives a ^C, it exits and prints out
  11. a frequency distribution of the values it found in the variable.
  12.  
  13.   The program being profiled must be slightly modified to include the code
  14. at function entry and exit to update the variable, and the code to access
  15. and free the shared memory segment.
  16.  
  17.   I wrote the profiler to help in speeding up a batch program that ran at
  18. a glacial rate, and it met the objective perfectly.  The profiler can easily
  19. be extended to handle multi-thread programs and recursive function calls.
  20. I release this program to the public domaine.  May it be useful to other
  21. OS/2 programmers.  Comments and suggestions are welcome.
  22.  
  23.       Andrew Goodman
  24.       Compuserve 72010,3113
  25.  
  26.  
  27.                       *** Instructions ***
  28.  
  29. --- To prepare:
  30.  
  31. A.  Compile the profiler
  32.  
  33.     Study the profiler code (PROFILE.C) and the include file (PROFILE.H).
  34.     Compile.  I used the large model.
  35.  
  36. B.  Modify the target file
  37.  
  38.     1.  Add the statement "#define PROFILE 1" *before* including PROFILE.H
  39.         in every module.  To turn off the inclusion of profiler code in the
  40.         target functions, comment out this define.
  41.  
  42.     2.  Include PROFILE.H in every module.
  43.  
  44.     3.  Add the variable  "PROMESSAGE   *pPM;"
  45.  
  46.     4.  Add the functions "fnusIPro" and "fnvXPro" to at least one module
  47.  
  48.     5.  Modify all the functions.  As the first line of each function after
  49.         any local variable declarations, add the line "ENTER(x);", where
  50.         x is a sequential number starting at 1.  Don't add ENTER to main().
  51.         add the line "LEAVE;" at every exit point except in main().  Needless
  52.         to say, be careful: if you miss a function entry or exit, you will
  53.         blow out the profiler stack.
  54.  
  55.     6.  If needed, modify the target program so that it will run for 3-5
  56.         minutes.  The profiler does not look very often (by machine speeds)
  57.         to see what function is running, so you need a large sample set
  58.         for significant results.
  59.  
  60.     7.  Compile.  I used the large model.
  61.  
  62.  
  63. --- To use:
  64.  
  65.     A.  Run the profiler in an OS/2 command window.  You will probably want
  66.         to pipe the output to a file.
  67.  
  68.     B.  Run the target in a seperate session.
  69.  
  70.     C.  When the target completes, check the profiler output.
  71.