5 #ifndef V8_BASE_PLATFORM_TIME_H_
6 #define V8_BASE_PLATFORM_TIME_H_
33 class TimeDelta
FINAL {
44 return TimeDelta(microseconds);
66 struct mach_timespec ToMachTimespec() const;
70 struct timespec ToTimespec() const;
73 delta_ = other.delta_;
79 return TimeDelta(delta_ + other.delta_);
82 return TimeDelta(delta_ - other.delta_);
86 delta_ += other.delta_;
90 delta_ -= other.delta_;
94 return TimeDelta(-delta_);
97 double TimesOf(
const TimeDelta& other)
const {
98 return static_cast<double>(delta_) /
static_cast<double>(other.delta_);
101 return TimesOf(other) * 100.0;
107 return TimeDelta(delta_ * a);
110 return TimeDelta(delta_ / a);
121 return delta_ / other.delta_;
126 return delta_ == other.delta_;
129 return delta_ != other.delta_;
132 return delta_ < other.delta_;
135 return delta_ <= other.delta_;
138 return delta_ > other.delta_;
141 return delta_ >= other.delta_;
163 static const int64_t kMillisecondsPerSecond = 1000;
164 static const int64_t kMicrosecondsPerMillisecond = 1000;
165 static const int64_t kMicrosecondsPerSecond = kMicrosecondsPerMillisecond *
166 kMillisecondsPerSecond;
167 static const int64_t kMicrosecondsPerMinute = kMicrosecondsPerSecond * 60;
168 static const int64_t kMicrosecondsPerHour = kMicrosecondsPerMinute * 60;
169 static const int64_t kMicrosecondsPerDay = kMicrosecondsPerHour * 24;
170 static const int64_t kMicrosecondsPerWeek = kMicrosecondsPerDay * 7;
171 static const int64_t kNanosecondsPerMicrosecond = 1000;
172 static const int64_t kNanosecondsPerSecond = kNanosecondsPerMicrosecond *
173 kMicrosecondsPerSecond;
182 bool IsMax()
const {
return us_ == std::numeric_limits<int64_t>::max(); }
200 static Time
Max() {
return Time(std::numeric_limits<int64_t>::max()); }
213 struct timespec ToTimespec() const;
217 struct timeval ToTimeval() const;
221 struct _FILETIME ToFiletime() const;
235 return TimeDelta::FromMicroseconds(us_ - other.us_);
240 us_ += delta.InMicroseconds();
244 us_ -= delta.InMicroseconds();
250 return Time(us_ + delta.InMicroseconds());
253 return Time(us_ - delta.InMicroseconds());
258 return us_ == other.us_;
261 return us_ != other.us_;
264 return us_ < other.us_;
267 return us_ <= other.us_;
270 return us_ > other.us_;
273 return us_ >= other.us_;
277 explicit Time(int64_t us) : us_(us) {}
283 inline Time
operator+(
const TimeDelta& delta,
const Time& time) {
298 class TimeTicks
FINAL {
326 bool IsNull()
const {
return ticks_ == 0; }
331 return TimeTicks(value);
338 ticks_ = other.ticks_;
344 return TimeDelta::FromMicroseconds(ticks_ - other.ticks_);
349 ticks_ += delta.InMicroseconds();
353 ticks_ -= delta.InMicroseconds();
359 return TimeTicks(ticks_ + delta.InMicroseconds());
362 return TimeTicks(ticks_ - delta.InMicroseconds());
367 return ticks_ == other.ticks_;
370 return ticks_ != other.ticks_;
373 return ticks_ < other.ticks_;
376 return ticks_ <= other.ticks_;
379 return ticks_ > other.ticks_;
382 return ticks_ >= other.ticks_;
394 inline TimeTicks
operator+(
const TimeDelta& delta,
const TimeTicks& ticks) {
395 return ticks + delta;
static TimeTicks KernelTimestampNow()
Time & operator=(const Time &other)
TimeTicks operator+(const TimeDelta &delta) const
int64_t InMilliseconds() const
TimeDelta & operator*=(int64_t a)
Time operator-(const TimeDelta &delta) const
TimeDelta operator+(const TimeDelta &other) const
TimeDelta operator-(const TimeTicks other) const
TimeDelta & operator-=(const TimeDelta &other)
bool operator>=(const TimeTicks &other) const
TimeTicks & operator-=(const TimeDelta &delta)
bool operator<(const TimeTicks &other) const
bool operator>=(const TimeDelta &other) const
TimeTicks operator-(const TimeDelta &delta) const
static TimeDelta FromNanoseconds(int64_t nanoseconds)
static TimeDelta FromMilliseconds(int64_t milliseconds)
int64_t InNanoseconds() const
static bool KernelTimestampAvailable()
int64_t InSeconds() const
TimeDelta & operator=(const TimeDelta &other)
bool operator>(const Time &other) const
TimeDelta operator-() const
TimeDelta operator*(int64_t a) const
static TimeTicks FromInternalValue(int64_t value)
bool operator>(const TimeDelta &other) const
Time & operator+=(const TimeDelta &delta)
bool operator<(const TimeDelta &other) const
bool operator<(const Time &other) const
Time operator+(const TimeDelta &delta) const
TimeDelta operator/(int64_t a) const
TimeDelta operator-(const Time &other) const
TimeDelta & operator/=(int64_t a)
TimeTicks & operator=(const TimeTicks other)
double TimesOf(const TimeDelta &other) const
static Time NowFromSystemTime()
double InSecondsF() const
int64_t InMicroseconds() const
bool operator==(const TimeTicks &other) const
bool operator<=(const TimeDelta &other) const
static Time FromTimespec(struct timespec ts)
bool operator<=(const TimeTicks &other) const
bool operator<=(const Time &other) const
static TimeTicks HighResolutionNow()
static TimeDelta FromTimespec(struct timespec ts)
Time & operator-=(const TimeDelta &delta)
int64_t ToInternalValue() const
static Time FromFiletime(struct _FILETIME ft)
TimeDelta & operator+=(const TimeDelta &other)
static TimeDelta FromSeconds(int64_t seconds)
TimeTicks & operator+=(const TimeDelta &delta)
int64_t InMillisecondsRoundedUp() const
bool operator!=(const TimeTicks &other) const
static TimeDelta FromMicroseconds(int64_t microseconds)
bool operator>(const TimeTicks &other) const
static TimeDelta FromDays(int days)
TimeDelta operator-(const TimeDelta &other) const
static bool IsHighResolutionClockWorking()
int64_t operator/(const TimeDelta &other) const
static TimeDelta FromHours(int hours)
bool operator!=(const Time &other) const
bool operator==(const TimeDelta &other) const
static Time FromTimeval(struct timeval tv)
bool operator!=(const TimeDelta &other) const
static TimeDelta FromMachTimespec(struct mach_timespec ts)
double PercentOf(const TimeDelta &other) const
bool operator>=(const Time &other) const
bool operator==(const Time &other) const
static TimeDelta FromMinutes(int minutes)
static Time FromJsTime(double ms_since_epoch)
static Time FromInternalValue(int64_t value)
double InMillisecondsF() const
Time operator+(const TimeDelta &delta, const Time &time)
Debugger support for the V8 JavaScript engine.