Changeset 3636 in Sophya for trunk/SophyaLib/SysTools/ctimer.cc
- Timestamp:
- May 26, 2009, 10:24:24 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/SysTools/ctimer.cc
r3579 r3636 1 1 // 2 // $Id: ctimer.cc,v 1. 8 2009-02-20 11:07:02ansari Exp $2 // $Id: ctimer.cc,v 1.9 2009-05-26 20:24:23 ansari Exp $ 3 3 // 4 4 5 5 #include "machdefs.h" 6 #include "sopnamsp.h"7 6 #include "ctimer.h" 8 7 … … 46 45 */ 47 46 47 namespace SOPHYA { 48 48 /*! 49 49 \brief Constructor with the specification of a optional name or message … … 76 76 timer name 77 77 */ 78 void Timer::Split (const char* comm, bool prfg)78 void Timer::SplitQ() 79 79 { 80 80 struct timeval elapse; … … 104 104 elapseSplit = elapse; 105 105 cpuSplit = cpu; 106 } 106 107 108 void Timer::Split(const char* comm, bool prfg) 109 { 110 SplitQ(); 107 111 if ( !defprtflg && !prfg ) return; 108 109 112 cout << "***Timing " << (comm ? comm : timerName.c_str()) << endl; 113 Print(cout); 114 } 110 115 111 116 // Pour des formats comme ca, la syntaxe printf est plus agreable. 112 117 // Pour ne pas melanger stdio/iostream (pb de desynchronisation sur 113 118 // autres C++ que GNU), on fait un cout << chaine. 119 120 121 ostream& Timer::Print(ostream& os) const 122 { 114 123 115 124 int_4 etm = elapSecP/1000; … … 119 128 sprintf(out,"CPU Time: Total= %lg (Partial= %lg) s", 120 129 cpuSecT, cpuSecP); 121 cout<< out << endl;130 os << out << endl; 122 131 123 132 if (etmt<60) { 124 133 int_4 etmtms = elapSecT%1000; 125 sprintf(out,"%02d.%03d ms", etmt, etmtms);134 sprintf(out,"%02d.%03d s", etmt, etmtms); 126 135 } 127 136 else … … 130 139 if (etm<60) { 131 140 int_4 etmms = elapSecT%1000; 132 sprintf(outp,"%02d.%03d ms", etm, etmms);141 sprintf(outp,"%02d.%03d s", etm, etmms); 133 142 } 134 143 else 135 144 sprintf(outp,"%02d:%02d:%02d", etm/3600, (etm%3600)/60, etm%60); 136 145 137 cout<< "Elapsed Time: Total=" << out << " (Partial= " << outp << ")" << endl;146 os << "Elapsed Time: Total=" << out << " (Partial= " << outp << ")" << endl; 138 147 } 139 148 149 } // FIN namespace SOPHYA
Note:
See TracChangeset
for help on using the changeset viewer.