mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
ae192ec3a5
Summary of the changes/reasons: - LayoutTelemetryTools.h directly uses several types whose headers it needs to include. (These includes were present in its .cpp file; I'm migrating them from there to the .h file, and I'm adding a new include for "Saturate.h" to provide the SaturateUint8 type.) - LayoutTelemetryTools.cpp needs an include for MainThreadUtils.h, to provide NS_IsMainThread(). - StaticPresData.cpp needs an include for ServoUtils.h, to provide AssertIsMainThreadOrServoFontMetricsLocked(). - ZoomConstraintsClient.h needs a forward-decl for mozilla::dom::Document since it uses a pointer of that type in a function-decl. - ScrollSnap.h needs forward-decls of nsPoint/nsRect for some references to those types in a method signature. - nsGridContainerFrame.cpp needs an include for nsBoxLayoutState.h since it uses that type (it instantiates a nsBoxLayoutState instance). - nsPlaceholderFrame.cpp needs a "using" decl for the mozilla::dom namespace in order to use the un-namespace-prefixed "Element" type. Differential Revision: https://phabricator.services.mozilla.com/D61603 --HG-- extra : moz-landing-system : lando
91 lines
2.6 KiB
C++
91 lines
2.6 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
/* Tools for collecting and reporting layout and style telemetry */
|
|
|
|
#ifndef mozilla_LayoutTelemetryTools_h
|
|
#define mozilla_LayoutTelemetryTools_h
|
|
|
|
#include "mozilla/EnumeratedArray.h"
|
|
#include "mozilla/EnumeratedRange.h"
|
|
#include "mozilla/FlushType.h"
|
|
#include "mozilla/Saturate.h"
|
|
#include "mozilla/TimeStamp.h"
|
|
|
|
#define LAYOUT_TELEMETRY_RECORD(subsystem) \
|
|
layout_telemetry::AutoRecord a(layout_telemetry::LayoutSubsystem::subsystem)
|
|
|
|
#define LAYOUT_TELEMETRY_RECORD_BASE(subsystem) \
|
|
layout_telemetry::AutoRecord a(&mLayoutTelemetry, \
|
|
layout_telemetry::LayoutSubsystem::subsystem)
|
|
|
|
namespace mozilla {
|
|
namespace layout_telemetry {
|
|
|
|
enum class FlushKind : uint8_t { Style, Layout, Count };
|
|
|
|
enum class LayoutSubsystem : uint8_t {
|
|
Restyle,
|
|
Reflow,
|
|
ReflowFlex,
|
|
ReflowGrid,
|
|
ReflowTable,
|
|
ReflowText,
|
|
Count
|
|
};
|
|
|
|
using LayoutSubsystemDurations =
|
|
EnumeratedArray<LayoutSubsystem, LayoutSubsystem::Count, double>;
|
|
using LayoutFlushCount =
|
|
EnumeratedArray<FlushKind, FlushKind::Count, SaturateUint8>;
|
|
|
|
struct Data {
|
|
Data();
|
|
|
|
void IncReqsPerFlush(FlushType aFlushType);
|
|
void IncFlushesPerTick(FlushType aFlushType);
|
|
|
|
void PingTelemetry();
|
|
|
|
// Send the current number of flush requests for aFlushType to telemetry and
|
|
// reset the count.
|
|
void PingReqsPerFlushTelemetry(FlushType aFlushType);
|
|
|
|
// Send the current non-zero number of style and layout flushes to telemetry
|
|
// and reset the count.
|
|
void PingFlushPerTickTelemetry(FlushType aFlushType);
|
|
|
|
// Send the current non-zero time spent under style and layout processing this
|
|
// tick to telemetry and reset the total.
|
|
void PingTotalMsPerTickTelemetry(FlushType aFlushType);
|
|
|
|
// Send the current per-tick telemetry for `aFlushType`.
|
|
void PingPerTickTelemetry(FlushType aFlushType);
|
|
|
|
LayoutFlushCount mReqsPerFlush;
|
|
LayoutFlushCount mFlushesPerTick;
|
|
LayoutSubsystemDurations mLayoutSubsystemDurationMs;
|
|
};
|
|
|
|
class AutoRecord {
|
|
public:
|
|
explicit AutoRecord(LayoutSubsystem aSubsystem);
|
|
AutoRecord(Data* aLayoutTelemetry, LayoutSubsystem aSubsystem);
|
|
~AutoRecord();
|
|
|
|
private:
|
|
AutoRecord* mParentRecord;
|
|
Data* mLayoutTelemetry;
|
|
LayoutSubsystem mSubsystem;
|
|
TimeStamp mStartTime;
|
|
double mDurationMs;
|
|
};
|
|
|
|
} // namespace layout_telemetry
|
|
} // namespace mozilla
|
|
|
|
#endif // !mozilla_LayoutTelemetryTools_h
|