in reply to Re: converting Time::HiRes
in thread converting Time::HiRes

Thanks, the scalar of localtime works, with a decimal correctly placed:
print scalar(localtime(1068837428.812901))."\n";

My real problem is with the Oracle trace data. It has a time value in microseconds since the epoch, but the conversion appears to be off by 9 months. The print statement above is from September 2004, but the conversion lands in November 2003. As in the following source data:

*** SESSION ID:(92.34308) 2004-09-06 11:52:07.103 APPNAME mod='sqlplus@prod90db (TNS V1-V3)' mh=0 act='' ah=0 ===================== PARSING IN CURSOR #1 len=69 dep=0 uid=0 oct=42 lid=0 tim=1068837428812 +901 hv=...

It's time to read the Oracle docs again!!

Replies are listed 'Best First'.
Re^3: converting Time::HiRes
by tachyon (Chancellor) on Sep 14, 2004 at 07:23 UTC

    Actually, scratch the V$Timer bit. There appears to be a plausible conversion factor.

    my $time = convert_tim(1068837428812901); print "Epoch $time\n", scalar gmtime $time, "\n"; # Seem to need a conversion factor of 976,562.5 is 1,000,000,000/1024 sub convert_tim { my $factor = 1_000_000_000/1024; return $_[0]/$factor; } __DATA__ Epoch 1094489527.10441 Mon Sep 6 16:52:07 2004

    Now the plaintext date in your log was 2004-09-06 11:52:07.103 so we get the date right, and the minute and second (down to 5 sig figs). This would appear to be a little to improbable for it to be a coincidence. I expect your DB GMT offset is -5 which is why the hours are out.



Re^3: converting Time::HiRes
by tachyon (Chancellor) on Sep 14, 2004 at 06:58 UTC

    The problem is that tim records the value in v$timer. Here is the man page that this was taken from:


    This view lists the elapsed time in hundredths of seconds. Time is measured since the beginning of the epoch, which is operating system specific, and wraps around to 0 again whenever the value overflows four bytes (roughly 497 days).