Evo C++ Library v0.5.1
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
TimerStampCpu Class Reference

#include <evo/timer.h>

Inheritance diagram for TimerStampCpu:
Inheritance graph
[legend]

Detailed Description

Holds a CPU (process) timer-stamp, used as template argument with TimerT.

Public Member Functions

void add_msec (ulong new_msec)
 Add milliseconds to current time. More...
 
void add_nsec (ulongl new_nsec)
 Add nanoseconds to current time. More...
 
void clear ()
 Clear and reset as 0. More...
 
int compare (const SysTimestamp &oth) const
 Compare to another timestamp. More...
 
ulongl diff_msec (const SysTimestamp &start) const
 Use this as an end-time and get the difference from start time in milliseconds. More...
 
ulongl diff_nsec (const SysTimestamp &start) const
 Use this as an end-time and get the difference from start time in nanoseconds. More...
 
ulongl diff_usec (const SysTimestamp &start) const
 Use this as an end-time and get the difference from start time in microseconds. More...
 
void set ()
 
void set (const SysNativeTimeStamp &src)
 Set from system native timestamp. More...
 
void set_cpu ()
 Set as current CPU (process) time for use by timers. More...
 

Static Public Member Functions

static void get_wall_datetime_fields_local (int &year, int &month, int &day, int &hour, int &minute, int &second, int &msecond)
 Get fields for current real (wall clock) time for calendar date/time use (Local Time). More...
 
static void get_wall_datetime_fields_local (int &year, int &month, int &day, int &hour, int &minute, int &second, int &msecond, int &tz_offset)
 Get fields for current real (wall clock) time for calendar date/time use (Local Time). More...
 
static void get_wall_datetime_fields_utc (int &year, int &month, int &day, int &hour, int &minute, int &second, int &msecond)
 Get fields for current real (wall clock) time for calendar date/time use (UTC). More...
 
static int tz_get_offset ()
 Get current time zone (local time) offset from UTC in minutes. More...
 
static void tz_init ()
 Initializater that optimizes timezone (local time) conversion in some cases. More...
 

Public Attributes

ulong nsec
 Number of nanoseconds from seconds. More...
 
ulongl sec
 Number of seconds since Jan 1, EPOCH_YEAR. More...
 

Static Public Attributes

static const int EPOCH_YEAR = 1970
 Epoch year used by system – 1970 for Linux/Unix/POSIX, 1601 for Windows. More...
 
static const ulong MSEC_PER_SEC = 1000
 Milliseconds per second. More...
 
static const ulong NSEC_PER_MSEC = 1000000UL
 Nanoseconds per millisecond. More...
 
static const ulong NSEC_PER_SEC = 1000000000UL
 Nanoseconds per second. More...
 
static const ulong NSEC_PER_USEC = 1000
 Nanoseconds per microsecond. More...
 
static const int SEC_PER_MIN = 60
 Seconds per minute. More...
 
static const ulong USEC_PER_SEC = 1000000UL
 Microseconds per second. More...
 

Member Function Documentation

◆ add_msec()

void add_msec ( ulong  new_msec)
inlineinherited

Add milliseconds to current time.

  • This normalizes the current time so the nsec field has less than 1 second
Parameters
new_msecMilliseconds to add

◆ add_nsec()

void add_nsec ( ulongl  new_nsec)
inlineinherited

Add nanoseconds to current time.

  • This normalizes the current time so the nsec field has less than 1 second
Parameters
new_nsecNanoseconds to add

◆ clear()

void clear ( )
inlineinherited

Clear and reset as 0.

◆ compare()

int compare ( const SysTimestamp oth) const
inlineinherited

Compare to another timestamp.

Parameters
othOther timestamp to compare to
Returns
Result (<0 if this is less, 0 if equal, >0 if this is greater)

◆ diff_msec()

ulongl diff_msec ( const SysTimestamp start) const
inlineinherited

Use this as an end-time and get the difference from start time in milliseconds.

Parameters
startStart time to use, must not be greater than this
Returns
Difference in milliseconds

◆ diff_nsec()

ulongl diff_nsec ( const SysTimestamp start) const
inlineinherited

Use this as an end-time and get the difference from start time in nanoseconds.

Parameters
startStart time to use, must not be greater than this
Returns
Difference in nanoseconds

◆ diff_usec()

ulongl diff_usec ( const SysTimestamp start) const
inlineinherited

Use this as an end-time and get the difference from start time in microseconds.

Parameters
startStart time to use, must not be greater than this
Returns
Difference in microseconds

◆ get_wall_datetime_fields_local() [1/2]

static void get_wall_datetime_fields_local ( int &  year,
int &  month,
int &  day,
int &  hour,
int &  minute,
int &  second,
int &  msecond 
)
inlinestaticinherited

Get fields for current real (wall clock) time for calendar date/time use (Local Time).

  • This is equivalent of using get_wall_datetime() then converting the timestamp to date/time fields in local time
  • Time is in the current local timezone, but this does not get the local timezone offset
Parameters
yearSet to 4 digit year for date [out]
monthSet to month of year for date (1 - 12) [out]
daySet to day of moneth for date (1 - 31) [out]
hourSet to hour for time of day (0 - 23) [out]
minuteMinutes for time of day (0 - 59) [out]
secondSeconds for time of day (0 - 60) [out]
msecondMilliseconds for time of day (0 - 999) [out]

◆ get_wall_datetime_fields_local() [2/2]

static void get_wall_datetime_fields_local ( int &  year,
int &  month,
int &  day,
int &  hour,
int &  minute,
int &  second,
int &  msecond,
int &  tz_offset 
)
inlinestaticinherited

Get fields for current real (wall clock) time for calendar date/time use (Local Time).

  • This is equivalent of using get_wall_datetime() then converting the timestamp to date/time fields in local time
  • Time is in the current local timezone
Parameters
yearSet to 4 digit year for date [out]
monthSet to month of year for date (1 - 12) [out]
daySet to day of moneth for date (1 - 31) [out]
hourSet to hour for time of day (0 - 23) [out]
minuteMinutes for time of day (0 - 59) [out]
secondSeconds for time of day (0 - 60) [out]
msecondMilliseconds for time of day (0 - 999) [out]
tz_offsetTime zone offset in minutes, see tz_get_offset() [out]

◆ get_wall_datetime_fields_utc()

static void get_wall_datetime_fields_utc ( int &  year,
int &  month,
int &  day,
int &  hour,
int &  minute,
int &  second,
int &  msecond 
)
inlinestaticinherited

Get fields for current real (wall clock) time for calendar date/time use (UTC).

  • This is equivalent of using get_wall_datetime() then converting the timestamp to date/time fields
  • Timezone is always UTC here
Parameters
yearSet to 4 digit year for date [out]
monthSet to month of year for date (1 - 12) [out]
daySet to day of moneth for date (1 - 31) [out]
hourSet to hour for time of day (0 - 23) [out]
minuteMinutes for time of day (0 - 59) [out]
secondSeconds for time of day (0 - 60) [out]
msecondMilliseconds for time of day (0 - 999) [out]

◆ set() [1/2]

void set ( )
inline

◆ set() [2/2]

void set ( const SysNativeTimeStamp src)
inlineinherited

Set from system native timestamp.

  • This converts from SysNativeTimeStamp, which has platform-specific fields
  • Timezone is always UTC here
Parameters
srcSource to convert from

◆ set_cpu()

void set_cpu ( )
inlineinherited

Set as current CPU (process) time for use by timers.

◆ tz_get_offset()

static int tz_get_offset ( )
inlinestaticinherited

Get current time zone (local time) offset from UTC in minutes.

Returns
Time zone offset from UTC in minutes, 0 for UTC, negative for the Western Hemisphere (America), positive for the remaining time zones

◆ tz_init()

static void tz_init ( )
inlinestaticinherited

Initializater that optimizes timezone (local time) conversion in some cases.

  • On some systems (Linux) this sets an env var (TZ) if not already set, which reduces system calls for local time conversion
  • Caution: Not thread safe – this should be called once at startup, before other threads are started

Member Data Documentation

◆ EPOCH_YEAR

const int EPOCH_YEAR = 1970
staticinherited

Epoch year used by system – 1970 for Linux/Unix/POSIX, 1601 for Windows.

◆ MSEC_PER_SEC

const ulong MSEC_PER_SEC = 1000
staticinherited

Milliseconds per second.

◆ nsec

ulong nsec
inherited

Number of nanoseconds from seconds.

◆ NSEC_PER_MSEC

const ulong NSEC_PER_MSEC = 1000000UL
staticinherited

Nanoseconds per millisecond.

◆ NSEC_PER_SEC

const ulong NSEC_PER_SEC = 1000000000UL
staticinherited

Nanoseconds per second.

◆ NSEC_PER_USEC

const ulong NSEC_PER_USEC = 1000
staticinherited

Nanoseconds per microsecond.

◆ sec

ulongl sec
inherited

Number of seconds since Jan 1, EPOCH_YEAR.

◆ SEC_PER_MIN

const int SEC_PER_MIN = 60
staticinherited

Seconds per minute.

◆ USEC_PER_SEC

const ulong USEC_PER_SEC = 1000000UL
staticinherited

Microseconds per second.


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