29#ifndef __BASE_TIME_HH__
30#define __BASE_TIME_HH__
56 void _set(
bool monotonic);
103 void set(time_t _sec,
long _nsec) {
sec(_sec);
nsec(_nsec); }
128 double seconds = floor(new_time);
129 sec((time_t)seconds);
130 nsec((
long)((seconds - new_time) * 1e9));
138 nsec(tv.tv_usec * 1000);
153 operator double()
const
155 return (
double)
sec() + ((double)
nsec()) * 1
e-9;
161 operator timespec()
const {
return _time; }
162 operator timeval()
const
189 if (
_time.tv_nsec < 0) {
197 std::string
date(
const std::string &
format =
"")
const;
198 std::string
time()
const;
204void sleep(
const Time &time);
209 return l.sec() ==
r.sec() &&
l.nsec() ==
r.nsec();
215 return l.sec() !=
r.sec() ||
l.nsec() !=
r.nsec();
221 return (
l.sec() <
r.sec()) ||
222 (
l.sec() ==
r.sec() &&
l.nsec() <
r.nsec());
228 return (
l.sec() <
r.sec()) ||
229 (
l.sec() ==
r.sec() &&
l.nsec() <=
r.nsec());
235 return (
l.sec() >
r.sec()) ||
236 (
l.sec() ==
r.sec() &&
l.nsec() >
r.nsec());
242 return (
l.sec() >
r.sec()) ||
243 (
l.sec() ==
r.sec() &&
l.nsec() >=
r.nsec());
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
void set(time_t _sec, long _nsec)
Set the current time.
static const long NSEC_PER_MSEC
const Time & operator=(double new_time)
Tick getTick() const
Get the current time from a value measured in Ticks.
void serialize(const std::string &base, CheckpointOut &cp) const
time_t sec() const
Accessors for getting and setting the current clock.
const Time & operator=(const timespec &ts)
void setTimer()
Use this to set time for the purposes of time measurement (use a monotonic clock if it is available.
std::string date(const std::string &format="") const
static const long NSEC_PER_SEC
const Time & operator+=(const Time &other)
Time(uint64_t sec, uint64_t nsec)
void unserialize(const std::string &base, CheckpointIn &cp)
void clear()
Clear the time.
const Time & operator=(const timeval &tv)
void setWallclock()
Use this to set the time to the actual current time.
const Time & operator=(const Time &other)
void _set(bool monotonic)
Internal time set function.
static const long NSEC_PER_USEC
void setTick(Tick ticks)
Set the current time from a value measured in Ticks.
const Time & operator-=(const Time &other)
Bitfield< 31, 29 > format
Temp operator+(Temp l, Temp r)
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
bool operator>(const Time &l, const Time &r)
static bool operator==(const PCStateBase &a, const PCStateBase &b)
std::ostream CheckpointOut
time_t mkutctime(struct tm *time)
uint64_t Tick
Tick count type.
void sleep(const Time &time)
static std::ostream & operator<<(std::ostream &os, const DummyMatRegContainer &d)
static bool operator!=(const PCStateBase &a, const PCStateBase &b)
bool operator>=(const Time &l, const Time &r)
bool operator<(const Time &l, const Time &r)
bool operator<=(const Time &l, const Time &r)
static AddrRangeList operator-(const AddrRange &range, const AddrRangeList &to_exclude)