Changeset 3579 in Sophya for trunk/SophyaLib/SysTools/ctimer.h


Ignore:
Timestamp:
Feb 20, 2009, 12:07:02 PM (17 years ago)
Author:
ansari
Message:

Amelioration classe Timer, precision time-elapsed par utilisation gettimeofday(...) au lieu de time(), amelioration calcul temps cpu pour jobs tres long - Reza 20/02/2009

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/SysTools/ctimer.h

    r3274 r3579  
    11// This may look like C code, but it is really -*- C++ -*-
    22//
    3 // $Id: ctimer.h,v 1.5 2007-07-06 12:54:12 ansari Exp $
     3// $Id: ctimer.h,v 1.6 2009-02-20 11:07:02 ansari Exp $
    44//
    55
     
    1111#include <sys/types.h>
    1212#include <time.h>
    13 #include <iostream>
    14 #include <stdio.h>
     13#include <sys/time.h>
    1514#include <string>
     15
     16using namespace std;
    1617
    1718// <summary> Permet de chronometrer des fonctions. </summary>
     
    4243    between the object creation and the last call to Split().
    4344  */
    44   inline int_8 TotalElapsedTime() { return elapSecT ; }
     45  inline int_8 TotalElapsedTime() { return elapSecT/1000 ; }
    4546  /*! \brief Return the partial elapsed time (number of seconds).
    4647      between the last two calls to Split().
    4748  */
    48   inline int_8 PartialElapsedTime() { return elapSecP ; }
     49  inline int_8 PartialElapsedTime() { return elapSecP/1000 ; }
     50 
     51  /*! \brief Return the total elapsed time (in milli-seconds),
     52    between the object creation and the last call to Split().
     53  */
     54  inline int_8 TotalElapsedTimems() { return elapSecT ; }
     55  /*! \brief Return the partial elapsed time (in milli-seconds).
     56      between the last two calls to Split().
     57  */
     58  inline int_8 PartialElapsedTimems() { return elapSecP ; }
    4959
    5060  /*! \brief Return the total CPU time in seconds,
    5161    between the object creation and the last call to Split().
    5262  */
    53   inline float TotalCPUTime() { return  cpuSecT; }
     63  inline double TotalCPUTime() { return  cpuSecT; }
    5464  /*! \brief Return the partial CPU time in seconds,
    5565      between the last two calls to Split().
    5666  */
    57   inline float PartialCPUTime() { return  cpuSecP; }
     67  inline double PartialCPUTime() { return  cpuSecP; }
    5868
    5969private:
    6070  clock_t cpu0, cpuSplit;
    61   time_t elapse0, elapseSplit;
    62   float cpuSecT, cpuSecP;     // Total and partial CPU time
    63   int_8 elapSecT, elapSecP;    // Total and partial elapsed time
     71  struct timeval elapse0, elapseSplit;
     72  double cpuSecT, cpuSecP;     // Total and partial CPU time
     73  int_8 elapSecT, elapSecP;    // Total and partial elapsed time in ms
    6474  string timerName;
    6575  bool defprtflg;
Note: See TracChangeset for help on using the changeset viewer.