1
0

prof 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. .TH PROF 1
  2. .SH NAME
  3. prof, tprof, kprof \- display profiling data
  4. .SH SYNOPSIS
  5. .B prof
  6. [
  7. .B -dr
  8. ]
  9. [
  10. .I program
  11. ]
  12. [
  13. .I profile
  14. ]
  15. .PP
  16. .B tprof
  17. .I pid
  18. .PP
  19. .B kprof
  20. .I kernel
  21. .I kpdata
  22. .SH DESCRIPTION
  23. .I Prof
  24. interprets files produced automatically by programs loaded using the
  25. .B -p
  26. option of
  27. .IR 2l (1)
  28. or other loader.
  29. The symbol table in the
  30. named program file
  31. .RL ( 2.out
  32. etc., according to
  33. .BR $objtype ,
  34. by default)
  35. is read and correlated with the
  36. profile file
  37. .RL ( prof.out
  38. by default).
  39. For each symbol, the percentage
  40. of time (in seconds) spent executing between that symbol
  41. and the next
  42. is printed (in decreasing order),
  43. together with the time spent there and
  44. the number of times that routine was called.
  45. .PP
  46. Under option
  47. .BR -d ,
  48. .I prof
  49. prints the dynamic call graph of the target program,
  50. annotating the calls with the time spent in each routine
  51. and those it calls, recursively. The output is indented
  52. two spaces for each call, and is formatted as
  53. .EX
  54. symbol:time/ncall
  55. .EE
  56. where
  57. .I symbol
  58. is the entry point of the call,
  59. .I time
  60. is in milliseconds,
  61. and
  62. .I ncall
  63. is the number of times that entry point was called at that
  64. point in the call graph. If
  65. .I ncall
  66. is one, the
  67. .B /ncall
  68. is elided.
  69. Normally recursive calls are compressed to keep the output brief;
  70. option
  71. .B -r
  72. prints the full call graph.
  73. .PP
  74. The size of the buffer
  75. in
  76. .I program
  77. used to hold the profiling
  78. data, by default 2000 entries,
  79. may be controlled by setting the environment variable
  80. .B profsize
  81. before running
  82. .IR program .
  83. If the buffer fills, subsequent function calls may not be recorded.
  84. .PP
  85. .I Tprof
  86. is similar to
  87. .IR prof ,
  88. but is intended for profiling multiprocess programs.
  89. It uses the
  90. .BI /proc/ pid /profile
  91. file to collect instruction frequency counts for the text image associated with the process,
  92. for all processes that share that text.
  93. It must be run while the program is still active, since the data is stored with the running program.
  94. To enable
  95. .I tprof
  96. profiling for a given process,
  97. .EX
  98. echo profile > /proc/\f2pid\f1/ctl
  99. .EE
  100. and then, after the program has run for a while, execute
  101. .EX
  102. tprof \f2pid\f1
  103. .EE
  104. Since the data collected for
  105. .I tprof
  106. is based on interrupt-time sampling of the program counter,
  107. .I tprof
  108. has no
  109. .B -d
  110. or
  111. .B -r
  112. options.
  113. .PP
  114. .I Kprof
  115. is similar to
  116. .IR prof ,
  117. but presents the data accumulated by the kernel
  118. profiling device,
  119. .IR kprof (3) .
  120. The symbol table file, that of the operating system kernel,
  121. and the data file, typically
  122. .BR /dev/kpdata ,
  123. must be provided.
  124. .I Kprof
  125. has no options and cannot present dynamic data.
  126. .SH SOURCE
  127. .B /sys/src/cmd/prof.c
  128. .br
  129. .B /sys/src/cmd/kprof.c
  130. .SH SEE ALSO
  131. .IR 2l (1),
  132. .IR kprof (3)