home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff232.lzh / Dbug / README.prof < prev    next >
Text File  |  1989-08-02  |  3KB  |  71 lines

  1. Hi,
  2.  
  3. I'm sending you the modifications I made to your Dbug routines to
  4. allow profiling in a (relatively) machine independent fashion.
  5. I use your Dbug routines fairly extensively.  Unfortunately, it's
  6. a royal pain to have to keep profiled versions of various libraries
  7. around.  The modifications allow profiling without the need for this.
  8.  
  9. How it works.
  10. ------------
  11.  
  12. Basically, I just added code in the dbug routines to write out a file
  13. called dbugmon.out (by default).  This is an ascii file containing lines
  14. of the form:
  15.  
  16. <function-name> E <time-entered>
  17. <function-name> X <time-exited>
  18.  
  19. A second program (analyze) reads this file, and produces a report on
  20. standard output.
  21.  
  22. Profiling is enabled through the `g' flag.  It can take a list of
  23. procedure names for which profiling is enabled.  By default, it
  24. profiles all procedures.
  25.  
  26. The code in ``dbug.c'' opens the profile file for appending.  This
  27. is in order that one can run a program several times, and get the
  28. sum total of all the times, etc.
  29.  
  30. The only system dependent part that I'm aware of is the routine
  31. Clock() at the end of dbug.c.  This returns the elapsed user time
  32. in milliseconds.  The version which I have is for 4.3 BSD.  As I
  33. don't have access to other systems, I'm not certain how this would
  34. change.
  35.  
  36. An example of the report generated follows:
  37.  
  38.         Profile of Execution
  39.         Execution times are in milliseconds
  40.  
  41.             Calls                Time
  42.             -----                ----
  43.         Times    Percentage    Time Spent    Percentage
  44. Function    Called    of total    in Function    of total    Importance
  45. ========    ======    ==========    ===========    ==========  ==========
  46. factorial               5         83.33             30        100.00        8333
  47. main                    1         16.67              0          0.00           0
  48. ========    ======    ==========    ===========    ==========
  49. Totals                  6        100.00             30        100.00
  50.  
  51.  
  52. As you can see, it's quite self-evident.  The ``Importance'' column is a
  53. metric obtained by multiplying the percentage of the calls and the percentage
  54. of the time.  Functions with higher 'importance' benefit the most from
  55. being sped up.
  56.  
  57. I'm really not certain how to add support for setjmp/longjmp, or for
  58. child processes, so I've ignored that for the time being.  In most of
  59. the code that I write, it isn't necessary.  If you have any good ideas,
  60. feel free to add them.
  61.  
  62. This has been very useful to me.  If you can use it as part of your
  63. dbug distribution, please feel free to do so.
  64.  
  65. Regards,
  66.  
  67.                 Binayak Banerjee
  68.         {allegra | astrovax | bpa | burdvax}!sjuvax!bbanerje
  69.             bbanerje%sjuvax.sju.edu@relay.cs.net
  70.                 July 9, 1987
  71.