Devel::DProf - ã·ã³ãã«ãªãããã¡ã¤ã©
Perl
›
ã¢ã¸ã¥ã¼ã«
›
here
ãããã°ã©ã ãå®è¡ãã¦ãå¿ è¦ãªããã©ã¼ãã³ã¹ãå¾ãããªããã¨ãããã¾ããã©ã®é¨åãããã«ããã¯ã«ãªã£ã¦ããã®ãã調ã¹ãã®ã¯ç°¡åãªãã¨ã§ã¯ããã¾ããããããã¡ã¤ã©ã¨å¼ã°ãããã¼ã«ãå©ç¨ããã°ããã°ã©ã ã®ä¸ã®ã©ã®å¦çã§æéãããã£ã¦ãããã調ã¹ããã¨ãã§ãã¾ãã(ç¾å¨ã§ããã°Devel::NYTProfãå©ç¨ããã®ãããã§ãããã)
ãæ¨æºã¢ã¸ã¥ã¼ã«ã«ã·ã³ãã«ãªãããã¡ã¤ã©ã§ããDevel::DProfã¢ã¸ã¥ã¼ã«ãããã®ã§ãããå©ç¨ãããã¨ãã§ãã¾ãã
ããããã¡ã¤ã«ãä½æããã®ã¯ç°¡åã§ãã次ã®ã³ãã³ããå®è¡ããã¨ã«ã¬ã³ããã£ã¬ã¯ããªã«ãtmon.outãã¨ãããããã¡ã¤ã«ãæ å ±ãåºåãããã¡ã¤ã«ãä½æããã¾ãã
# ãããã¡ã¤ã«æ å ±ã®ä½æ perl -d:DProf target.pl
ããtmon.outããè¦ããããã©ã¼ãããã§è¡¨ç¤ºããã«ã¯dprofppã³ãã³ããå®è¡ãã¾ãã
# ãããã¡ã¤ã«ãè¦ããããã©ã¼ãããã§è¡¨ç¤º
dprofpp
ãããã¨æ¬¡ã®ãããªè¦ããããã©ã¼ãããã§åºåããã¾ãã
# ãããã¡ã¤ã« Total Elapsed Time = 1.171916 Seconds User+System Time = 1.171916 Seconds Exclusive Times %Time ExclSec CumulS #Calls sec/call Csec/c Name 78.6 0.922 0.922 2 0.4610 0.4610 main::func2 18.6 0.218 0.218 1 0.2180 0.2180 main::func1 1.37 0.016 0.016 5 0.0032 0.0032 main::BEGIN 0.00 - -0.000 1 - - strict::bits 0.00 - -0.000 2 - - strict::import 0.00 - -0.000 2 - - warnings::import
ãåé ç®ã®æå³ã¯æ¬¡ã®ããã«ãªã£ã¦ãã¾ããæéãããã£ãé ã«ä¸ä½ãã表示ããã¾ãã
%Time | ãµãã«ã¼ãã³ã®å®è¡æéã®å ¨ä½ã«å¯¾ããå²å |
ExclSec | ãµãã«ã¼ãã³ã®å®è¡æé(ãµãã«ã¼ãã³ã®å¼ã³åºããå«ã¾ãªã) |
CumulS | ãµãã«ã¼ãã³ã®å®è¡æé(ãµãã«ã¼ãã³ã®å¼ã³åºããå«ã) |
#Calls | ã«ã¼ãã³å¼ã³åºãåæ° |
sec/call | 1åãããã®ãµãã«ã¼ãã³ã®å®è¡æé(ãµãã«ã¼ãã³ã®å¼ã³åºããå«ã¾ãªã) |
Csec/c | 1åãããã®ãµãã«ã¼ãã³ã®å®è¡æé(ãµãã«ã¼ãã³ã®å¼ã³åºããå«ã) |
Name | ãµãã«ã¼ãã³å |
ãä¸è¨ã®çµæã¯ã¹ã¯ãªãããå®è¡ããå ´åã®ç§ã®ç°å¢ã§ã®çµæã§ãã
use strict; use warnings; func1(); func2(); func2(); sub func1 { my $i = 0; while ($i < 1000000) { $i++; } } sub func2 { my $i = 0; while ($i < 2000000) { $i++; } }