Loginskip to content

November 1st, 2006

So make the code you benchmark as close

sub sym { $symlinks++ } sub dir { $dirs++ } sub regular { $regulars++ } sub sock { $sockets++ } sub block { $blocks++ } sub char { $chars++ } sub other { $others++ } This code is purposely broken out into subroutines rather than the more obvious data-driven solution of using a hash keyed by statflags to illustrate how Devel::DProf works. (Note that we again eschewed our usual brace style in the file type counting subroutines in favor of something more compact and more readable in this case.) You may be wondering why there is no mention of Devel::DProf in the source code; the answer is that this is a special module that is invoked by the -d option as an alternate debugger module. (So instead of the default module, which presents a command-line interface for stepping through your program, Devel::DProf basically intercepts subroutine calls[4] and starts a stopwatch.) This is how we run it: [4] Unfortunately, it is not possible to profile on a finer granularity than subroutines. $ perl -d:DProf dirwalk Symlinks: 1804, Dirs: 4519, Regulars: 67319 Sockets: 7, Blocks: 3467, Chars: 1856, Others: 50 This creates a file tmon.out (you can change the name with the environment variable PERL_DPROF_OUT_FILE_NAME) in the current directory and puts raw tracing information in it. The tool that can cook that information into something palatable for you is dprofpp: $ dprofpp Total Elapsed Time = 25.03237 Seconds User+System Time = 24.83237 Seconds Exclusive Times %Time ExclSec CumulS #Calls sec/call Csec/c Name 81.1 20.14 20.755 79022 0.0003 0.0003 main::process 28.8 7.157 146.90 4520 0.0016 0.0325 main::doit 9.05 2.248 1.678 67319 0.0000 0.0000 main::regular 0.56 0.140 0.102 4519 0.0000 0.0000 main::dir 0.36 0.090 0.061 3467 0.0000 0.0000 main::block 0.28 0.070 0.055 1804 0.0000 0.0000 main::sym 0.16 0.040 0.024 1856 0.0000 0.0000 main::char 0.04 0.010 0.010 1 0.0100 0.0100 main::BEGIN 0.00 0.000 -0.000 1 0.0000 -strict::import 0.00 0.000 -0.000 50 0.0000 -main::other 0.00 0.000 -0.000 7 0.0000 -main::sock 0.00 0.000 -0.000 1 0.0000 -strict::bits
Note: If you are looking for good and high quality web space to host and run your java application check Vision java hosting services

Comments are closed.