gprof

GPROF(1)                    General Commands Manual                   GPROF(1)



åå
       gprof - ã³ã¼ã«ã»ã°ã©ã (call graph) ã®ãããã¡ã¤ã«ã表示ãã

æ¸å¼
       gprof [ -abcsz ] [ -e|-E name ] [ -f|-F name ] [ -k fromname toname ] [
       objfile [ gmon.out ] ]

説æ
       gprof 㯠C, Pascal, Fortran77 ããã°ã©ã ã®å®è¡ãããã¡ã¤ã«ãçæãããå¼ã³åº
       ãããã«ã¼ãã³ã®å¤ã¯å¼ã³åºãåã«åãè¾¼ã¾ããããããã¡ã¤ã«ã®ããã®ãã¼
       ã¿ã¯ã³ã¼ã«ã»ã°ã©ã (call graph: é¢æ°ã³ã¼ã«ã®è¦ªåé¢ä¿ã®ã°ã©ã) ã®ãããã¡
       ã¤ã«ãã¼ã¿ãã¡ã¤ã« (ããã©ã«ãã§ã¯ `gmon.out') ããåã è¾¼ã¾ããããã®ãã¡ã¤ã«ã¯
       cc(1)ã pc(1)ã f77(1) 㧠-pg ãªãã·ã§ã³ãæå®ãã¦ã³ã³ãã¤ã«ããããã‐
       ã°ã©ã ã«ãã£ã¦ä½æãããã -pg ãªãã·ã§ã³ã§ã¯ããªã³ã¯ãããã©ã¤ãã©ãªããã‐
       ãã¡ã¤ã«ç¨ã«ã³ã³ãã¤ã«ãã ããã®ã«ãªãã gprof ã¯æå®ããããªãã¸ã§ã¯ããã¡ã¤ã«
       (ããã©ã«ã㯠`a.out') ããã·ã³ã ã«ãã¼ãã«ãèªã¿ããã㨠`gmon.out'
       ã®ã³ã¼ã«ã»ã°ã©ãã»ãããã¡ã¤ã«ã¨ã é¢é£ä»ããã è¤æ°ã®ãã‐
       ãã¡ã¤ã«ãã¼ã¿ãã¡ã¤ã«ãæå®ãããå ´åã«ã¯ã gprof ã¯ãããã®ãã‐
       ãã¡ã¤ã«æå ±ããã¹ã¦åè¨ãã¦è¡¨ç¤ºããã

       gprof ã¯ããããã®ã«ã¼ãã³ã«ãã£ã¦æ¶è²»ãããæéãè¨ç®ããã次ã«ãããã®æé
       ãã³ã¼ã«ã»ã°ã©ãã®æã«æ²¿ã£ã¦è¦ªã«ã¼ãã³ã¸ã¨ä¼æããããããã°ã©ã ã® ãµã¤ã¯ã«
       (cycle: å帰å¼ã³åºãã®å¾ªç°) ãã¾ã¨ãããµã¤ã¯ã«ã¸ã®ã³ã¼ã«ãè¡ã£
       ãã«ã¼ãã³ã¯ããµã¤ã¯ã«ã§æ¶è²»ããæéãå±æããã¨ã¿ãªããæåã®ãªã¹ãã¯
       é¢æ°ã§ãæ¶è²»æéã®é ã«ã½ã¼ãããã¦ããã æ¶è²»æéã«ã¯ã³ã¼ã«ã»ã°ã©ãã§ã®åå‐
       «ã®åãå«ã¾ãããããããã®é¢æ°ã¨ã³ã㪠ã®ä¸ã«ã¯ããã®é¢æ°ã®ã³ã¼ã«ã»ã°ã©ãã§ã®
       (ç´æ¥ã®) åã¨ãããã§æ¶è²»ããã æéãã©ã®ããã«é¢æ°ã«ä¼æ‐
       ãããã表示ããããåæ§ã®è¡¨ç¤ºã¯é¢æ°ã®ä¸ã«ã 表示ããã¦ããããã®é¢æ°ã¨ãããã®åå‐
       «ã§æ¶è²»ãããæéãã©ã®ããã«ã³ã¼ ã«ã»ã°ã©ãã® (ç´æ¥ã®) 親ã¸ä¼æãããã示ãããã

       ãµã¤ã¯ã«ã表示ãããããµã¤ã¯ã«å¨ä½ã¨ãã¦ã®ã¨ã³ããªããã®ãµã¤ã¯ã«ã«å±ã
       ãã¡ã³ãã¼ã®ãªã¹ãã¨ããããã®ã¡ã³ãã¼ã«ãã£ã¦æ¶è²»ãããæéããã®
       ãµã¤ã¯ã«ã®å¼ã³åºãåæ°ãªã©ã表示ãããã

       次ã«ãã©ãããããã¡ã¤ã« (prof(1) ã®çµæã¨ä¼¼ããã®)
       ãä¸ããããããã®ãªã¹ãã§ã¯åè¨å®è¡æéãå¼ã³åºãå æ°ããã®ã«ã¼ãã³èªèº«ã§æ¶è²»ããæé
       (ããªç§åä½)ãåå«ã®åãå«ãã¦æ¶è²» ããæé (ããªç§åä½) ã表示ãããã

       æå¾ã«é¢æ°åã®ç´¢å¼ãä¸ããããã

ãªãã·ã§ã³
       以ä¸ã®ãªãã·ã§ã³ãæå®ã§ãã:

       -a     ã¹ã¿ãã£ãã¯ã«å®£è¨ãããé¢æ°ã表示ããªãããã®ãªãã·ã§ã³ãæå®ãã
              ãã¨ãã¹ã¿ãã£ãã¯ãªé¢æ°ã«é¢ããå¨ã¦ã®æå ± (å®è¡æéãä»ã®é¢æ°ã®å¼ã³åº
              ããä»ã®é¢æ°ããå¼ã³åºãããé¢ä¿ãªã©) ã¯ããã¡ã¤ã« `objfile' ä¸ã§ãã®
              ã¹ã¿ãã£ãã¯ãªé¢æ°ã®ç´åã«ãã¼ããããé¢æ°ã«å±ãããã¨ã«ãªãã

       -b     ãããã¡ã¤ã«ã®ããããã®ãã£ã¼ã«ãã«é¢ãã説æã表示ããªãã

       -c     ããã°ã©ã ã®ã¹ã¿ãã£ãã¯ãªã³ã¼ã«ã»ã°ã©ããããªãã¸ã§ã¯ããã¡ã¤ã«ã®ãã
              ã¹ãã»ã°ã¡ã³ãã調ã¹ãã¨ããçºè¦ç (heuristic) ãªææ³ã§ä½æãããã¹
              ã¿ãã£ãã¯ã»ã³ã¼ã«ã ãã®è¦ªãåã®å¼ã³åºãåæ°ã¯ 0 ã¨ãã¦è¡¨ç¤ºããã

       -e name
              ã«ã¼ãã³ name ã¨ããã®åå«ãã¹ã¦ã«é¢ããã°ã©ããã‐
              ãã¡ã¤ã«ã®ã¨ã³ããªã表示ããªã (åå‐
              «ã«é¢ãã¦ã¯ãå¥ã®ç¥åãããã°è¡¨ç¤ºããã)ã -e
              ãªãã·ã§ã³ã¯è¤æ°åæå®ã§ãããä¸ã¤ã® -e ãªãã·ã§ã³ã«ã¤ãã¦æå®ã§ãã name
              ã¯ä¸ã¤ã ãã§ããã

       -E name
              -e ã¨åæ§ã«ã«ã¼ãã³ name ã¨ãã®åå«ã«é¢ããã°ã©ããã‐
              ãã¡ã¤ã«ã®ã¨ã³ããªã表示ããªããã¾ã name (ã¨ãã®åå«)
              ã«ãã£ã¦æ¶è²»ãããæéããããã°ã©ã å®è¡ã®ç·æé (ããã³ ãã¼ã»ã³ãã¼ã¸ã®è¨ç®)
              ããé¤ããããä¾ãã° -E mcount -E mcleanup ã¯ããã©ã«ãã«ãªã£ã¦ããã

       -f name
              ã«ã¼ãã³ name ã¨ãã®åå«ã«é¢ãã¦ã®ã¿ãã°ã©ããã‐
              ãã¡ã¤ã«ã®ã¨ã³ããªã表示ããã -f ãªãã·ã§ã³ã¯è¤æ°åæå®ã§ãããä¸ã¤ã® -f
              ãªãã·ã§ã³ã«ã¤ãã¦æå®ã§ãã name ã¯ä¸ã¤ã ãã§ããã

       -F name
              -f ã¨åæ§ã«ãã«ã¼ãã³ name ã¨ãã®åå«ã«é¢ãã¦ã®ã¿ãã°ã©ããã‐
              ãã¡ã¤ã«ã®ã¨ã³ããªã表示ãããã¾ãã
              ããã«ãã£ã¦ç¨ããããæéã ããåè¨ã®å®è¡æéã¨ãã¼ã»ã³ãã¼ã¸ã®è¨ç®ã« ç¨ããã -F
              ãªãã·ã§ã³ã¯è¤æ°æå®ã§ãããä¸ã¤ã® -F ãªãã·ã§ã³ã«ã¤ãã¦æå®ã§ãã name
              ã¯ä¸ã¤ã ãã§ããã -F ãªãã·ã§ã³ã¯ -E ãªãã·ã§ã³ã«ããè¨å®ãä¸æ¸ãããã

       -k fromname toname
              ã«ã¼ãã³ fromname ããã«ã¼ãã³ toname
              ã¾ã§ã®æãåé¤ãããããã¯ä¸è¦ãªãµã¤ã¯ã«ã®å¾ªç°ãç ´å£ããã®ã«ä¾¿å©ã§ããã -k
              ã¯è¤æ°æå®ã§ãããä¸ã¤ã® -k
              ãªãã·ã§ã³ã«å¯¾ãã¦æå®ã§ããã®ã¯ä¸çµã®ã«ã¼ãã³åã ãã§ããã

       -s     ãããã¡ã¤ã«ãã¡ã¤ã« `gmon.sum' ãä½æããæå®ãããããã¡ã¤ã«ãã¡ã¤ã«
              ã®æå ±ãã¹ã¦ããã®ãããã¡ã¤ã«æå ±ãç·è¨ãããã®ãæ¸ãè¾¼ãããã®åè¨ã ã‐
              ãã¡ã¤ã«ãã¡ã¤ã«ã¯å¾ã« gprof ã (ãããã㯠-s ã¨å±ã«) å®è¡ããéã«ä¸ãã¦ã
              `objfile' ãã¡ã¤ã«ãè¤æ°åå®è¡ãã¦å¾ãã ããã‐
              ãã¡ã¤ã«ãã¼ã¿ãç´¯ç©ããããã«ç¨ãããã¨ãã§ããã

       -v     gprof ã®ãã¼ã¸ã§ã³çªå·ã表示ãã¦çµäºããã

       -z     ç¨ããããªãã£ãé¢æ° (å¼ã³åºãåæ°ã¨å®è¡æéã§ããã) ã表示ããããã ã -c
              ãªãã·ã§ã³ã¨å±ã«ç¨ããã¨ãå¼ã³åºãããªãã£ãã«ã¼ãã³ãè¦ã¤ããã®ã«å½¹
              ã«ç«ã¤ã

ãã¡ã¤ã«
       a.out       ååã®ãªã¹ãã¨ããã¹ã空é
       gmon.out    ãã¤ãããã¯ãªã³ã¼ã«ã»ã°ã©ãã¨ãããã¡ã¤ã«
       gmon.sum    ãã¤ãããã¯ãªã³ã¼ã«ã»ã°ã©ãã¨ãããã¡ã¤ã«ã®ã¾ã¨ã


é¢é£é ç®
       monitor(3), profil(2), cc(1), prof(1)

       ``An Execution Profiler for Modular Programs'', by S. Graham, P.
       Kessler, M. McKusick; Software - Practice and Experience, Vol. 13, pp.
       671-685, 1983.

       ``gprof: A Call Graph Execution Profiler'', by S. Graham, P. Kessler,
       M. McKusick; Proceedings of the SIGPLAN '82 Symposium on Compiler
       Construction, SIGPLAN Notices, Vol. 17, No  6, pp. 120-126, June 1982.


å±¥æ´
       gprof 㯠4.2 BSD ããç»å ´ããã

ãã°
       ãµã³ããªã³ã°ã®ç²åº¦ (granularity) ã表示ãããããããããçµ±è¨çãªãã®
       ã§ãããªããããã§ã¯é¢æ°ã®ä¸åãããã®å®è¡æéã¯ãé¢æ°ã®æ¶è²»ããåè¨æ
       éãå¼ã³åºãåæ°ã§å²ã£ããã®ã¨ä»®å®ãã¦ããããããã£ã¦ãå¼ã³åºãã°ã©ãã® æãä¼æ‐
       ãã¦é¢æ°ã®è¦ªã«ä¼ããæéã¯ãæãééããåæ°ã«ç´ã«æ¯ä¾ããã㨠ã«ãªãã

       èªåèªèº«ããããã¡ã¤ã«ããã¦ããªã親ã§ããåããä¼æãã¦ããæéãä¿æ
       ãããã¨ã«ãªããããããããã®ã«ã¼ãã³ã¯ãå¼ã³åºãã°ã©ãã®ä¸ã§ (ã©ãã
       ãå¼ã³åºãããã®ã§ããªã) åæã«èµ·åããããã«è¦ããã®ã§ããã®æéã¯ã ã以ä¸ã©ãã¸ãä¼æ‐
       ããªããåæ§ã«ãã·ã°ãã«ããã£ããããã«ã¼ãã³ã¯ãã ã‐
       ãã¡ã¤ã«ããã¦ãã¦ãåæã«èµ·åããããã«è¦ãã¦ãã¾ã (çç±ã¯ããå°ã è¤éã ã)ãã·ã°ãã«ãã‐
       ã£ããããã«ã¼ãã³ã®åããããã¡ã¤ã«ããã¦ã ãã°ãã®æéãæ£ããä¼æ‐
       ããããã¨ãã§ãããã親ã«ã¼ãã³ããããã¡ ã¤ã«ã«ã¼ãã³ã®éä¸ã§ã·ã°ãã«ãã‐
       ã£ãããããå ´åã«ã¯å¨ã¦ã®æå ±ã¯å¤±ãããã

       ãããã¡ã¤ã«ãããããã°ã©ã 㯠exit(2) ãã³ã¼ã«ãã¦çµäºãããã main ã«ã¼ãã³ããã®
       return ã§çµäºããªããã°ãª ããªãããããªãã¨çµäºæã«ãããã¡ã¤ã«æå ±ã `gmon.out'
       ãã¡ã¤ã«ã«ã»ã¼ ããããªãã



                               January 29, 1993                       GPROF(1)