time() and $^T will be giving you elapsed real time, but in whole seconds.
To get something with a finer grain, you should look at Time::HiRes. That provides:
Time::HiRes::time() which you can use instead of time() which will give whatever resolution your system will support -- it's reasonable to expect at least milli-seconds, and probably micro-seconds. You will have to do your own $Start_Time = Time::HiRes::time(), early on in the script, though. (Sadly, it does not seem to be possible to $^T = Time::HiRes::time().
you can also (Update: but not under Winders):
use Time::HiRes qw(clock_gettime CLOCK_REALTIME) ; my $t = clock_gettime(CLOCK_REALTIME) ; # same as: my $t = Time::Hi +Res::time()
and if you want the cpu time, rather than the elapsed time, then:
should give you cpu time since the process started. CLOCK_PROCESS_CPUTIME_ID is a POSIX thing, which is probably implemented on your system (Update: but not under Winders).use Time::HiRes qw(clock_gettime CLOCK_PROCESS_CPUTIME_ID) ; my $cpu = clock_gettime(CLOCK_PROCESS_CPUTIME_ID) ;
Update: Time::HiRes::time() is supported on Winders. Unfortunately Time::HiRes::clock_gettime() isn't... Time::HiRes::clock() I find is also not implemented on Winders :-(
However, testing on Linux and Windows XP, suggests that the following is supported by POSIX:
where this is retrning: the elapsed realtime since some point in the past (such as system startup); user and system times for this process; and user and system times used by child processes. They are in units of CLOCKS_PER_SEC, which on my XP is 1000 (so ms).use POSIX qw(CLOCKS_PER_SEC) ; my ($realtime, $user, $system, $cuser, $csystem) = POSIX::times() ;
In reply to Re: Script execution time
by gone2015
in thread Script execution time
by velusamy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |