1 #include "otsdaq/ConfigurationInterface/TimeFormatter.h"
10 #include "otsdaq/Macros/CoutMacros.h"
11 #include "otsdaq/MessageFacility/MessageFacility.h"
18 TimeFormatter::TimeFormatter(std::string source)
23 std::cout << __COUT_HDR_FL__ <<
"[TimeFormatter::TimeFormatter()]\t\t Time counter started for " << origin_ << std::endl << std::endl;
24 startTime_ = getImSecTime();
28 void TimeFormatter::stopTimer(
void)
32 endTime_ = getImSecTime();
33 double start = startTime_.tv_sec + startTime_.tv_usec / 1000000.;
34 double stop = endTime_.tv_sec + endTime_.tv_usec / 1000000.;
35 std::cout << __COUT_HDR_FL__ <<
"[TimeFormatter::stopTimer()]\t\t\t Elapsed time: " << stop - start <<
" seconds for " << origin_ << std::endl
40 std::string TimeFormatter::getTime(
void)
47 thisTime = localtime(&aclock);
50 "%d-%02d-%02d %02d:%02d:%02d",
51 thisTime->tm_year + 1900,
64 struct tm* TimeFormatter::getITime(
void)
69 thisTime = localtime(&aclock);
74 std::string getmSecTime(
void)
77 struct timeval msecTime;
78 gettimeofday(&msecTime, (
struct timezone*)0);
80 sprintf(theDate,
"%d-%d", (
unsigned int)msecTime.tv_sec, (
unsigned int)msecTime.tv_usec);
81 return std::string(theDate);
87 struct timeval msecTime;
88 gettimeofday(&msecTime, (
struct timezone*)0);