By way of a method (excessively detailed which is also guilty of re-inventing a wheel) of getting a (low res, W32) execution time:

#!C:\perl\bin\perl.exe -lw my $starttime = localtime(); my $starthms = $starttime; $starthms =~ /[A-Z]+\s[A-Z]+\s+\d+\s+(\d{2}:\d{2}:\d{2}).*/i; $starthms = $1; print $starthms; if ( $starthms =~ /(\d+):(\d+):(\d+)/ ) { my $hours = $1; my $minutes = $2; my $seconds = $3; our $startsecs = ($hours*60*60) + ($minutes*60) + $seconds; } sleep 2; # insert your code to be timed my $endtime = localtime(); my $endtimehms = $endtime; $endtimehms =~ /[A-Z]+\s[A-Z]+\s+\d+\s+(\d{2}:\d{2}:\d{2}).*/i; $endpart = $1; if ( $endpart =~ /(\d+):(\d+):(\d+)/ ) { local $hours = $1; local $minutes = $2; local $seconds = $3; our $endtimesecs = ($hours*60*60) + ($minutes*60) + $seconds; } print "\$endpart: $endpart and Runduration: " . ($endtimesecs - $start +secs) . " seconds"; print "=======================\n"; use POSIX; print "starttime, \$^T without POSIX: $^T"; print "Start time, , \$^T with POSIX: " . POSIX::strftime "%H:%M:%S", + localtime($^T); print "\t2nd POSIX, \$^T: " . POSIX::strftime "%H:%M:%S", localtime($^ +T); print "\t3rd POSIX, current time: " . POSIX::strftime "%H:%M:%S", loca +ltime(); print "local_time(): " . localtime();

Upon execution,

11:10:11 $endpart: 11:10:13 and Runduration: 2 seconds ======================= starttime, $^T without POSIX: 1233763810 Start time, , $^T with POSIX: 11:10:10 2nd POSIX, $^T: 11:10:10 3rd POSIX, current time: 11:10:13 local_time(): Wed Feb 4 11:10:13 2009 POSIX localtime: Wed Feb 11:10:13 2009 ...and after sleeping another second, POSIX localtime: Wed Feb 11:10: +14 2009

For more precise timeing, read perldoc -q profile.

See also Time-HiRes and for a *nix-ish flavor, perldoc -q time in (perlfaq8.pod) at "How can I measure time under a second?"

Update: ...or see oshalla's, above.


In reply to Re: Script execution time by ww
in thread Script execution time by velusamy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.