hemocell
Loading...
Searching...
No Matches
profiler.h
Go to the documentation of this file.
1/*
2This file is part of the HemoCell library
3
4HemoCell is developed and maintained by the Computational Science Lab
5in the University of Amsterdam. Any questions or remarks regarding this library
6can be sent to: info@hemocell.eu
7
8When using the HemoCell library in scientific work please cite the
9corresponding paper: https://doi.org/10.3389/fphys.2017.00563
10
11The HemoCell library is free software: you can redistribute it and/or
12modify it under the terms of the GNU Affero General Public License as
13published by the Free Software Foundation, either version 3 of the
14License, or (at your option) any later version.
15
16The library is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19GNU Affero General Public License for more details.
20
21You should have received a copy of the GNU Affero General Public License
22along with this program. If not, see <http://www.gnu.org/licenses/>.
23*/
24
25#ifndef PROFILER_H
26#define PROFILER_H
27
28#include <chrono>
29#include <string>
30#include <map>
31#include <logfile.h>
32
33namespace hemo {
47class Profiler {
48public:
49 Profiler(std::string name_);
50 Profiler(std::string name_, Profiler & parent_);
51
52 void start();
53 void stop();
54 void reset();
55 void printStatistics();
56 void outputStatistics();
57 void outputStatistics(int);
58
59 std::chrono::high_resolution_clock::duration elapsed();
60 std::string elapsed_string();
61 Profiler & operator[] (std::string);
63
64 std::string static toString(std::chrono::high_resolution_clock::duration);
65
66private:
67 void stop_nowarn();
68 template<typename T>
69 void printStatistics_inner(int level, T & out);
70 template<typename T>
71 void printStatistics_JSON(T & out);
72 std::chrono::high_resolution_clock::duration total_time = std::chrono::high_resolution_clock::duration::zero();
73 std::chrono::high_resolution_clock::time_point start_time = std::chrono::high_resolution_clock::now();
74 bool started = false;
75 const std::string name;
76 std::map<std::string,Profiler> timers;
78 Profiler * current = this;
79};
80}
81#endif /* PROFILER_H */
Definition profiler.h:47
std::string elapsed_string()
Definition profiler.cpp:130
void outputStatistics()
Definition profiler.cpp:186
void printStatistics_inner(int level, T &out)
Definition profiler.cpp:139
std::chrono::high_resolution_clock::duration total_time
Definition profiler.h:72
Profiler * current
Definition profiler.h:78
void start()
Definition profiler.cpp:41
void printStatistics_JSON(T &out)
Definition profiler.cpp:154
bool started
Definition profiler.h:74
Profiler & getCurrent()
Definition profiler.cpp:251
void reset()
Definition profiler.cpp:111
std::chrono::high_resolution_clock::time_point start_time
Definition profiler.h:73
std::map< std::string, Profiler > timers
Definition profiler.h:76
void stop_nowarn()
Definition profiler.cpp:72
const std::string name
Definition profiler.h:75
std::chrono::high_resolution_clock::duration elapsed()
Definition profiler.cpp:122
Profiler & parent
Definition profiler.h:77
void stop()
Definition profiler.cpp:87
static std::string toString(std::chrono::high_resolution_clock::duration)
Definition profiler.cpp:258
Profiler & operator[](std::string)
Definition profiler.cpp:243
void printStatistics()
Definition profiler.cpp:180
double T
Definition constant_defaults.h:118
Definition config.cpp:34