ActiveState::StopWatch - Time code
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);
The ActiveState::StopWatch module provide functions that can be used to measure the time spent by sections of code. The following functions are provided:
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.
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.
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.
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 (C) 2003 ActiveState Corp. All rights reserved.