Time::Elapse

Time::Elapse is a Perl extension for monitoring time conveniently during tasks.
Download

Time::Elapse Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Scott R. Godin
  • Publisher web site:
  • http://search.cpan.org/~sgodin/Time-Elapse-1.2402/Elapse.pm

Time::Elapse Tags


Time::Elapse Description

Time::Elapse is a Perl extension for monitoring time conveniently during tasks. Time::Elapse is a Perl extension for monitoring time conveniently during tasks.Time::Elapse is a very simple class with one method: lapse.Basically, the lapse method 'eats the brains' of the variable, squirrels away whatever value it may have held internally, (much like space aliens are known to do in the movies), and also stores the current time within it. Then, whenever you access the value of the variable, the 'alien' within formats the time differential between when you initialized the variable, and when you printed it, and returns that (along with any value the variable may hold, as well). :-) Every time you print it, you get the updated differential, returned by the method hidden inside the variable itself. The output will be formatted as HH:MM:SS.000000 .Frankly it doesn't do much more than time(), but then again the simplest things rarely do.All it really does is hides the calculations that anyone else would have had to set up manually in a clever way and then produce a reasonably formatted output which lends itself equally well to single-line output or inlining with other text.SYNOPSISUsageTo use Elapse is simplicity itself: use Time::Elapse; # somewhere in your program... Time::Elapse->lapse(my $now); # or you can do: # Time::Elapse->lapse(my $now = "processing"); #...rest of program execution print "Time Wasted: $nown";To update the description and reset the time counter mid-stream, simply assign to the variable $now = "parsing";somewhere in the middle of the program. The new value is stored, while the original time is replaced with the current time.Sample OutputOutput looks something like this, using above code: Time Wasted: 00:00:05.565763 or Time Wasted: 00:00:03.016700 (more output) Time Wasted: 00:00:02.003764 Additional example codeYou can also use this during a Net::FTP download loop of files to show elapsed time for each file's download. foreach my $file (@files_to_download) { # extract localfile name from $file # ... Time::Elapse->lapse(my $now = "Downloading $localfile."); $ftp->get($file, $localfile) or carp("### Could not download $file! $!") and next; print "Done. Elapsed : $nown"; # ... }This can also be a useful trick when you're processing a lot of data from multiple sources. Requirements: · Perl


Time::Elapse Related Software