RE: [ROOT] system time in msec ?

From: Robert Hatcher (rhatcher@SLAC.stanford.edu)
Date: Tue Mar 05 2002 - 22:55:00 MET


On Tue, 5 Mar 2002, Faine, Valeri wrote:

>
> > On Tue, 5 Mar 2002, Faine, Valeri wrote:
>
> > > In theory  (;-)the TStopwatch method is a good ROOT candidate.
> > > Have a look at
> > >
> > >
> http://root.cern.ch/root/htmldoc/src/TStopwatch.cxx.html#TStopwatch:GetR
> ealT
> > > ime
>
> > Actually, no it isn't.  TStopwatch is a good candidate for a stop watch
> > object.  Stopwatches are good for measuring elapsed times not absolutes.
>
>   I think ( under Windows at least) the method TStopwatch::GetRealTime()
> does what he wants. Namely it returns:
>
>   the (Double_t)FILETIME structure, that is a 64-bit value representing
>   the number of 100-nanosecond intervals since January 1, 1601.
>
>   I agree it is not true under UNIX. This is why I called this
>   method "the candidate". Otherwise I would say USE that method.

But it *isn't* a "candidate" because it doesn't meet his requirements:

> > [...] Since my app must run on Linux AND windoze I do not
> > want to implement it by myself ( no clue about Linux).

#elif defined(WIN32)
  union     {FILETIME ftFileTime;
             __int64  ftInt64;
            } ftRealTime; // time the process has spent in kernel mode
  SYSTEMTIME st;
  GetSystemTime(&st);
  SystemTimeToFileTime(&st,&ftRealTime.ftFileTime);
  return (Double_t)ftRealTime.ftInt64 * gTicks;

The problem here is that this returns (as a double) the time, in
seconds, since ... well, you say it is, Jan 1, 1601.  Which needs
further massaging to convert to seconds since "epoch" (Jan 1, 1970)
that forms the basis for the POSIX standard time functions if it is to
be used in TTimeStamp.  It may also need adjustments for time zone.

Okay, so perhaps the best thing to do is to merge a modified version
of what TStopwatch::GetRealTime() does for M$ Windows with my proposal
for modification on systems with gettimeofday() into TTimeStamp.  That
leaves R__VMS and R__MAC as unknowns ...

-robert

Robert W. Hatcher   | rhatcher@fnal.gov   630-840-3102
FNAL CD/CP (MINOS)  | MS 220, PO Box 500, Batavia IL 60510



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:44 MET