in reply to Clocking Portion of Your Perl Code

An example -
#!/usr/bin/perl -w use Benchmark; my $start_time = new Benchmark; $line++ while (<>); # Count number of lines in the file(s) my $end_time = new Benchmark; my $difference = timediff($end_time, $start_time); print ("Counted $line lines\n"); print ("It took ", timestr($difference), "\n");
Usage/Output:

[sk]% bench *.csv Counted 900285 lines It took 2 wallclock secs ( 1.88 usr + 0.27 sys = 2.15 CPU)

Replies are listed 'Best First'.
Re^2: Clocking Portion of Your Perl Code
by Anonymous Monk on Jun 12, 2005 at 09:57 UTC
    Hi,
    THanks for the reply.
    >It took 2 wallclock secs ( 1.88 usr + 0.27 sys = 2.15 CPU)
    What's the difference between these three:
    wallclock usr sys

      In short, the wallclock time elapsed is the real (actual) time that passed during the execution of your program. The CPU time is the time it took for the CPU to execute the program, taking into account the fact that your program may not be the only thing running at the moment, so that more or less this is independent of the load on your system. CPU time is further broken down into time used for system calls and time spent actually in your code.

      Using the time Command to Measure CPU Use, despite being a guide for AIX users, has a pretty good explanation as well.