PhoenixHardware  0.2.0
Tools to get hardware information
Loading...
Searching...
No Matches
PFunctionPerf.h
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#ifndef __PFUNCTIONPERF_H__
8#define __PFUNCTIONPERF_H__
9
10#include <string>
11#include <ostream>
12#include <iostream>
13#include <vector>
15
18 public:
19 PFunctionPerf(const std::string & name = "");
20 PFunctionPerf(const PFunctionPerf & other);
21 virtual ~PFunctionPerf();
23
24 void setName(const std::string & name);
25 void resize(size_t nbThread);
26
27 void start(size_t threadIndex = 0lu);
28 void stop(size_t threadIndex = 0lu);
29 void reset(size_t threadIndex);
30 void reset();
31
32 void getPerf(size_t & nbCall, double & fullTime, double & averageTime, double & stdTime, size_t & minTime, size_t & maxTime) const;
33 const std::string & getName() const;
34
35 void print(std::ostream & out = std::cout) const;
36 void printCsv(std::ostream & out = std::cout) const;
37
38 protected:
39 void copyPFunctionPerf(const PFunctionPerf & other);
40
41 private:
42 void initialisationPFunctionPerf(const std::string & name);
43
45 std::string p_name;
47 std::vector<size_t> p_timeBegin;
49 std::vector<size_t> p_nbCall;
51 std::vector<double> p_fullTime;
53 std::vector<double> p_fullSqrTime;
55 std::vector<size_t> p_minTime;
57 std::vector<size_t> p_maxTime;
58};
59
60
61
62#endif
63
void resize(size_t nbThread)
Resize the PFunctionPerf by respect to the number of thread which call the function.
PFunctionPerf & operator=(const PFunctionPerf &other)
Definition of equal operator of PFunctionPerf.
void stop(size_t threadIndex=0lu)
Stop the timing of one function.
std::string p_name
Name of the function to profile.
void printCsv(std::ostream &out=std::cout) const
Print the performance of the function in CSV format.
void print(std::ostream &out=std::cout) const
Print the performance of the function.
void copyPFunctionPerf(const PFunctionPerf &other)
Copy function of PFunctionPerf.
virtual ~PFunctionPerf()
Destructor of PFunctionPerf.
void setName(const std::string &name)
Set the name of the function profiled by the current PFunctionPerf.
PFunctionPerf(const std::string &name="")
Default constructor of PFunctionPerf.
std::vector< double > p_fullTime
Full time of execution for the current function (compute the averaged time with nbCall)
std::vector< size_t > p_maxTime
Maximum execution time.
void getPerf(size_t &nbCall, double &fullTime, double &averageTime, double &stdTime, size_t &minTime, size_t &maxTime) const
Get the performances of the current function.
std::vector< double > p_fullSqrTime
Sum of all square times (used to compute standard deviation)
void start(size_t threadIndex=0lu)
Start the timing for one function.
std::vector< size_t > p_nbCall
Number of calls of the current function.
const std::string & getName() const
Get the name of the function to profile.
void initialisationPFunctionPerf(const std::string &name)
Initialisation function of the class PFunctionPerf.
std::vector< size_t > p_minTime
Minimum execution time.
std::vector< size_t > p_timeBegin
Begin time of the current performance evaluation.
void reset()
Reset the profiling.