forked from mirrors/gecko-dev
Bug 1831581 - Expose raw innards of TimeStamp. r=glandium
It's often useful to be able to get the OS specifc raw values out of a TimeStamp when interacting with other OS specific things. For example, this lets us produce timestamps that are compatible with perf or ETW. This adds explicitly named per OS functions to do so. These should be sufficiently unpleasant to use and clear in their semantics that it should avoid any misuse. Differential Revision: https://phabricator.services.mozilla.com/D177267
This commit is contained in:
parent
edb0a32d82
commit
a9fa81b9b0
1 changed files with 20 additions and 0 deletions
|
|
@ -25,6 +25,8 @@ struct ParamTraits;
|
|||
// defines TimeStampValue as a complex value keeping both
|
||||
// GetTickCount and QueryPerformanceCounter values
|
||||
# include "TimeStamp_windows.h"
|
||||
|
||||
# include "mozilla/Maybe.h" // For TimeStamp::RawQueryPerformanceCounterValue
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
|
|
@ -450,6 +452,24 @@ class TimeStamp {
|
|||
*/
|
||||
static MFBT_API void RecordProcessRestart();
|
||||
|
||||
#ifdef XP_LINUX
|
||||
uint64_t RawClockMonotonicNanosecondsSinceBoot() {
|
||||
return static_cast<uint64_t>(mValue);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
uint64_t RawMachAbsoluteTimeValue() { return static_cast<uint64_t>(mValue); }
|
||||
#endif
|
||||
|
||||
#ifdef XP_WIN
|
||||
Maybe<uint64_t> RawQueryPerformanceCounterValue() {
|
||||
// mQPC is stored in `mt` i.e. QueryPerformanceCounter * 1000
|
||||
// so divide out the 1000
|
||||
return mValue.mHasQPC ? Some(mValue.mQPC / 1000ULL) : Nothing();
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Compute the difference between two timestamps. Both must be non-null.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue