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 19 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 22 of file profiler.hpp.

23 {
59 };

Constructor & Destructor Documentation

◆ OksProfiler()

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

Definition at line 61 of file profiler.cpp.

62{
63 for(short i=0; i<=(short)QueryOperatorFrom; i++) {
64 t_total[i] = 0.0;
65 c_total[i] = 0;
66 }
67
68 p_start_time_point = std::chrono::steady_clock::now();
69}
unsigned long c_total[(unsigned) OksProfiler::QueryOperatorFrom+1]
Definition profiler.hpp:82
std::chrono::time_point< std::chrono::steady_clock > p_start_time_point
Definition profiler.hpp:79
double t_total[(unsigned) OksProfiler::QueryOperatorFrom+1]
Definition profiler.hpp:81

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

167{
168 time_point = std::chrono::steady_clock::now();
169 c_total[fid]++;
170}

◆ start_time_point()

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

Definition at line 65 of file profiler.hpp.

66 {
67 return p_start_time_point;
68 }

◆ Stop()

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

Definition at line 173 of file profiler.cpp.

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

◆ OksFunctionProfiler

friend class OksFunctionProfiler
friend

Definition at line 85 of file profiler.hpp.

◆ OksKernel

friend class OksKernel
friend

Definition at line 84 of file profiler.hpp.

◆ operator<<

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

Definition at line 89 of file profiler.cpp.

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

Member Data Documentation

◆ c_total

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

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

◆ t_total

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

Definition at line 81 of file profiler.hpp.


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