PhoenixHardware  0.2.0
Tools to get hardware information
Loading...
Searching...
No Matches
PProfiler.cpp
Go to the documentation of this file.
1/***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5****************************************/
6
7
8
9
10#include "PProfiler.h"
11
16
18
21 copyPProfiler(other);
22}
23
28
30
34 copyPProfiler(other);
35 return *this;
36}
37
39
43size_t PProfiler::addFunction(const std::string & name, size_t nbThread){
44 PFunctionPerf perf(name);
45 if(nbThread < 1lu){nbThread = 1;}
46 perf.resize(nbThread);
47 p_vecFunctionPerf.push_back(perf);
48 return p_vecFunctionPerf.size() - 1lu;
49}
50
52
55void PProfiler::rename(size_t index, const std::string & name){
56 p_vecFunctionPerf[index].setName(name);
57}
58
60
63void PProfiler::start(size_t index, size_t threadIndex){
64 p_vecFunctionPerf[index].start(threadIndex);
65}
66
68
71void PProfiler::stop(size_t index, size_t threadIndex){
72 p_vecFunctionPerf[index].stop(threadIndex);
73}
74
76
79void PProfiler::reset(size_t index, size_t threadIndex){
80 p_vecFunctionPerf[index].reset(threadIndex);
81}
82
85 for(PVecFunctionPerf::iterator it(p_vecFunctionPerf.begin()); it != p_vecFunctionPerf.end(); ++it){
86 it->reset();
87 }
88}
89
91
93void PProfiler::print(std::ostream & out) const{
94 for(PVecFunctionPerf::const_iterator it(p_vecFunctionPerf.begin()); it != p_vecFunctionPerf.end(); ++it){
95 it->print(out);
96 }
97}
98
100
102void PProfiler::printCsvHeader(std::ostream & out) const{
103 out << "function,nbCall,fullTime,averageTime,stdTime,minTime,maxTime" << std::endl;
104}
105
107
109void PProfiler::printCsv(std::ostream & out) const{
110 for(PVecFunctionPerf::const_iterator it(p_vecFunctionPerf.begin()); it != p_vecFunctionPerf.end(); ++it){
111 it->printCsv(out);
112 }
113}
114
116
121
126
127
128
129
130
Performances of a function.
void resize(size_t nbThread)
Resize the PFunctionPerf by respect to the number of thread which call the function.
void initialisationPProfiler()
Initialisation function of the class PProfiler.
void printCsvHeader(std::ostream &out=std::cout) const
Print header of all the PFunctionPerf of the PProfiler in CSV format.
void start(size_t index, size_t threadIndex=0lu)
Start the given PFunctionPerf.
Definition PProfiler.cpp:63
PProfiler()
Default constructor of PProfiler.
Definition PProfiler.cpp:13
void print(std::ostream &out=std::cout) const
Print all the PFunctionPerf of the PProfiler.
Definition PProfiler.cpp:93
void printCsv(std::ostream &out=std::cout) const
Print all the PFunctionPerf of the PProfiler in CSV format.
void copyPProfiler(const PProfiler &other)
Copy function of PProfiler.
void rename(size_t index, const std::string &name)
Rename a function.
Definition PProfiler.cpp:55
PProfiler & operator=(const PProfiler &other)
Definition of equal operator of PProfiler.
Definition PProfiler.cpp:33
virtual ~PProfiler()
Destructor of PProfiler.
Definition PProfiler.cpp:25
size_t addFunction(const std::string &name, size_t nbThread=1lu)
Add a function to profile.
Definition PProfiler.cpp:43
void reset()
Reset all the function perf.
Definition PProfiler.cpp:84
PVecFunctionPerf p_vecFunctionPerf
Vector of performances for all registered functions.
Definition PProfiler.h:42
void stop(size_t index, size_t threadIndex=0lu)
Stop the given PFunctionPerf.
Definition PProfiler.cpp:71