gem5  v21.1.0.2
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
gem5::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 48 of file time.hh.

Constructor & Destructor Documentation

◆ Time() [1/6]

gem5::Time::Time ( )
inlineexplicit

Definition at line 64 of file time.hh.

References clear().

◆ Time() [2/6]

gem5::Time::Time ( double  sec)
inlineexplicit

Definition at line 65 of file time.hh.

References operator=(), and sec().

◆ Time() [3/6]

gem5::Time::Time ( const Time val)
inline

Definition at line 66 of file time.hh.

◆ Time() [4/6]

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

Definition at line 67 of file time.hh.

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

◆ Time() [5/6]

gem5::Time::Time ( const timeval &  tv)
inline

Definition at line 68 of file time.hh.

References operator=().

◆ Time() [6/6]

gem5::Time::Time ( const timespec &  ts)
inline

Definition at line 69 of file time.hh.

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

Member Function Documentation

◆ _set()

void gem5::Time::_set ( bool  monotonic)
protected

Internal time set function.

Definition at line 45 of file time.cc.

References _time, and operator=().

Referenced by setTimer(), and setWallclock().

◆ clear()

void gem5::Time::clear ( )
inline

Clear the time.

Definition at line 87 of file time.hh.

References _time.

Referenced by Time().

◆ date()

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

Definition at line 73 of file time.cc.

References gem5::ArmISA::format, sec(), and gem5::PowerISA::tm.

Referenced by gem5::operator<<().

◆ getTick()

Tick gem5::Time::getTick ( ) const

Get the current time from a value measured in Ticks.

Returns
Time value measured in Ticks.

Definition at line 66 of file time.cc.

References gem5::sim_clock::Frequency, gem5::sim_clock::as_float::ns, nsec(), and sec().

Referenced by gem5::Root::timeSyncPeriod().

◆ msec() [1/2]

long gem5::Time::msec ( ) const
inline

Definition at line 75 of file time.hh.

References _time, and NSEC_PER_MSEC.

Referenced by msec().

◆ msec() [2/2]

void gem5::Time::msec ( long  msec)
inline

Definition at line 80 of file time.hh.

References _time, msec(), and NSEC_PER_MSEC.

◆ nsec() [1/2]

long gem5::Time::nsec ( ) const
inline

Definition at line 77 of file time.hh.

References _time.

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

◆ nsec() [2/2]

void gem5::Time::nsec ( long  nsec)
inline

Definition at line 82 of file time.hh.

References _time, and nsec().

Referenced by nsec().

◆ operator double()

gem5::Time::operator double ( ) const
inline

Get the time in floating point seconds.

Definition at line 153 of file time.hh.

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

◆ operator timespec()

gem5::Time::operator timespec ( ) const
inline

operators for time conversion

Definition at line 161 of file time.hh.

References _time.

◆ operator timeval()

gem5::Time::operator timeval ( ) const
inline

Definition at line 162 of file time.hh.

References sec(), and usec().

◆ operator+=()

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

Definition at line 171 of file time.hh.

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

◆ operator-=()

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

Definition at line 185 of file time.hh.

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

◆ operator=() [1/4]

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

Definition at line 118 of file time.hh.

References nsec(), and sec().

Referenced by _set(), and Time().

◆ operator=() [2/4]

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

Definition at line 143 of file time.hh.

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

◆ operator=() [3/4]

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

Definition at line 135 of file time.hh.

References nsec(), and sec().

◆ operator=() [4/4]

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

Definition at line 126 of file time.hh.

References nsec(), and sec().

◆ sec() [1/2]

time_t gem5::Time::sec ( ) const
inline

Accessors for getting and setting the current clock.

Definition at line 74 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 gem5::Time::sec ( time_t  sec)
inline

Definition at line 79 of file time.hh.

References _time, and sec().

Referenced by sec().

◆ serialize()

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

Definition at line 124 of file time.cc.

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

◆ set()

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

Set the current time.

Definition at line 103 of file time.hh.

References nsec(), and sec().

Referenced by setTick(), and Time().

◆ setTick()

void gem5::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 57 of file time.cc.

References gem5::sim_clock::Frequency, gem5::sim_clock::as_float::GHz, and set().

◆ setTimer()

void gem5::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 93 of file time.hh.

References _set().

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

◆ setWallclock()

void gem5::Time::setWallclock ( )
inline

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

Definition at line 98 of file time.hh.

References _set().

◆ time()

std::string gem5::Time::time ( ) const

Definition at line 94 of file time.cc.

◆ unserialize()

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

Definition at line 131 of file time.cc.

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

◆ usec() [1/2]

long gem5::Time::usec ( ) const
inline

Definition at line 76 of file time.hh.

References _time, and NSEC_PER_USEC.

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

◆ usec() [2/2]

void gem5::Time::usec ( long  usec)
inline

Definition at line 81 of file time.hh.

References _time, NSEC_PER_USEC, and usec().

Member Data Documentation

◆ _time

timespec gem5::Time::_time
protected

Definition at line 51 of file time.hh.

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

◆ NSEC_PER_MSEC

const long gem5::Time::NSEC_PER_MSEC = 1000 * 1000
static

Definition at line 60 of file time.hh.

Referenced by msec().

◆ NSEC_PER_SEC

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

Definition at line 59 of file time.hh.

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

◆ NSEC_PER_USEC

const long gem5::Time::NSEC_PER_USEC = 1000
static

Definition at line 61 of file time.hh.

Referenced by usec().


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

Generated on Tue Sep 21 2021 12:28:15 for gem5 by doxygen 1.8.17