Last change
on this file since 1434 was
1135,
checked in by ymipsl, 7 years ago
|
- Add new timer for better profiling. The full timer output will be provided only for info_level=100
- Add new file attribute : convention_str (string) : this string will overide the default value wrote in the file (CF-1.6 or UGRID)
YM
|
-
Property copyright set to
Software name : XIOS (Xml I/O Server) http://forge.ipsl.jussieu.fr/ioserver Creation date : January 2009 Licence : CeCCIL version2 see license file in root directory : Licence_CeCILL_V2-en.txt or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement) CNRS/IPSL (Institut Pierre Simon Laplace) Project Manager : Yann Meurdesoif yann.meurdesoif@cea.fr
-
Property svn:eol-style set to
native
|
File size:
1.3 KB
|
Rev | Line | |
---|
[347] | 1 | #include "timer.hpp" |
---|
[382] | 2 | #include "mpi.hpp" |
---|
[347] | 3 | #include <string> |
---|
| 4 | #include <map> |
---|
[1135] | 5 | #include <iostream> |
---|
| 6 | #include <sstream> |
---|
[347] | 7 | #include "tracer.hpp" |
---|
| 8 | |
---|
| 9 | namespace xios |
---|
| 10 | { |
---|
[652] | 11 | std::map<std::string,CTimer> CTimer::allTimer; |
---|
[347] | 12 | |
---|
[652] | 13 | CTimer::CTimer(const std::string& name_) : name(name_) |
---|
[347] | 14 | { |
---|
[652] | 15 | reset(); |
---|
[347] | 16 | } |
---|
| 17 | |
---|
| 18 | double CTimer::getTime(void) |
---|
| 19 | { |
---|
| 20 | return MPI_Wtime(); |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | void CTimer::suspend(void) |
---|
| 24 | { |
---|
| 25 | if (!suspended) |
---|
| 26 | { |
---|
[652] | 27 | traceEnd(name); |
---|
| 28 | cumulatedTime += getTime() - lastTime; |
---|
[347] | 29 | } |
---|
[652] | 30 | suspended = true; |
---|
[347] | 31 | } |
---|
| 32 | |
---|
| 33 | void CTimer::resume(void) |
---|
| 34 | { |
---|
| 35 | if (suspended) |
---|
| 36 | { |
---|
[652] | 37 | lastTime = getTime(); |
---|
| 38 | traceBegin(name); |
---|
[347] | 39 | } |
---|
[652] | 40 | suspended = false; |
---|
[347] | 41 | } |
---|
| 42 | |
---|
| 43 | void CTimer::reset(void) |
---|
| 44 | { |
---|
[652] | 45 | cumulatedTime = 0.; |
---|
| 46 | suspended = true; |
---|
[347] | 47 | } |
---|
| 48 | |
---|
| 49 | double CTimer::getCumulatedTime(void) |
---|
| 50 | { |
---|
[652] | 51 | return cumulatedTime; |
---|
[347] | 52 | } |
---|
| 53 | |
---|
[652] | 54 | CTimer& CTimer::get(const std::string name) |
---|
[347] | 55 | { |
---|
[652] | 56 | std::map<std::string,CTimer>::iterator it = allTimer.find(name); |
---|
| 57 | if (it == allTimer.end()) |
---|
| 58 | it = allTimer.insert(std::make_pair(name, CTimer(name))).first; |
---|
| 59 | return it->second; |
---|
[347] | 60 | } |
---|
[1135] | 61 | |
---|
| 62 | string CTimer::getAllCumulatedTime(void) |
---|
| 63 | { |
---|
| 64 | std::ostringstream strOut ; |
---|
| 65 | for(std::map<std::string,CTimer>::iterator it=allTimer.begin();it!=allTimer.end();++it) |
---|
| 66 | strOut<<"Timer : "<<it->first<<" --> cumulated time : "<<it->second.getCumulatedTime()<<std::endl ; |
---|
| 67 | return strOut.str() ; |
---|
| 68 | } |
---|
[347] | 69 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.