I was curious about the startup time of my program, so I wanted to figure out how many lines of code were being loaded and how long that was taking.

So I created "MM.pm", and loaded my top-level module with perl -MMM -MMy::Module -e0. MM shows real time, and cpu for user, system, child user, and child system, and then opens each of the included modules and gives a line count, including a total linecount.

package MM; my @times = (time, times); END { warn sprintf("real %d, user %.2g, sys %.2g, cuser %.2g, csys %.2g\n" +, map { $_ - shift @times } time, times); local *ARGV; @ARGV = sort values %INC; my $sum = 0; while (<>) { next unless eof; warn "$ARGV: $.\n"; $sum += $.; close ARGV; } warn "total: $sum\n"; } 1;

Replies are listed 'Best First'.
Re: quick startup time profiler
by ysth (Canon) on Sep 18, 2006 at 02:34 UTC
    system 'wc', '-l', '--', sort values %INC;
Re: quick startup time profiler
by Anonymous Monk on Sep 18, 2006 at 03:11 UTC
    Devel::MM? perl -d:MM foobar?