CEPS  24.01
Cardiac ElectroPhysiology Simulator
CepsProfiler.hpp
Go to the documentation of this file.
1 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2  This file is part of CEPS.
3 
4  CEPS is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  CEPS is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with CEPS (see file LICENSE at root of project).
16  If not, see <https://www.gnu.org/licenses/>.
17 
18 
19  Copyright 2019-2024 Inria, Universite de Bordeaux
20 
21  Authors, in alphabetical order:
22 
23  Pierre-Elliott BECUE, Florian CARO, Yves COUDIERE(*), Andjela DAVIDOVIC,
24  Charlie DOUANLA-LONTSI, Marc FUENTES, Mehdi JUHOOR, Michael LEGUEBE(*),
25  Pauline MIGERDITICHAN, Valentin PANNETIER(*), Nejib ZEMZEMI.
26  * : currently active authors
27 
28 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
32 #pragma once
33 
35 
70 class Profiler
71 {
72 
73  public:
74 
76  Profiler();
82  Profiler(const Profiler&) = delete;
83 
89  Profiler&
90  operator=(const Profiler&) = delete;
91 
93  ~Profiler();
94 
102  void
103  start(CepsString lbl, CepsString dspl = "");
104 
108  void
109  restart(CepsString lbl);
110 
114  void
115  stop(CepsString lbl);
116 
121  void
122  display(const CepsString& lbl, std::ostream& os) const;
123 
127  void
128  display(const CepsString& lbl) const;
129 
132  void
133  display(std::ostream&) const;
134 
137  void
138  display() const;
139 
143  void
144  logMemoryUsage(const CepsString& xtic);
145 
149  void
150  logMemoryUsageIf(CepsBool ifexpr, const CepsString& xtic);
151 
155  size_t
157 
161  size_t
163 
164 
165  private:
166 
171 
172 };
std::basic_string< CepsChar > CepsString
C++ format string.
Definition: CepsTypes.hpp:128
std::map< _Key, _Tp, _Compare, _Alloc > CepsMap
C++ map.
Definition: CepsTypes.hpp:196
bool CepsBool
Booleans.
Definition: CepsTypes.hpp:124
std::make_unsigned_t< CepsInt > CepsUInt
Unsigned version on CepsInt.
Definition: CepsTypes.hpp:109
A Chronometer used to measure execution of blocks of code, plus some methods to get current memory us...
void stop(CepsString lbl)
Stops the measure of a labeled chronometer.
CepsMap< CepsString, clock_t > m_tmpTimes
Temp evals for times.
size_t localMemoryUsage()
Returns an estimation of the memory taken by the current process (in kB)
~Profiler()
Destructor.
CepsMap< CepsString, CepsReal > m_seconds
Times.
Profiler()
Constructor.
void start(CepsString lbl, CepsString dspl="")
Creates or continue a labeled chronometer.
CepsUInt m_maxLen
For nice output.
Profiler(const Profiler &)=delete
Copy constructor deleted, ideally, there should be one profiler per run.
CepsMap< CepsString, CepsString > m_dsplStrs
Text to display at the end of computation, typically.
void logMemoryUsage(const CepsString &xtic)
Writes a line with memory usage in profiling log, xtic is used to describe what the program is curren...
void display() const
Prints time spent by all chronometers.
Profiler & operator=(const Profiler &)=delete
Assignment operator deleted, ideally, there should be one profiler per run.
size_t globalMemoryUsage()
Returns an estimation of the memory taken by all the MPI process (in kB)
void restart(CepsString lbl)
Resets a labeled chronometer.
void logMemoryUsageIf(CepsBool ifexpr, const CepsString &xtic)
Writes a line with memory usage in profiling log if 'ifexpr' is true, xtic is used to describe what t...