mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-11 01:57:00 +00:00
Bug 827287 - make it possible to use TimeStamp without performance concerns (TimeStamp::NowLoRes), r=ehsan, sr=roc
This commit is contained in:
parent
a3e10fe7fa
commit
3e6e5d6690
@ -211,8 +211,17 @@ public:
|
||||
* Return a timestamp reflecting the current elapsed system time. This
|
||||
* is monotonically increasing (i.e., does not decrease) over the
|
||||
* lifetime of this process' XPCOM session.
|
||||
*
|
||||
* Now() is trying to ensure the best possible precision on each platform,
|
||||
* at least one millisecond.
|
||||
*
|
||||
* NowLoRes() has been introduced to workaround performance problems of
|
||||
* QueryPerformanceCounter on the Windows platform. NowLoRes() is giving
|
||||
* lower precision, usually 15.6 ms, but with very good performance benefit.
|
||||
* Use it for measurements of longer times, like >200ms timeouts.
|
||||
*/
|
||||
static TimeStamp Now();
|
||||
static TimeStamp Now() { return Now(true); }
|
||||
static TimeStamp NowLoRes() { return Now(false); }
|
||||
/**
|
||||
* Compute the difference between two timestamps. Both must be non-null.
|
||||
*/
|
||||
@ -298,6 +307,8 @@ private:
|
||||
|
||||
TimeStamp(TimeStampValue aValue) : mValue(aValue) {}
|
||||
|
||||
static TimeStamp Now(bool aHighResolution);
|
||||
|
||||
/**
|
||||
* When built with PRIntervalTime, a value of 0 means this instance
|
||||
* is "null". Otherwise, the low 32 bits represent a PRIntervalTime,
|
||||
|
@ -156,7 +156,7 @@ TimeStamp::Shutdown()
|
||||
}
|
||||
|
||||
TimeStamp
|
||||
TimeStamp::Now()
|
||||
TimeStamp::Now(bool aHighResolution)
|
||||
{
|
||||
return TimeStamp(ClockTime());
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ TimeStamp::Shutdown()
|
||||
}
|
||||
|
||||
TimeStamp
|
||||
TimeStamp::Now()
|
||||
TimeStamp::Now(bool aHighResolution)
|
||||
{
|
||||
return TimeStamp(ClockTimeNs());
|
||||
}
|
||||
|
@ -537,10 +537,10 @@ TimeStamp::Shutdown()
|
||||
}
|
||||
|
||||
TimeStamp
|
||||
TimeStamp::Now()
|
||||
TimeStamp::Now(bool aHighResolution)
|
||||
{
|
||||
// sUseQPC is volatile
|
||||
bool useQPC = sUseQPC;
|
||||
bool useQPC = (aHighResolution && sUseQPC);
|
||||
|
||||
// Both values are in [mt] units.
|
||||
ULONGLONG QPC = useQPC ? PerformanceCounter() : uint64_t(0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user