Line | Branch | Exec | Source |
---|---|---|---|
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> | ||
14 | #include "phoenix_hardware_rdtsc.h" | ||
15 | |||
16 | ///@brief Performances of a function | ||
17 | class PFunctionPerf{ | ||
18 | public: | ||
19 |
2/2✓ Branch 0 (10→11) taken 1 times.
✓ Branch 2 (14→15) taken 1 times.
|
3 | PFunctionPerf(const std::string & name = ""); |
20 | PFunctionPerf(const PFunctionPerf & other); | ||
21 | virtual ~PFunctionPerf(); | ||
22 | PFunctionPerf & operator = (const PFunctionPerf & other); | ||
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 | |||
44 | ///Name of the function to profile | ||
45 | std::string p_name; | ||
46 | ///Begin time of the current performance evaluation | ||
47 | std::vector<size_t> p_timeBegin; | ||
48 | ///Number of calls of the current function | ||
49 | std::vector<size_t> p_nbCall; | ||
50 | ///Full time of execution for the current function (compute the averaged time with nbCall) | ||
51 | std::vector<double> p_fullTime; | ||
52 | ///Sum of all square times (used to compute standard deviation) | ||
53 | std::vector<double> p_fullSqrTime; | ||
54 | ///Minimum execution time | ||
55 | std::vector<size_t> p_minTime; | ||
56 | ///Maximum execution time | ||
57 | std::vector<size_t> p_maxTime; | ||
58 | }; | ||
59 | |||
60 | |||
61 | |||
62 | #endif | ||
63 | |||
64 |