Index: trunk/SophyaLib/SysTools/ctimer.cc
===================================================================
--- trunk/SophyaLib/SysTools/ctimer.cc	(revision 3226)
+++ trunk/SophyaLib/SysTools/ctimer.cc	(revision 3274)
@@ -1,4 +1,4 @@
 //
-// $Id: ctimer.cc,v 1.6 2004-09-10 09:54:57 cmv Exp $
+// $Id: ctimer.cc,v 1.7 2007-07-06 12:54:12 ansari Exp $
 //
 
@@ -23,18 +23,7 @@
 //	courante comme message. Le temps écoulé sera affiché à la sortie 
 //	de la function.
-//      * SPLITTIME affiche le temps partiel du compteur crée par TIMEF
-//      * TIMEN(nom) permet de donner un autre nom que le nom de la fonction.
 //--
 
 
-//++
-// Titre	Constructeurs
-//--
-
-//++
-// Timer::Timer(const char* name)
-//	Crée un objet qui mémorise l'heure et le temps CPU du process courant.
-//	Le destructeur affiche les temps écoulé et CPU utilisé.
-//--
 
 /*!
@@ -45,42 +34,59 @@
   measuring the CPU and elapsed time in functions. The constructor
   keeps the start time (and CPU time) and an optional message. 
-  The \b Split method displays the partial time, and destructor 
+  The \b Split updates partial times and optionaly displays partial and 
+  total CPU and elapsed time. 
+  The destructor calls Split() if the object has been created with prfg=true.
   displays the total CPU and elapsed time since timer creation.
   The macro \b  TIMEF create a timer object with the function name.
-  The macro \b  SPLITTIME calls the split methode for the timer created
-  by TIMEF. A named timer can be created using the macro \b TIMEN(nom)
+  The elapsed and CPU time are displayed at the end of the bloc or function.
 */
 
-/*! Constructor with the specification of a optional name or message */
-Timer::Timer(const char* name)
-: timerName(name)
+/*! 
+  \brief Constructor with the specification of a optional name or message 
+  and default print flag.
+  if \b prfg==true , a call to Split() causes the display of partial and 
+  total CPU and elapsed time.
+*/
+Timer::Timer(const char* name, bool prfg)
+  : timerName(name) , defprtflg(prfg)
 {
   cpu0 = cpuSplit = clock();
   elapse0 = elapseSplit = time(0);
+  cpuSecT = cpuSecP = 0.;
+  elapSecT = elapSecP = 0;
 }
 
-//++
-// Titre	Méthodes
-//--
+//! The destructor call Split() if the object has been created with prtflag=true.
+Timer::~Timer()
+{
+  if (defprtflg) Split();
+}
 
-//++
-// Timer::Split(const char* comm)
-//	Affiche le temps partiel.
-//--
 
-/*! Method which displays the partial CPU and elapsed time
+/*! This method updates the CPU and elapsed time. 
+    If the prfg==true or the constructor prfg==true, it also displays (prints) 
+    the partial CPU and elapsed time
     An optional message can be passed to be used instead of the
     timer name
 */
-void Timer::Split(const char* comm)
+void Timer::Split(const char* comm, bool prfg)
 {
   time_t elapse = time(0);
   clock_t cpu   = clock();
 
-  float cpuSecT = ((float)cpu - (float)cpu0) / (float)(CLOCKS_PER_SEC);
-  float cpuSecP = ((float)cpu - (float)cpuSplit) / (float)(CLOCKS_PER_SEC);
+  cpuSecT = ((float)cpu - (float)cpu0) / (float)(CLOCKS_PER_SEC);
+  cpuSecP = ((float)cpu - (float)cpuSplit) / (float)(CLOCKS_PER_SEC);
   
-  int etm  = elapse - elapseSplit;
-  int etmt = elapse - elapse0;
+  elapSecP  = elapse - elapseSplit;
+  elapSecT = elapse - elapse0;
+
+
+  //  cumlcpu += (double)cpuSecP;
+  //  cumulelapse += (int_8)etm;
+
+  elapseSplit = elapse;
+  cpuSplit    = cpu;
+
+  if ( !defprtflg && !prfg )  return;
 
   cout << "***Timing " << (comm ? comm : timerName.c_str()) << endl;
@@ -90,4 +96,6 @@
 // autres C++ que GNU), on fait un cout << chaine.
 
+  int etm  = elapSecP;
+  int etmt = elapSecT; 
   char out[200];
   sprintf(out,"CPU     Time: Total= %g (Partial= %g) Sec.",
@@ -100,11 +108,4 @@
 
   cout << out << endl;
-
-  elapseSplit = elapse;
-  cpuSplit    = cpu;
 }
 
-Timer::~Timer()
-{
-  Split();
-}
Index: trunk/SophyaLib/SysTools/ctimer.h
===================================================================
--- trunk/SophyaLib/SysTools/ctimer.h	(revision 3226)
+++ trunk/SophyaLib/SysTools/ctimer.h	(revision 3274)
@@ -1,5 +1,5 @@
 // This may look like C code, but it is really -*- C++ -*-
 //
-// $Id: ctimer.h,v 1.4 2003-02-11 15:31:07 cmv Exp $
+// $Id: ctimer.h,v 1.5 2007-07-06 12:54:12 ansari Exp $
 //
 
@@ -16,11 +16,8 @@
 
 // <summary> Permet de chronometrer des fonctions. </summary>
-// La macro TIMEF cree un objet de class Timer qui memorise
-// l'heure de sa creation, et le temps CPU.
-
+// Class Timer qui memorise l'heure de sa creation, et le temps CPU.
 // A la fin du bloc ou de la procedure, l'objet est detruit,
 // et son destructeur affiche le temps ecoule.
 
-// La macro SPLITTIME lui permet d'afficher des temps partiels.
 namespace SOPHYA {
 
@@ -29,5 +26,5 @@
 public:
   // L'objet memorise le temps CPU et l'heure, et le nom donne
-  Timer(const char* name=0);
+  Timer(const char* name=0, bool prfg=true);
 
   // Le destructeur appelle split sans parametre.
@@ -36,5 +33,5 @@
   // Affiche le temps ecoule total/partiel, avec le nom eventuel.
   // Si pas de parametre affiche le nom donne a la creation.
-  void Split(const char* comm=0);
+  void Split(const char* comm=0, bool prfg=false);
 
   // Sert a eviter que GNU ne pretende qu'on utilise pas l'objet...
@@ -42,15 +39,34 @@
   void Nop() {}
 
+  /*! \brief Return the total elapsed time (number of seconds), 
+    between the object creation and the last call to Split(). 
+  */ 
+  inline int_8 TotalElapsedTime() { return elapSecT ; }
+  /*! \brief Return the partial elapsed time (number of seconds).
+      between the last two calls to Split().
+  */ 
+  inline int_8 PartialElapsedTime() { return elapSecP ; }
+
+  /*! \brief Return the total CPU time in seconds, 
+    between the object creation and the last call to Split(). 
+  */ 
+  inline float TotalCPUTime() { return  cpuSecT; }
+  /*! \brief Return the partial CPU time in seconds, 
+      between the last two calls to Split().
+  */ 
+  inline float PartialCPUTime() { return  cpuSecP; }
+
 private:
   clock_t cpu0, cpuSplit;
   time_t  elapse0, elapseSplit;
+  float cpuSecT, cpuSecP;     // Total and partial CPU time 
+  int_8 elapSecT, elapSecP;    // Total and partial elapsed time 
   string timerName;
+  bool defprtflg;
 };
 
 } // namespace SOPHYA
 
-#define TIMEN(x)  Timer timer(x); timer.Nop();
-#define TIMEF     Timer timer(__PRETTY_FUNCTION__); timer.Nop();
-#define SPLITTIME timer.Split();
+#define TIMEF     Timer timer(__PRETTY_FUNCTION__); timer.Nop(); 
 
 #endif // CTIMER_SEEN
