9#include <daq/modules/ElapsedTime/ElapsedTimeModule.h>
28 addParam(
"EventInterval", m_interval,
"Event interval to measure time",
32 B2INFO(
"ElapsedTime: Constructor done.");
36ElapsedTimeModule::~ElapsedTimeModule()
42 gettimeofday(&m_t0, 0); \
52 B2INFO(
"ElapsedTime: started to measure elapsed time.");
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,
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);
93 B2INFO(
"ElapsedTime: terminate called");
void initialize() override
Module functions to be called from main process.
void event() override
This method is the core of the module.
ElapsedTimeModule()
Constructor / Destructor.
void endRun() override
This method is called if the current run ends.
void terminate() override
This method is called at the end of the event processing.
void beginRun() override
Module functions to be called from event process.
void setDescription(const std::string &description)
Sets the description of the module.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.