зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1692213 - Use raw timestamp internally for PerformanceEventTiming r=smaug
Currently, whenever the algorithm requires to get timestamps, it'll try to get the corresponding precision reduced timestamps. However, this creates some memory overhead because the calculation of precision reduced timestamps. So instead of always generating the precision reduced timestamps, we use the raw timestamps internally to avoid generating precision reduced timestamps unnecessarily. Differential Revision: https://phabricator.services.mozilla.com/D105829
This commit is contained in:
Родитель
1df7755bd6
Коммит
5c67d2bffc
|
@ -138,7 +138,7 @@ bool PerformanceEventTiming::ShouldAddEntryToBuffer(double aDuration) const {
|
|||
return true;
|
||||
}
|
||||
MOZ_ASSERT(GetEntryType() == nsGkAtoms::event);
|
||||
return Duration() >= aDuration;
|
||||
return RawDuration() >= aDuration;
|
||||
}
|
||||
|
||||
bool PerformanceEventTiming::ShouldAddEntryToObserverBuffer(
|
||||
|
|
|
@ -67,6 +67,11 @@ class PerformanceEventTiming final
|
|||
mDuration = aDuration;
|
||||
}
|
||||
|
||||
// nsRFPService::ReduceTimePrecisionAsMSecs might causes
|
||||
// some memory overhead, using the raw timestamp internally
|
||||
// to avoid calling in unnecessarily.
|
||||
DOMHighResTimeStamp RawDuration() const { return mDuration; }
|
||||
|
||||
DOMHighResTimeStamp Duration() const override {
|
||||
if (mCachedDuration.isNothing()) {
|
||||
mCachedDuration.emplace(nsRFPService::ReduceTimePrecisionAsMSecs(
|
||||
|
@ -77,6 +82,10 @@ class PerformanceEventTiming final
|
|||
return mCachedDuration.value();
|
||||
}
|
||||
|
||||
// Similar as RawDuration; Used to avoid calling
|
||||
// nsRFPService::ReduceTimePrecisionAsMSecs unnecessarily.
|
||||
DOMHighResTimeStamp RawStartTime() const { return mStartTime; }
|
||||
|
||||
DOMHighResTimeStamp StartTime() const override {
|
||||
if (mCachedStartTime.isNothing()) {
|
||||
mCachedStartTime.emplace(nsRFPService::ReduceTimePrecisionAsMSecs(
|
||||
|
|
|
@ -245,10 +245,10 @@ void PerformanceMainThread::DispatchPendingEventTimingEntries() {
|
|||
RefPtr<PerformanceEventTiming> entry =
|
||||
mPendingEventTimingEntries.popFirst();
|
||||
|
||||
entry->SetDuration(renderingTime - entry->StartTime());
|
||||
entry->SetDuration(renderingTime - entry->RawStartTime());
|
||||
IncEventCount(entry->GetName());
|
||||
|
||||
if (entry->Duration() >= kDefaultEventTimingMinDuration) {
|
||||
if (entry->RawDuration() >= kDefaultEventTimingMinDuration) {
|
||||
QueueEntry(entry);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче