gem5  v21.0.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Time Class Reference

#include <time.hh>

Public Member Functions

 Time ()
 
 Time (double sec)
 
 Time (const Time &val)
 
 Time (uint64_t sec, uint64_t nsec)
 
 Time (const timeval &tv)
 
 Time (const timespec &ts)
 
time_t sec () const
 Accessors for getting and setting the current clock. More...
 
long msec () const
 
long usec () const
 
long nsec () const
 
void sec (time_t sec)
 
void msec (long msec)
 
void usec (long usec)
 
void nsec (long nsec)
 
void clear ()
 Clear the time. More...
 
void setTimer ()
 Use this to set time for the purposes of time measurement (use a monotonic clock if it is available. More...
 
void setWallclock ()
 Use this to set the time to the actual current time. More...
 
void set (time_t _sec, long _nsec)
 Set the current time. More...
 
void setTick (Tick ticks)
 Set the current time from a value measured in Ticks. More...
 
Tick getTick () const
 Get the current time from a value measured in Ticks. More...
 
const Timeoperator= (const Time &other)
 
const Timeoperator= (double new_time)
 
const Timeoperator= (const timeval &tv)
 
const Timeoperator= (const timespec &ts)
 
 operator double () const
 Get the time in floating point seconds. More...
 
 operator timespec () const
 operators for time conversion More...
 
 operator timeval () const
 
const Timeoperator+= (const Time &other)
 
const Timeoperator-= (const Time &other)
 
std::string date (const std::string &format="") const
 
std::string time () const
 
void serialize (const std::string &base, CheckpointOut &cp) const
 
void unserialize (const std::string &base, CheckpointIn &cp)
 

Static Public Attributes

static const long NSEC_PER_SEC = 1000 * 1000 * 1000
 
static const long NSEC_PER_MSEC = 1000 * 1000
 
static const long NSEC_PER_USEC = 1000
 

Protected Member Functions

void _set (bool monotonic)
 Internal time set function. More...
 

Protected Attributes

timespec _time
 

Detailed Description

Definition at line 45 of file time.hh.

Constructor & Destructor Documentation

◆ Time() [1/6]

Time::Time ( )
inlineexplicit

Definition at line 61 of file time.hh.

References clear().

◆ Time() [2/6]

Time::Time ( double  sec)
inlineexplicit

Definition at line 62 of file time.hh.

References operator=(), and sec().

◆ Time() [3/6]

Time::Time ( const Time val)
inline

Definition at line 63 of file time.hh.

◆ Time() [4/6]

Time::Time ( uint64_t  sec,
uint64_t  nsec 
)
inline

Definition at line 64 of file time.hh.

References nsec(), sec(), and set().

◆ Time() [5/6]

Time::Time ( const timeval &  tv)
inline

Definition at line 65 of file time.hh.

References operator=().

◆ Time() [6/6]

Time::Time ( const timespec &  ts)
inline

Definition at line 66 of file time.hh.

References operator=(), and ArmISA::ts.

Member Function Documentation

◆ _set()

void Time::_set ( bool  monotonic)
protected

Internal time set function.

Definition at line 42 of file time.cc.

References _time, and operator=().

Referenced by setTimer(), and setWallclock().

◆ clear()

void Time::clear ( )
inline

Clear the time.

Definition at line 84 of file time.hh.

References _time.

Referenced by Time().

◆ date()

std::string Time::date ( const std::string &  format = "") const

Definition at line 70 of file time.cc.

References ArmISA::format, and sec().

Referenced by operator<<().

◆ getTick()

Tick Time::getTick ( ) const

Get the current time from a value measured in Ticks.

Returns
Time value measured in Ticks.

Definition at line 63 of file time.cc.

References SimClock::Frequency, SimClock::Float::ns, nsec(), and sec().

Referenced by Root::timeSyncPeriod().

◆ msec() [1/2]

long Time::msec ( ) const
inline

Definition at line 72 of file time.hh.

References _time, and NSEC_PER_MSEC.

Referenced by msec().

◆ msec() [2/2]

void Time::msec ( long  msec)
inline

Definition at line 77 of file time.hh.

References _time, msec(), and NSEC_PER_MSEC.

◆ nsec() [1/2]

long Time::nsec ( ) const
inline

Definition at line 74 of file time.hh.

References _time.

Referenced by getTick(), operator double(), operator+=(), operator-=(), operator=(), serialize(), set(), Time(), and unserialize().

◆ nsec() [2/2]

void Time::nsec ( long  nsec)
inline

Definition at line 79 of file time.hh.

References _time, and nsec().

Referenced by nsec().

◆ operator double()

Time::operator double ( ) const
inline

Get the time in floating point seconds.

Definition at line 150 of file time.hh.

References ArmISA::e, nsec(), and sec().

◆ operator timespec()

Time::operator timespec ( ) const
inline

operators for time conversion

Definition at line 158 of file time.hh.

References _time.

◆ operator timeval()

Time::operator timeval ( ) const
inline

Definition at line 159 of file time.hh.

References sec(), and usec().

◆ operator+=()

const Time& Time::operator+= ( const Time other)
inline

Definition at line 168 of file time.hh.

References _time, nsec(), NSEC_PER_SEC, and sec().

◆ operator-=()

const Time& Time::operator-= ( const Time other)
inline

Definition at line 182 of file time.hh.

References _time, nsec(), NSEC_PER_SEC, and sec().

◆ operator=() [1/4]

const Time& Time::operator= ( const Time other)
inline

Definition at line 115 of file time.hh.

References nsec(), and sec().

Referenced by _set(), and Time().

◆ operator=() [2/4]

const Time& Time::operator= ( const timespec &  ts)
inline

Definition at line 140 of file time.hh.

References nsec(), sec(), and ArmISA::ts.

◆ operator=() [3/4]

const Time& Time::operator= ( const timeval &  tv)
inline

Definition at line 132 of file time.hh.

References nsec(), and sec().

◆ operator=() [4/4]

const Time& Time::operator= ( double  new_time)
inline

Definition at line 123 of file time.hh.

References nsec(), and sec().

◆ sec() [1/2]

time_t Time::sec ( ) const
inline

Accessors for getting and setting the current clock.

Definition at line 71 of file time.hh.

References _time.

Referenced by date(), getTick(), operator double(), operator timeval(), operator+=(), operator-=(), operator=(), serialize(), set(), Time(), and unserialize().

◆ sec() [2/2]

void Time::sec ( time_t  sec)
inline

Definition at line 76 of file time.hh.

References _time, and sec().

Referenced by sec().

◆ serialize()

void Time::serialize ( const std::string &  base,
CheckpointOut cp 
) const

Definition at line 121 of file time.cc.

References X86ISA::base, nsec(), paramOut(), and sec().

◆ set()

void Time::set ( time_t  _sec,
long  _nsec 
)
inline

Set the current time.

Definition at line 100 of file time.hh.

References nsec(), and sec().

Referenced by setTick(), and Time().

◆ setTick()

void Time::setTick ( Tick  ticks)

Set the current time from a value measured in Ticks.

Parameters
ticksNumber of ticks to convert into a time.

Definition at line 54 of file time.cc.

References SimClock::Frequency, SimClock::Float::GHz, and set().

◆ setTimer()

void Time::setTimer ( )
inline

Use this to set time for the purposes of time measurement (use a monotonic clock if it is available.

Definition at line 90 of file time.hh.

References _set().

Referenced by Root::RootStats::RootStats(), and Root::timeSync().

◆ setWallclock()

void Time::setWallclock ( )
inline

Use this to set the time to the actual current time.

Definition at line 95 of file time.hh.

References _set().

◆ time()

std::string Time::time ( ) const

Definition at line 91 of file time.cc.

◆ unserialize()

void Time::unserialize ( const std::string &  base,
CheckpointIn cp 
)

Definition at line 128 of file time.cc.

References X86ISA::base, nsec(), paramIn(), and sec().

◆ usec() [1/2]

long Time::usec ( ) const
inline

Definition at line 73 of file time.hh.

References _time, and NSEC_PER_USEC.

Referenced by operator timeval(), and usec().

◆ usec() [2/2]

void Time::usec ( long  usec)
inline

Definition at line 78 of file time.hh.

References _time, NSEC_PER_USEC, and usec().

Member Data Documentation

◆ _time

timespec Time::_time
protected

Definition at line 48 of file time.hh.

Referenced by _set(), clear(), msec(), nsec(), operator timespec(), operator+=(), operator-=(), sec(), and usec().

◆ NSEC_PER_MSEC

const long Time::NSEC_PER_MSEC = 1000 * 1000
static

Definition at line 57 of file time.hh.

Referenced by msec().

◆ NSEC_PER_SEC

const long Time::NSEC_PER_SEC = 1000 * 1000 * 1000
static

Definition at line 56 of file time.hh.

Referenced by operator+=(), and operator-=().

◆ NSEC_PER_USEC

const long Time::NSEC_PER_USEC = 1000
static

Definition at line 58 of file time.hh.

Referenced by usec().


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

Generated on Tue Jun 22 2021 15:28:45 for gem5 by doxygen 1.8.17