DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::oks::OksProfiler Class Reference

#include <profiler.hpp>

Public Types

enum  FunctionID {
  KernelDestructor = 0 , KernelOperatorOut , KernelLoadSchema , KernelSaveSchema ,
  KernelCloseSchema , KernelCreateSchemaClassList , KernelLoadData , KernelSaveData ,
  KernelCloseData , KernelCreateDataObjectList , KernelIsDanglingObject , KernelIsDanglingClass ,
  ObjectStreamConstructor , ObjectNormalConstructor , ObjectCopyConstructor , ObjectDestructor ,
  ObjectOperatorEqual , ObjectOperatorOut , ObjectSatisfiesQueryExpression , ObjectGetFreeObjectId ,
  ObjectPutObject , ClassConstructor , ClassDestructor , ClassOperatorOut ,
  ClassGetObject , Classexecute_query , ClassRegistrateClass , ClassRegistrateClassChange ,
  ClassRegistrateAttributeChange , ClassRegistrateRelationshipChange , ClassRegistrateInstances , ClassCreateSubClassesList ,
  fStringToQuery , fStringToQueryExpression , QueryOperatorFrom
}
 

Public Member Functions

const std::chrono::time_point< std::chrono::steady_clock > start_time_point () const
 

Private Member Functions

 OksProfiler ()
 
void Start (OksProfiler::FunctionID, std::chrono::time_point< std::chrono::steady_clock > &)
 
void Stop (OksProfiler::FunctionID, const std::chrono::time_point< std::chrono::steady_clock > &)
 

Private Attributes

std::chrono::time_point< std::chrono::steady_clock > p_start_time_point
 
double t_total [(unsigned) OksProfiler::QueryOperatorFrom+1]
 
unsigned long c_total [(unsigned) OksProfiler::QueryOperatorFrom+1]
 

Friends

class OksKernel
 
class OksFunctionProfiler
 
std::ostream & operator<< (std::ostream &s, const OksProfiler &t)
 

Detailed Description

Definition at line 14 of file profiler.hpp.

Member Enumeration Documentation

◆ FunctionID

Enumerator
KernelDestructor 
KernelOperatorOut 
KernelLoadSchema 
KernelSaveSchema 
KernelCloseSchema 
KernelCreateSchemaClassList 
KernelLoadData 
KernelSaveData 
KernelCloseData 
KernelCreateDataObjectList 
KernelIsDanglingObject 
KernelIsDanglingClass 
ObjectStreamConstructor 
ObjectNormalConstructor 
ObjectCopyConstructor 
ObjectDestructor 
ObjectOperatorEqual 
ObjectOperatorOut 
ObjectSatisfiesQueryExpression 
ObjectGetFreeObjectId 
ObjectPutObject 
ClassConstructor 
ClassDestructor 
ClassOperatorOut 
ClassGetObject 
Classexecute_query 
ClassRegistrateClass 
ClassRegistrateClassChange 
ClassRegistrateAttributeChange 
ClassRegistrateRelationshipChange 
ClassRegistrateInstances 
ClassCreateSubClassesList 
fStringToQuery 
fStringToQueryExpression 
QueryOperatorFrom 

Definition at line 17 of file profiler.hpp.

18 {
54 };

Constructor & Destructor Documentation

◆ OksProfiler()

dunedaq::oks::OksProfiler::OksProfiler ( )
private

Definition at line 56 of file profiler.cpp.

57{
58 for(short i=0; i<=(short)QueryOperatorFrom; i++) {
59 t_total[i] = 0.0;
60 c_total[i] = 0;
61 }
62
63 p_start_time_point = std::chrono::steady_clock::now();
64}
unsigned long c_total[(unsigned) OksProfiler::QueryOperatorFrom+1]
Definition profiler.hpp:77
std::chrono::time_point< std::chrono::steady_clock > p_start_time_point
Definition profiler.hpp:74
double t_total[(unsigned) OksProfiler::QueryOperatorFrom+1]
Definition profiler.hpp:76

Member Function Documentation

◆ Start()

void dunedaq::oks::OksProfiler::Start ( OksProfiler::FunctionID fid,
std::chrono::time_point< std::chrono::steady_clock > & time_point )
private

Definition at line 161 of file profiler.cpp.

162{
163 time_point = std::chrono::steady_clock::now();
164 c_total[fid]++;
165}

◆ start_time_point()

const std::chrono::time_point< std::chrono::steady_clock > dunedaq::oks::OksProfiler::start_time_point ( ) const
inline

Definition at line 60 of file profiler.hpp.

61 {
62 return p_start_time_point;
63 }

◆ Stop()

void dunedaq::oks::OksProfiler::Stop ( OksProfiler::FunctionID fid,
const std::chrono::time_point< std::chrono::steady_clock > & time_point )
private

Definition at line 168 of file profiler.cpp.

169{
170 t_total[fid] += std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now()-time_point).count();
171}

Friends And Related Symbol Documentation

◆ OksFunctionProfiler

friend class OksFunctionProfiler
friend

Definition at line 80 of file profiler.hpp.

◆ OksKernel

friend class OksKernel
friend

Definition at line 79 of file profiler.hpp.

◆ operator<<

std::ostream & operator<< ( std::ostream & s,
const OksProfiler & t )
friend

Definition at line 84 of file profiler.cpp.

86{
87 const int p = s.precision(4);
88
89 printTableLine(s, '=');
90
91 s << '|';
92 s.fill(' ');
93 s.width(76);
94 s.setf(std::ios::left, std::ios::adjustfield);
95 s << " O K S P R O F I L E R " << '|' << std::endl;
96
97 printTableLine(s, '-');
98
99 s << "| Time: ";
100 s.setf(std::ios::right, std::ios::adjustfield);
101 s << std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now()-t.p_start_time_point).count() / 1000.;
102 s.fill(' ');
103 s.width(64);
104 s.setf(std::ios::left, std::ios::adjustfield);
105 s << " seconds" << '|' << std::endl;
106
107 printTableSeparator(s, '-');
108
109 s.fill(' ');
110 s.width(42); s << "| Function name" << '|';
111 s.width(12); s << " # of calls" << '|';
112 s.width(10); s << " total T," << '|';
113 s.width(10); s << " ~T/call," << '|' << std::endl;
114
115 s.fill(' ');
116 s.width(42); s << '|' << "" << '|';
117 s.width(12); s << "" << '|';
118 s.width(10); s << " ms" << '|';
119 s.width(10); s << " µs" << '|' << std::endl;
120
121 for(short i=0; i<=(short)OksProfiler::QueryOperatorFrom; i++) {
122 if(i==0 || i==12 || i==21 || i==32) printTableSeparator(s, '-');
123
124 s << "| ";
125
126 s.width(40);
127 s.fill(' ');
128 s.setf(std::ios::left, std::ios::adjustfield);
129 s << OksProfilerFunctionsStr[i] << '|';
130
131 s.width(11);
132 s.setf(std::ios::right, std::ios::adjustfield);
133 s << t.c_total[i] << ' ' << '|';
134
135 if(t.c_total[i]) {
136 s.width(9);
137 s << t.t_total[i]/1000. << ' ' << '|';
138
139 s.width(9);
140 s << t.t_total[i]/(double)t.c_total[i];
141 }
142 else {
143 s.width(10);
144 s << " - " << '|';
145
146 s.width(9);
147 s << " -";
148 }
149
150 s << " |\n";
151 }
152
153 printTableSeparator(s, '=');
154
155 s.precision(p);
156
157 return s;
158}
static const char * OksProfilerFunctionsStr[]
Definition profiler.cpp:9
static void printTableSeparator(std::ostream &s, unsigned char c)
Definition profiler.cpp:66
static void printTableLine(std::ostream &s, unsigned char c)
Definition profiler.cpp:76

Member Data Documentation

◆ c_total

unsigned long dunedaq::oks::OksProfiler::c_total[(unsigned) OksProfiler::QueryOperatorFrom+1]
private

Definition at line 77 of file profiler.hpp.

◆ p_start_time_point

std::chrono::time_point<std::chrono::steady_clock> dunedaq::oks::OksProfiler::p_start_time_point
private

Definition at line 74 of file profiler.hpp.

◆ t_total

double dunedaq::oks::OksProfiler::t_total[(unsigned) OksProfiler::QueryOperatorFrom+1]
private

Definition at line 76 of file profiler.hpp.


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