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();
57 void clear();
58 void printStatistics();
59 void outputStatistics();
60 void outputStatistics(int);
61
62 std::chrono::high_resolution_clock::duration elapsed();
63 std::string elapsed_string();
64 Profiler & operator[](std::string);
66
67 std::string static toString(std::chrono::high_resolution_clock::duration);
68
69private:
70 void stop_nowarn();
71 template <typename T>
72 void printStatistics_inner(int level, T & out);
73 template <typename T>
74 void printStatistics_JSON(T & out);
75 std::chrono::high_resolution_clock::duration total_time = std::chrono::high_resolution_clock::duration::zero();
76 std::chrono::high_resolution_clock::time_point start_time = std::chrono::high_resolution_clock::now();
77 bool started = false;
78 const std::string name;
79 std::map<std::string, Profiler> timers;
81 Profiler * current = this;
82};
83}
84#endif /* PROFILER_H */
Definition profiler.h:47
std::string elapsed_string()
Definition profiler.cpp:135
void outputStatistics()
Definition profiler.cpp:201
void printStatistics_inner(int level, T &out)
Definition profiler.cpp:147
std::chrono::high_resolution_clock::duration total_time
Definition profiler.h:75
Profiler * current
Definition profiler.h:81
void start()
Definition profiler.cpp:37
void printStatistics_JSON(T &out)
Definition profiler.cpp:168
bool started
Definition profiler.h:77
Profiler & getCurrent()
Definition profiler.cpp:261
void reset()
Definition profiler.cpp:109
std::chrono::high_resolution_clock::time_point start_time
Definition profiler.h:76
void stop_nowarn()
Definition profiler.cpp:71
void clear()
Definition profiler.cpp:120
const std::string name
Definition profiler.h:78
std::chrono::high_resolution_clock::duration elapsed()
Definition profiler.cpp:127
Profiler & parent
Definition profiler.h:80
void stop()
Definition profiler.cpp:85
static std::string toString(std::chrono::high_resolution_clock::duration)
Definition profiler.cpp:270
Profiler & operator[](std::string)
Definition profiler.cpp:253
void printStatistics()
Definition profiler.cpp:195
std::map< std::string, Profiler > timers
Definition profiler.h:79
double T
Definition constant_defaults.h:137
Definition config.cpp:37