Line | Branch | Exec | Source |
---|---|---|---|
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 | |||
12 | ///Default constructor of PProfiler | ||
13 | 6 | PProfiler::PProfiler(){ | |
14 |
1/1✓ Branch 0 (3→4) taken 6 times.
|
6 | initialisationPProfiler(); |
15 | 6 | } | |
16 | |||
17 | ///Copy constructor of PProfiler | ||
18 | /** @param other : class to copy | ||
19 | */ | ||
20 | 2 | PProfiler::PProfiler(const PProfiler & other){ | |
21 |
1/1✓ Branch 0 (3→4) taken 2 times.
|
2 | copyPProfiler(other); |
22 | 2 | } | |
23 | |||
24 | ///Destructor of PProfiler | ||
25 | 8 | PProfiler::~PProfiler(){ | |
26 | |||
27 | 8 | } | |
28 | |||
29 | ///Definition of equal operator of PProfiler | ||
30 | /** @param other : class to copy | ||
31 | * @return copied class | ||
32 | */ | ||
33 | 2 | PProfiler & PProfiler::operator = (const PProfiler & other){ | |
34 | 2 | copyPProfiler(other); | |
35 | 2 | return *this; | |
36 | } | ||
37 | |||
38 | ///Add a function to profile | ||
39 | /** @param name : name of the function to profile | ||
40 | * @param nbThread : number of threads which call the function | ||
41 | * @return index of the corresponding function perf in the current PProfiler | ||
42 | */ | ||
43 | 4 | size_t PProfiler::addFunction(const std::string & name, size_t nbThread){ | |
44 |
1/1✓ Branch 0 (2→3) taken 4 times.
|
4 | PFunctionPerf perf(name); |
45 |
2/2✓ Branch 0 (3→4) taken 1 times.
✓ Branch 1 (3→5) taken 3 times.
|
4 | if(nbThread < 1lu){nbThread = 1;} |
46 |
1/1✓ Branch 0 (5→6) taken 4 times.
|
4 | perf.resize(nbThread); |
47 |
1/1✓ Branch 0 (6→7) taken 4 times.
|
4 | p_vecFunctionPerf.push_back(perf); |
48 | 8 | return p_vecFunctionPerf.size() - 1lu; | |
49 | 4 | } | |
50 | |||
51 | ///Rename a function | ||
52 | /** @param index : index of the PFunctionPerf to be renamed | ||
53 | * @param name : new name of the function | ||
54 | */ | ||
55 | 2 | void PProfiler::rename(size_t index, const std::string & name){ | |
56 | 2 | p_vecFunctionPerf[index].setName(name); | |
57 | 2 | } | |
58 | |||
59 | ///Start the given PFunctionPerf | ||
60 | /** @param index : index of the PFunctionPerf to be started | ||
61 | * @param threadIndex : index of the current thread | ||
62 | */ | ||
63 | 3987 | void PProfiler::start(size_t index, size_t threadIndex){ | |
64 | 3987 | p_vecFunctionPerf[index].start(threadIndex); | |
65 | 3987 | } | |
66 | |||
67 | ///Stop the given PFunctionPerf | ||
68 | /** @param index : index of the PFunctionPerf to be stoped | ||
69 | * @param threadIndex : index of the current thread | ||
70 | */ | ||
71 | 4000 | void PProfiler::stop(size_t index, size_t threadIndex){ | |
72 | 4000 | p_vecFunctionPerf[index].stop(threadIndex); | |
73 | 3989 | } | |
74 | |||
75 | ///Reset the given PFunctionPerf | ||
76 | /** @param index : index of the PFunctionPerf to be reset | ||
77 | * @param threadIndex : index of the current thread | ||
78 | */ | ||
79 | 20 | void PProfiler::reset(size_t index, size_t threadIndex){ | |
80 | 20 | p_vecFunctionPerf[index].reset(threadIndex); | |
81 | 20 | } | |
82 | |||
83 | ///Reset all the function perf | ||
84 | 2 | void PProfiler::reset(){ | |
85 |
2/2✓ Branch 0 (16→3) taken 2 times.
✓ Branch 1 (16→17) taken 2 times.
|
8 | for(PVecFunctionPerf::iterator it(p_vecFunctionPerf.begin()); it != p_vecFunctionPerf.end(); ++it){ |
86 |
1/1✓ Branch 0 (5→6) taken 2 times.
|
2 | it->reset(); |
87 | } | ||
88 | 2 | } | |
89 | |||
90 | ///Print all the PFunctionPerf of the PProfiler | ||
91 | /** @param[out] : out : ostream to be used | ||
92 | */ | ||
93 | 16 | void PProfiler::print(std::ostream & out) const{ | |
94 |
2/2✓ Branch 0 (16→3) taken 16 times.
✓ Branch 1 (16→17) taken 16 times.
|
64 | for(PVecFunctionPerf::const_iterator it(p_vecFunctionPerf.begin()); it != p_vecFunctionPerf.end(); ++it){ |
95 |
1/1✓ Branch 0 (5→6) taken 16 times.
|
16 | it->print(out); |
96 | } | ||
97 | 16 | } | |
98 | |||
99 | ///Print header of all the PFunctionPerf of the PProfiler in CSV format | ||
100 | /** @param[out] : out : ostream to be used | ||
101 | */ | ||
102 | 2 | void PProfiler::printCsvHeader(std::ostream & out) const{ | |
103 | 2 | out << "function,nbCall,fullTime,averageTime,stdTime,minTime,maxTime" << std::endl; | |
104 | 2 | } | |
105 | |||
106 | ///Print all the PFunctionPerf of the PProfiler in CSV format | ||
107 | /** @param[out] : out : ostream to be used | ||
108 | */ | ||
109 | 11 | void PProfiler::printCsv(std::ostream & out) const{ | |
110 |
2/2✓ Branch 0 (16→3) taken 11 times.
✓ Branch 1 (16→17) taken 11 times.
|
44 | for(PVecFunctionPerf::const_iterator it(p_vecFunctionPerf.begin()); it != p_vecFunctionPerf.end(); ++it){ |
111 |
1/1✓ Branch 0 (5→6) taken 11 times.
|
11 | it->printCsv(out); |
112 | } | ||
113 | 11 | } | |
114 | |||
115 | ///Copy function of PProfiler | ||
116 | /** @param other : class to copy | ||
117 | */ | ||
118 | 4 | void PProfiler::copyPProfiler(const PProfiler & other){ | |
119 | 4 | p_vecFunctionPerf = other.p_vecFunctionPerf; | |
120 | 4 | } | |
121 | |||
122 | ///Initialisation function of the class PProfiler | ||
123 | 6 | void PProfiler::initialisationPProfiler(){ | |
124 | |||
125 | 6 | } | |
126 | |||
127 | |||
128 | |||
129 | |||
130 | |||
131 |