$treeview $search $mathjax
|
Palabos
Version 1.1
$projectbrief
|
$projectbrief
|
$searchbox |
00001 /* This file is part of the Palabos library. 00002 * 00003 * Copyright (C) 2011 FlowKit Sarl 00004 * Avenue de Chailly 23 00005 * 1012 Lausanne, Switzerland 00006 * E-mail contact: contact@flowkit.com 00007 * 00008 * The most recent release of Palabos can be downloaded at 00009 * <http://www.palabos.org/> 00010 * 00011 * The library Palabos is free software: you can redistribute it and/or 00012 * modify it under the terms of the GNU Affero General Public License as 00013 * published by the Free Software Foundation, either version 3 of the 00014 * License, or (at your option) any later version. 00015 * 00016 * The library is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Affero General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Affero General Public License 00022 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00023 */ 00024 00025 #ifndef PLB_PROFILER_H 00026 #define PLB_PROFILER_H 00027 00028 #include "core/globalDefs.h" 00029 #include "core/plbTimer.h" 00030 #include "io/plbFiles.h" 00031 #include "libraryInterfaces/TINYXML_xmlIO.h" 00032 #include <string> 00033 #include <set> 00034 00035 namespace plb { 00036 00037 namespace global { 00038 00057 class Profiler { 00058 public: 00059 void turnOn(); 00060 void turnOff(); 00061 void automaticCycling(); 00062 void manualCycling(); 00063 void cycle(); 00064 bool cyclingIsAutomatic() const { 00065 return !manualCycleFlag; 00066 } 00067 bool doProfiling() const { 00068 return profilingFlag; 00069 } 00070 void start(char const* timer) { 00071 if (doProfiling()) { 00072 verifyTimer(timer); 00073 plbTimer(timer).start(); 00074 } 00075 } 00076 void stop(char const* timer) { 00077 if (doProfiling()) { 00078 verifyTimer(timer); 00079 plbTimer(timer).stop(); 00080 } 00081 } 00082 void increment(char const* counter) { 00083 if (doProfiling()) { 00084 verifyCounter(counter); 00085 plbCounter(counter).increment(); 00086 } 00087 } 00088 void increment(char const* counter, plint value) { 00089 if (doProfiling()) { 00090 verifyCounter(counter); 00091 plbCounter(counter).increment(value); 00092 } 00093 } 00094 plint getCounter(char const* counter) { 00095 verifyCounter(counter); 00096 return plbCounter(counter).getCount(); 00097 } 00098 double getTimer(char const* timer) { 00099 verifyTimer(timer); 00100 return plbTimer(timer).getTime(); 00101 } 00102 void setReportFile(FileName const& reportFile_); 00103 void writeReport(); 00104 private: 00105 void verifyTimer(std::string const& timer); 00106 void verifyCounter(std::string const& counter); 00107 void addStatisticalValue(XMLwriter& writer, std::string name, double value); 00108 void addMainProcValue(XMLwriter& writer, std::string name, plint value); 00109 00110 Profiler(); 00111 private: 00112 bool profilingFlag; 00113 bool manualCycleFlag; 00114 FileName reportFile; 00115 std::set<std::string> validTimers; 00116 std::set<std::string> validCounters; 00117 friend Profiler& profiler(); 00118 }; 00119 00120 inline Profiler& profiler() { 00121 static Profiler instance; 00122 return instance; 00123 } 00124 00125 } // namespace global 00126 00127 } // namespace plb 00128 00129 #endif // PLB_PROFILER_H
1.6.3
1.6.3