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


Ignore:
Timestamp:
May 26, 2009, 10:24:24 PM (16 years ago)
Author:
ansari
Message:

Petites correction/amelioration de la classe Timer - Reza 26/05/2009

File:
1 edited

Legend:

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

    r3579 r3636  
    11// This may look like C code, but it is really -*- C++ -*-
    22//
    3 // $Id: ctimer.h,v 1.6 2009-02-20 11:07:02 ansari Exp $
     3// $Id: ctimer.h,v 1.7 2009-05-26 20:24:24 ansari Exp $
    44//
    55
     
    1313#include <sys/time.h>
    1414#include <string>
     15#include <iostream>
    1516
    1617using namespace std;
     
    3536  // Si pas de parametre affiche le nom donne a la creation.
    3637  void Split(const char* comm=0, bool prfg=false);
     38
     39  //! store partial CPU and elapsed time (no print)
     40  void SplitQ();
    3741
    3842  // Sert a eviter que GNU ne pretende qu'on utilise pas l'objet...
     
    6771  inline double PartialCPUTime() { return  cpuSecP; }
    6872
     73//! Print the CPU and elapsed time on os (partial time corresponding to the last call to Split())
     74  ostream& Print(ostream& os) const ;
     75//! Print the CPU and elapsed time on cout
     76  inline ostream& Print() const { return Print(cout); }
     77
    6978private:
    7079  clock_t cpu0, cpuSplit;
     
    7685};
    7786
     87/*! operator << overloading - Calls SplitQ() and Print() */
     88inline ostream& operator << (ostream& s, Timer& tm)
     89  {  tm.SplitQ(); tm.Print(s);  return(s);  }
     90
    7891} // namespace SOPHYA
    7992
Note: See TracChangeset for help on using the changeset viewer.