$treeview $search $mathjax
Palabos  Version 1.1
$projectbrief
$projectbrief
$searchbox

plbTimer.h

Go to the documentation of this file.
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 
00028 #ifndef PLB_TIMER_H
00029 #define PLB_TIMER_H
00030 
00031 #include <ctime>
00032 
00033 namespace plb {
00034 
00035 namespace global {
00036 
00038 
00041 class PlbTimer {
00042 public:
00043     PlbTimer();
00045     void start();
00047     void restart();
00049     /* \return Current cumulative time.
00050      */
00051     double stop();
00053     void reset();
00055     double getTime() const;
00056 private:
00057     double cumulativeTime;
00058     bool   isOn;
00059 #ifdef PLB_MPI_PARALLEL
00060     double startTime;
00061 #else
00062     clock_t startClock;
00063 #endif
00064 friend PlbTimer& timer(std::string nameOfTimer);
00065 friend PlbTimer& plbTimer(std::string nameOfTimer);
00066 };
00067 
00068 // Global instance of timer objects, for public use.
00069 PlbTimer& timer(std::string nameOfTimer);
00070 
00071 // Global instance of timer objects, for internal use.
00072 PlbTimer& plbTimer(std::string nameOfTimer);
00073 
00076 class PlbCounter {
00077 public:
00078     PlbCounter();
00080     plint increment(plint value=1);
00082     void reset();
00084     plint getCount() const;
00085 private:
00086     plint count;
00087 friend PlbCounter& counter(std::string nameOfCounter);
00088 friend PlbCounter& plbCounter(std::string nameOfCounter);
00089 };
00090 
00091 // Global instance of counter objects, for public use.
00092 PlbCounter& counter(std::string nameOfCounter);
00093 
00094 // Global instance of counter objects, for internal use.
00095 PlbCounter& plbCounter(std::string nameOfCounter);
00096 
00097 }  // namespace global
00098 
00099 }  // namespace plb
00100 
00101 #endif  // PLB_TIMER_H