in reply to Start / Stop Time Module

This would be good too, it would tell you what the start, stop, and duration of the execution along with the file name. Good if it's a CRON job...

Would this make a good module? I'd use it, and I offer to do it.
package Timer::StartStop; use strict; use Time::Elapse; Time::Elapse->lapse( my $now); BEGIN { print "$0 Started: " . ( scalar localtime ) . "\n"; } END { print "$0 Finished: " . ( scalar localtime ) . ", time = $now\n"; } 1;

Replies are listed 'Best First'.
Re^2: Start / Stop Time Module
by Tux (Canon) on Aug 13, 2010 at 06:24 UTC

    That means loading yet another non-core module. Why not use Time::HiRes instead, which is core.

    On a second note, IF you want to make this into a module, consider finding a way to accept options for what to print on start and exit. It might be very interesting to add an option that uses the values returned by times () to show resource use. It's a shame that there is no HiRes version for this function, but you might want to delve into getrusage () in BSD::Resource (which may not work on non-Unix boxes).

    If options like that were implemented correctly, it would certainly be worth releasing to CPAN.

    test.pl started : Fri Aug 13 08:23:10 2010 test.pl ended : Fri Aug 13 08:23:11 2010 duration: 00:00:01.51003 (usr: 0.41, sys: 0.19, cusr: 0, csys: + 0)

    update: being able to select the output (STDOUT or STDERR) would be another point of attention


    Enjoy, Have FUN! H.Merijn