artdaq_core  v3_04_09
artdaq::TimeUtils Namespace Reference

Namespace to hold useful time-converting functions. More...

Typedefs

typedef std::chrono::duration
< double, std::ratio< 1 > > 
seconds
 

Functions

constexpr double GetElapsedTime (std::chrono::steady_clock::time_point then, std::chrono::steady_clock::time_point now=std::chrono::steady_clock::now())
 Get the number of seconds in the given interval More...
 
constexpr size_t GetElapsedTimeMicroseconds (std::chrono::steady_clock::time_point then, std::chrono::steady_clock::time_point now=std::chrono::steady_clock::now())
 Gets the number of microseconds in the given time interval More...
 
constexpr size_t GetElapsedTimeMilliseconds (std::chrono::steady_clock::time_point then, std::chrono::steady_clock::time_point now=std::chrono::steady_clock::now())
 Gets the number of milliseconds in the given time interval More...
 
std::string convertUnixTimeToString (time_t inputUnixTime)
 Converts a Unix time to its string representation, in UTC. More...
 
std::string convertUnixTimeToString (struct timeval const &inputUnixTime)
 Converts a Unix time to its string representation, in UTC. More...
 
std::string convertUnixTimeToString (struct timespec const &inputUnixTime)
 Converts a Unix time to its string representation, in UTC. More...
 
uint64_t gettimeofday_us ()
 Get the current time of day in microseconds (from gettimeofday system call) More...
 
double convertUnixTimeToSeconds (time_t inputUnixTime)
 Converts a Unix time to double. More...
 
double convertUnixTimeToSeconds (struct timeval const &inputUnixTime)
 Converts a Unix time to double. More...
 
double convertUnixTimeToSeconds (struct timespec const &inputUnixTime)
 Converts a Unix time to double. More...
 

Detailed Description

Namespace to hold useful time-converting functions.

Typedef Documentation

typedef std::chrono::duration<double, std::ratio<1> > artdaq::TimeUtils::seconds

We shall use artdaq::detail::seconds as our "standard" duration type. Note that this differs from std::chrono::seconds, which has a representation in some integer type of at least 35 bits.

daqrate::duration dur(1.0) represents a duration of 1 second. daqrate::duration dur2(0.001) represents a duration of 1 millisecond.

Definition at line 24 of file TimeUtils.hh.

Function Documentation

double artdaq::TimeUtils::convertUnixTimeToSeconds ( time_t  inputUnixTime)

Converts a Unix time to double.

Parameters
inputUnixTimeA time_t Unix time variable
Returns
double representation of Unix time (seconds since epoch)

Definition at line 59 of file TimeUtils.cc.

double artdaq::TimeUtils::convertUnixTimeToSeconds ( struct timeval const &  inputUnixTime)

Converts a Unix time to double.

Parameters
inputUnixTimeA struct timeval Unix time variable
Returns
double representation of Unix time (in seconds)

Definition at line 65 of file TimeUtils.cc.

double artdaq::TimeUtils::convertUnixTimeToSeconds ( struct timespec const &  inputUnixTime)

Converts a Unix time to double.

Parameters
inputUnixTimeA struct timespec Unix time variable
Returns
double representation of Unix time (in seconds)

Definition at line 71 of file TimeUtils.cc.

std::string artdaq::TimeUtils::convertUnixTimeToString ( time_t  inputUnixTime)

Converts a Unix time to its string representation, in UTC.

Parameters
inputUnixTimeA time_t Unix time variable
Returns
std::string representation of Unix time, in UTC

Definition at line 7 of file TimeUtils.cc.

std::string artdaq::TimeUtils::convertUnixTimeToString ( struct timeval const &  inputUnixTime)

Converts a Unix time to its string representation, in UTC.

Parameters
inputUnixTimeA struct timeval Unix time variable
Returns
std::string representation of Unix time, in UTC

Definition at line 18 of file TimeUtils.cc.

std::string artdaq::TimeUtils::convertUnixTimeToString ( struct timespec const &  inputUnixTime)

Converts a Unix time to its string representation, in UTC.

Parameters
inputUnixTimeA struct timespec Unix time variable
Returns
std::string representation of Unix time, in UTC

Definition at line 35 of file TimeUtils.cc.

constexpr double artdaq::TimeUtils::GetElapsedTime ( std::chrono::steady_clock::time_point  then,
std::chrono::steady_clock::time_point  now = std::chrono::steady_clock::now() 
)
inline

Get the number of seconds in the given interval

Parameters
thenstd::chrono::steady_clock::time_point representing start of interval
nowstd::chrono::steady_clock::time_point representing end of interval. Defaults to std::chrono::steady_clock::now()
Returns
Seconds in time interval, expressed as double

Definition at line 32 of file TimeUtils.hh.

constexpr size_t artdaq::TimeUtils::GetElapsedTimeMicroseconds ( std::chrono::steady_clock::time_point  then,
std::chrono::steady_clock::time_point  now = std::chrono::steady_clock::now() 
)
inline

Gets the number of microseconds in the given time interval

Parameters
thenstd::chrono::steady_clock::time_point representing start of interval
nowstd::chrono::steady_clock::time_point representing end of interval. Defaults to std::chrono::steady_clock::now()
Returns
Microseconds in time interval

Definition at line 43 of file TimeUtils.hh.

constexpr size_t artdaq::TimeUtils::GetElapsedTimeMilliseconds ( std::chrono::steady_clock::time_point  then,
std::chrono::steady_clock::time_point  now = std::chrono::steady_clock::now() 
)
inline

Gets the number of milliseconds in the given time interval

Parameters
thenstd::chrono::steady_clock::time_point representing start of interval
nowstd::chrono::steady_clock::time_point representing end of interval. Defaults to std::chrono::steady_clock::now()
Returns
Milliseconds in time interval

Definition at line 54 of file TimeUtils.hh.

uint64_t artdaq::TimeUtils::gettimeofday_us ( )

Get the current time of day in microseconds (from gettimeofday system call)

Returns
The current time of day in microseconds

Definition at line 51 of file TimeUtils.cc.