9 #include <daq/modules/ElapsedTime/ElapsedTimeModule.h>
26 setDescription(
"Encode DataStore into RingBuffer");
28 addParam(
"EventInterval", m_interval,
"Event interval to measure time",
32 B2INFO(
"ElapsedTime: Constructor done.");
36 ElapsedTimeModule::~ElapsedTimeModule()
40 void ElapsedTimeModule::initialize()
42 gettimeofday(&m_t0, 0); \
50 void ElapsedTimeModule::beginRun()
52 B2INFO(
"ElapsedTime: started to measure elapsed time.");
56 void ElapsedTimeModule::event()
58 if (m_nevent % m_interval == 0) {
59 gettimeofday(&m_tnow, 0);
60 double etime = (double)((m_tnow.tv_sec - m_t0.tv_sec) * 1000000 +
61 (m_tnow.tv_usec - m_t0.tv_usec));
62 double delta = (double)((m_tnow.tv_sec - m_tprev.tv_sec) * 1000000 +
63 (m_tnow.tv_usec - m_tprev.tv_usec));
64 double evtime = etime / ((double)m_nevent);
66 double devtime = delta / (double)m_interval;
67 double erate = (double)m_nevent / etime * 1000.0;
68 double derate = (double)m_interval / delta * 1000.0;
69 printf(
"Elapsed( %d ) : time = %7.2f (msec), time/evt = %5.2f [ %5.3f ](msec) (%f[%f]kHz)\n",
70 m_nevent, etime / 1000.0, evtime / 1000.0, devtime / 1000.0,
79 void ElapsedTimeModule::endRun()
82 gettimeofday(&m_tend, 0);
83 double etime = (double)((m_tnow.tv_sec - m_t0.tv_sec) * 1000000 +
84 (m_tnow.tv_usec - m_t0.tv_usec));
85 double evtime = etime / ((double)m_nevent);
86 printf(
"Total Elapsed : time = %f (msec), time/evt = %f (msec)\n",
87 etime / 1000.0, evtime / 1000.0);
91 void ElapsedTimeModule::terminate()
93 B2INFO(
"ElapsedTime: terminate called");
A class definition of an input module for Sequential ROOT I/O.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.