Skip to content
Snippets Groups Projects
Commit a9fa81b9 authored by Markus Stange's avatar Markus Stange
Browse files

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
parent edb0a32d
No related branches found
No related tags found
No related merge requests found
......@@ -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.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment