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 18 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 21 of file profiler.hpp.

22 {
58 };

Constructor & Destructor Documentation

◆ OksProfiler()

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

Definition at line 58 of file profiler.cpp.

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

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 179 of file profiler.cpp.

180{
181 time_point = std::chrono::steady_clock::now();
182 c_total[fid]++;
183}

◆ start_time_point()

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

Definition at line 62 of file profiler.hpp.

62{ return p_start_time_point; }

◆ Stop()

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

Definition at line 186 of file profiler.cpp.

187{
188 t_total[fid] +=
189 std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now() - time_point).count();
190}

◆ OksFunctionProfiler

friend class OksFunctionProfiler
friend

Definition at line 77 of file profiler.hpp.

◆ OksKernel

friend class OksKernel
friend

Definition at line 76 of file profiler.hpp.

◆ operator<<

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

Definition at line 92 of file profiler.cpp.

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

Member Data Documentation

◆ c_total

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

Definition at line 74 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 71 of file profiler.hpp.

◆ t_total

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

Definition at line 73 of file profiler.hpp.


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