ActiveState::StopWatch(3)

NAME
ActiveState::StopWatch - Time code

SYNOPSIS
 use ActiveState::StopWatch qw(start_watch stop_watch read_watch real_time);

 my $w = start_watch();
 # ... do stuff ...
 print read_watch($w);
 # ... do stuff ...
 print stop_watch($w);

 # restart it
 start_watch($w);
 print stop_watch($w);

DESCRIPTION
The ActiveState::StopWatch module provide functions that can be used to measure the time spent by sections of code. The following functions are provided:

$w = start_watch()
start_watch( $w )
    Without argument this function creates a new watch object. With argument it can restart a watch that has been stopped after invoking the stop_watch() function on it. If the watch provided is not stopped then its state is not affected.

$str = read_watch( $w )
    This function returns a string that tells how much real, user and system time has ticked during the time the watch has been running. The string will look like this:

      r=12.5s u=4.90s s=0.55s cu=1.22s cs=0.22s

    The 'cu' and 'cs' field gives time spent in children of the current process during the time the watch has been running. The child fields are not shown if they are 0.

$str = stop_watch( $w )
    This function return a string of the same format as for read_watch(), but it will also stop the clock from running. This means that read_watch() will continue to return the same result. The watch can be restarted by calling start_watch() with the watch object as argument.

$r = real_time( $w )
    This function returns the number of seconds of real time passed during the time the watch has been running.

Only the start_watch() and stop_watch() functions are exported by default.

COPYRIGHT
Copyright (C) 2003 ActiveState Corp. All rights reserved.