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


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.cc

    r3579 r3636  
    11//
    2 // $Id: ctimer.cc,v 1.8 2009-02-20 11:07:02 ansari Exp $
     2// $Id: ctimer.cc,v 1.9 2009-05-26 20:24:23 ansari Exp $
    33//
    44
    55#include "machdefs.h"
    6 #include "sopnamsp.h"
    76#include "ctimer.h"
    87
     
    4645*/
    4746
     47namespace SOPHYA {
    4848/*!
    4949  \brief Constructor with the specification of a optional name or message
     
    7676    timer name
    7777*/
    78 void Timer::Split(const char* comm, bool prfg)
     78void Timer::SplitQ()
    7979{
    8080  struct timeval elapse;
     
    104104  elapseSplit = elapse;
    105105  cpuSplit    = cpu;
     106}
    106107
     108void Timer::Split(const char* comm, bool prfg)
     109{
     110  SplitQ();
    107111  if ( !defprtflg && !prfg )  return;
    108 
    109112  cout << "***Timing " << (comm ? comm : timerName.c_str()) << endl;
     113  Print(cout);
     114}
    110115
    111116// Pour des formats comme ca, la syntaxe printf est plus agreable.
    112117// Pour ne pas melanger stdio/iostream (pb de desynchronisation sur
    113118// autres C++ que GNU), on fait un cout << chaine.
     119
     120
     121ostream& Timer::Print(ostream& os) const
     122{
    114123
    115124  int_4 etm  = elapSecP/1000;
     
    119128  sprintf(out,"CPU     Time: Total= %lg (Partial= %lg) s",
    120129          cpuSecT, cpuSecP);
    121   cout << out << endl;
     130  os << out << endl;
    122131
    123132  if (etmt<60) {
    124133    int_4 etmtms = elapSecT%1000;
    125     sprintf(out,"%02d.%03d ms", etmt, etmtms);
     134    sprintf(out,"%02d.%03d s", etmt, etmtms);
    126135  }
    127136  else
     
    130139  if (etm<60) {
    131140    int_4 etmms = elapSecT%1000;
    132     sprintf(outp,"%02d.%03d ms", etm, etmms);
     141    sprintf(outp,"%02d.%03d s", etm, etmms);
    133142  }
    134143  else
    135144    sprintf(outp,"%02d:%02d:%02d", etm/3600, (etm%3600)/60, etm%60);
    136145       
    137   cout << "Elapsed Time: Total=" << out << " (Partial= " << outp << ")" << endl;
     146  os << "Elapsed Time: Total=" << out << " (Partial= " << outp << ")" << endl;
    138147}
    139148
     149} // FIN namespace SOPHYA
Note: See TracChangeset for help on using the changeset viewer.