Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I need to be able to get the date/time down to the milisecond for a certain process, but I can't spawn a new system command (no using backticks or anything to call the command line) simply because the new process will add more time and throw off what I'm doing. Any ideas? I've tried this using "times" but can't get it to display actual date/time information, only cpu time. Please Help Thanks in advance.
  • Comment on Time down to the milisecond, without a system command?

Replies are listed 'Best First'.
Re: Time down to the milisecond, without a system command?
by Mr. Muskrat (Canon) on Nov 08, 2002 at 16:09 UTC

    You want to use Time::HiRes.
    (I altered one of the examples from the Time::HiRes docs...)

    #!/usr/bin/perl use warnings; use strict; use Time::HiRes qw( gettimeofday tv_interval ); # measure elapsed time my $t0 = [gettimeofday]; # do bunch of stuff here my $t1 = [gettimeofday]; # do more stuff here my $t0_t1 = tv_interval $t0, $t1; my $elapsed = tv_interval ($t0, [gettimeofday]);

Re: Time down to the milisecond, without a system command?
by belg4mit (Prior) on Nov 08, 2002 at 17:29 UTC
    Nothing to seee here, move along. (I was a bit hasty in my reply, thought he meant sleep).

    <s>4-arg select can also be used for this.</s>

    --
    perl -wpe "s/\b;([mnst])/'$1/g"