| # Gaudi Framework, version v23r1 |

Home |  | Generated: Wed Feb 29 2012

# Timing.h

Go to the documentation of this file.

    00001 //====================================================================
    00002 //      Timing.h
    00003 //--------------------------------------------------------------------
    00004 //
    00005 //      Package    : Gaudi/System (The LHCb System service)
    00006 //
    00007 //  Description: Definition of Systems internals
    00008 //
    00009 //      Author     : M.Frank
    00010 //      Created    : 13/1/99
    00011 //====================================================================
    00012 #ifndef GAUDIKERNEL_TIMING_H
    00013 #define GAUDIKERNEL_TIMING_H
    00014
    00015 // Framework include files
    00016 #include "GaudiKernel/Kernel.h"
    00017 #include "GaudiKernel/SystemBase.h"
    00018
    00049 namespace System  {
    00051   enum TimeType   { Year, Month, Day, Hour, Min, Sec, milliSec, microSec, nanoSec, Native };
    00052
    00054   GAUDI_API longlong adjustTime(TimeType typ, longlong timevalue);
    00055
    00057   template <TimeType T>
    00058   inline long long adjustTime(long long timevalue);
    00059
    00065   GAUDI_API longlong ellapsedTime(TimeType typ = milliSec, InfoType fetch = Times, long pid = -1);
    00073   GAUDI_API longlong kernelTime(TimeType typ = milliSec, InfoType fetch = Times, long pid = -1);
    00081   GAUDI_API longlong userTime(TimeType typ = milliSec, InfoType fetch = Times, long pid = -1);
    00089   GAUDI_API longlong cpuTime(TimeType typ = milliSec, InfoType fetch = Times, long pid = -1);
    00097   GAUDI_API longlong remainingTime(TimeType typ = milliSec, InfoType fetch = Quota, long pid = -1);
    00105   GAUDI_API longlong creationTime(TimeType typ = milliSec, InfoType fetch = Times, long pid = -1);
    00110   GAUDI_API longlong systemStart(TimeType typ = Sec);
    00115   GAUDI_API longlong upTime(TimeType typ = Hour);
    00120   GAUDI_API longlong currentTime(TimeType typ = milliSec);
    00124   GAUDI_API longlong tickCount();
    00125
    00133   class ProcessTime {
    00134   public:
    00135     typedef long long TimeValueType;
    00136
    00138     ProcessTime(): i_kernel(0), i_user(0), i_elapsed(0) {}
    00139
    00141     ProcessTime(TimeValueType k, TimeValueType u, TimeValueType e):
    00142       i_kernel(k), i_user(u), i_elapsed(e) {}
    00143
    00145     template <TimeType T>
    00146     inline TimeValueType kernelTime() const { return adjustTime<T>(i_kernel); }
    00147
    00149     template <TimeType T>
    00150     inline TimeValueType userTime() const { return adjustTime<T>(i_user); }
    00151
    00153     template <TimeType T>
    00154     inline TimeValueType elapsedTime() const { return adjustTime<T>(i_elapsed); }
    00155
    00157     template <TimeType T>
    00158     inline TimeValueType cpuTime() const { return adjustTime<T>(i_user + i_kernel); }
    00159
    00161     inline ProcessTime operator-(const ProcessTime &rhs) const {
    00162       return ProcessTime(i_kernel - rhs.i_kernel,
    00163                          i_user - rhs.i_user,
    00164                          i_elapsed - rhs.i_elapsed);
    00165     }
    00166   private:
    00168     TimeValueType i_kernel, i_user, i_elapsed;
    00169   };
    00170
    00176   GAUDI_API ProcessTime getProcessTime(long pid = -1);
    00177
    00178 }
    00179
    00180 // implementation of the templated adjustTime
    00181 namespace System {
    00182   template <>
    00183   inline long long adjustTime<Year>(long long t) {
    00184     return (t==-1) ? t : t /= (1LL * 365 * 24 * 60 * 60 * 1000 * 1000 * 10);
    00185   }
    00186   template <>
    00187   inline long long adjustTime<Day>(long long t) {
    00188     return (t==-1) ? t : t /= (1LL * 24 * 60 * 60 * 1000 * 1000 * 10);
    00189   }
    00190   template <>
    00191   inline long long adjustTime<Hour>(long long t) {
    00192     return (t==-1) ? t : t /= (1LL * 60 * 60 * 1000 * 1000 * 10);
    00193   }
    00194   template <>
    00195   inline long long adjustTime<Min>(long long t) {
    00196     return (t==-1) ? t : t /= (60 * 1000 * 1000 * 10);
    00197   }
    00198   template <>
    00199   inline long long adjustTime<Sec>(long long t) {
    00200     return (t==-1) ? t : t /= (1000 * 1000 * 10);
    00201   }
    00202   template <>
    00203   inline long long adjustTime<milliSec>(long long t) {
    00204     return (t==-1) ? t : t /= (1000 * 10);
    00205   }
    00206   template <>
    00207   inline long long adjustTime<microSec>(long long t) {
    00208     return (t==-1) ? t : t /= (10LL);
    00209   }
    00210   template <>
    00211   inline long long adjustTime<nanoSec>(long long t) {
    00212     return (t==-1) ? t : t *= 100LL;
    00213   }
    00214   template <>
    00215   inline long long adjustTime<Month>(long long t) {
    00216     return (t==-1) ? t : t /= (1LL * 30 * 24 * 60 * 60 * 1000 * 1000 * 10);
    00217   }
    00218   template <>
    00219   inline long long adjustTime<Native>(long long t) {
    00220     return t;
    00221   }
    00222 }
    00223
    00224 #endif    // GAUDIKERNEL_TIMING_H

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines