Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: converting Time::HiRes

by Lhamo Latso (Scribe)
on Sep 14, 2004 at 06:20 UTC ( [id://390755]=note: print w/replies, xml ) Need Help??


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.

    cheers

    tachyon

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:

    V$TIMER

    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).

    cheers

    tachyon

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://390755]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-19 22:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found