PhoenixHardware  0.2.0
Tools to get hardware information
Loading...
Searching...
No Matches
PProfiler Class Reference

Profiler of functions. More...

#include <PProfiler.h>

Public Member Functions

size_t addFunction (const std::string &name, size_t nbThread=1lu)
 Add a function to profile.
 
PProfileroperator= (const PProfiler &other)
 Definition of equal operator of PProfiler.
 
 PProfiler ()
 Default constructor of PProfiler.
 
 PProfiler (const PProfiler &other)
 Copy constructor of PProfiler.
 
void print (std::ostream &out=std::cout) const
 Print all the PFunctionPerf of the PProfiler.
 
void printCsv (std::ostream &out=std::cout) const
 Print all the PFunctionPerf of the PProfiler in CSV format.
 
void printCsvHeader (std::ostream &out=std::cout) const
 Print header of all the PFunctionPerf of the PProfiler in CSV format.
 
void rename (size_t index, const std::string &name)
 Rename a function.
 
void reset ()
 Reset all the function perf.
 
void reset (size_t index, size_t threadIndex=0lu)
 Reset the given PFunctionPerf.
 
void start (size_t index, size_t threadIndex=0lu)
 Start the given PFunctionPerf.
 
void stop (size_t index, size_t threadIndex=0lu)
 Stop the given PFunctionPerf.
 
virtual ~PProfiler ()
 Destructor of PProfiler.
 

Protected Member Functions

void copyPProfiler (const PProfiler &other)
 Copy function of PProfiler.
 

Private Member Functions

void initialisationPProfiler ()
 Initialisation function of the class PProfiler.
 

Private Attributes

PVecFunctionPerf p_vecFunctionPerf
 Vector of performances for all registered functions.
 

Detailed Description

Profiler of functions.

Definition at line 16 of file PProfiler.h.

Constructor & Destructor Documentation

◆ PProfiler() [1/2]

PProfiler::PProfiler ( )

Default constructor of PProfiler.

Definition at line 13 of file PProfiler.cpp.

13 {
15}
void initialisationPProfiler()
Initialisation function of the class PProfiler.

References initialisationPProfiler().

Referenced by copyPProfiler(), operator=(), and PProfiler().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PProfiler() [2/2]

PProfiler::PProfiler ( const PProfiler & other)

Copy constructor of PProfiler.

Parameters
other: class to copy

Definition at line 20 of file PProfiler.cpp.

20 {
21 copyPProfiler(other);
22}
void copyPProfiler(const PProfiler &other)
Copy function of PProfiler.

References copyPProfiler(), and PProfiler().

+ Here is the call graph for this function:

◆ ~PProfiler()

PProfiler::~PProfiler ( )
virtual

Destructor of PProfiler.

Definition at line 25 of file PProfiler.cpp.

25 {
26
27}

Member Function Documentation

◆ addFunction()

size_t PProfiler::addFunction ( const std::string & name,
size_t nbThread = 1lu )

Add a function to profile.

Parameters
name: name of the function to profile
nbThread: number of threads which call the function
Returns
index of the corresponding function perf in the current PProfiler

Definition at line 43 of file PProfiler.cpp.

43 {
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}
PVecFunctionPerf p_vecFunctionPerf
Vector of performances for all registered functions.
Definition PProfiler.h:42

References p_vecFunctionPerf, and PFunctionPerf::resize().

+ Here is the call graph for this function:

◆ copyPProfiler()

void PProfiler::copyPProfiler ( const PProfiler & other)
protected

Copy function of PProfiler.

Parameters
other: class to copy

Definition at line 118 of file PProfiler.cpp.

118 {
120}

References p_vecFunctionPerf, and PProfiler().

Referenced by operator=(), and PProfiler().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initialisationPProfiler()

void PProfiler::initialisationPProfiler ( )
private

Initialisation function of the class PProfiler.

Definition at line 123 of file PProfiler.cpp.

123 {
124
125}

Referenced by PProfiler().

+ Here is the caller graph for this function:

◆ operator=()

PProfiler & PProfiler::operator= ( const PProfiler & other)

Definition of equal operator of PProfiler.

Parameters
other: class to copy
Returns
copied class

Definition at line 33 of file PProfiler.cpp.

33 {
34 copyPProfiler(other);
35 return *this;
36}

References copyPProfiler(), and PProfiler().

+ Here is the call graph for this function:

◆ print()

void PProfiler::print ( std::ostream & out = std::cout) const

Print all the PFunctionPerf of the PProfiler.

Parameters
[out]out : ostream to be used

Definition at line 93 of file PProfiler.cpp.

93 {
94 for(PVecFunctionPerf::const_iterator it(p_vecFunctionPerf.begin()); it != p_vecFunctionPerf.end(); ++it){
95 it->print(out);
96 }
97}

References p_vecFunctionPerf.

◆ printCsv()

void PProfiler::printCsv ( std::ostream & out = std::cout) const

Print all the PFunctionPerf of the PProfiler in CSV format.

Parameters
[out]out : ostream to be used

Definition at line 109 of file PProfiler.cpp.

109 {
110 for(PVecFunctionPerf::const_iterator it(p_vecFunctionPerf.begin()); it != p_vecFunctionPerf.end(); ++it){
111 it->printCsv(out);
112 }
113}

References p_vecFunctionPerf.

◆ printCsvHeader()

void PProfiler::printCsvHeader ( std::ostream & out = std::cout) const

Print header of all the PFunctionPerf of the PProfiler in CSV format.

Parameters
[out]out : ostream to be used

Definition at line 102 of file PProfiler.cpp.

102 {
103 out << "function,nbCall,fullTime,averageTime,stdTime,minTime,maxTime" << std::endl;
104}

◆ rename()

void PProfiler::rename ( size_t index,
const std::string & name )

Rename a function.

Parameters
index: index of the PFunctionPerf to be renamed
name: new name of the function

Definition at line 55 of file PProfiler.cpp.

55 {
56 p_vecFunctionPerf[index].setName(name);
57}

References p_vecFunctionPerf.

◆ reset() [1/2]

void PProfiler::reset ( )

Reset all the function perf.

Definition at line 84 of file PProfiler.cpp.

84 {
85 for(PVecFunctionPerf::iterator it(p_vecFunctionPerf.begin()); it != p_vecFunctionPerf.end(); ++it){
86 it->reset();
87 }
88}

References p_vecFunctionPerf.

◆ reset() [2/2]

void PProfiler::reset ( size_t index,
size_t threadIndex = 0lu )

Reset the given PFunctionPerf.

Parameters
index: index of the PFunctionPerf to be reset
threadIndex: index of the current thread

Definition at line 79 of file PProfiler.cpp.

79 {
80 p_vecFunctionPerf[index].reset(threadIndex);
81}

References p_vecFunctionPerf.

◆ start()

void PProfiler::start ( size_t index,
size_t threadIndex = 0lu )

Start the given PFunctionPerf.

Parameters
index: index of the PFunctionPerf to be started
threadIndex: index of the current thread

Definition at line 63 of file PProfiler.cpp.

63 {
64 p_vecFunctionPerf[index].start(threadIndex);
65}

References p_vecFunctionPerf.

◆ stop()

void PProfiler::stop ( size_t index,
size_t threadIndex = 0lu )

Stop the given PFunctionPerf.

Parameters
index: index of the PFunctionPerf to be stoped
threadIndex: index of the current thread

Definition at line 71 of file PProfiler.cpp.

71 {
72 p_vecFunctionPerf[index].stop(threadIndex);
73}

References p_vecFunctionPerf.

Member Data Documentation

◆ p_vecFunctionPerf

PVecFunctionPerf PProfiler::p_vecFunctionPerf
private

Vector of performances for all registered functions.

Definition at line 42 of file PProfiler.h.

Referenced by addFunction(), copyPProfiler(), print(), printCsv(), rename(), reset(), reset(), start(), and stop().


The documentation for this class was generated from the following files: