From 89add2582d3047bf0edf4e2a1d8801e9e3361d33 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Mon, 4 Nov 2019 18:19:05 -0800 Subject: [PATCH] Fabric: Collecting mounting time inside `MountingTelemetry` Summary: Now we also collect mounting time inside MountingTelemetry. We will use it soon. Changelog: [Internal] Fabric-specific internal change. Reviewed By: mdvacca Differential Revision: D18285826 fbshipit-source-id: 512fc62c210a111614b0defb0d76cbd6228fe89f --- React/Fabric/Mounting/RCTMountingManager.mm | 9 ++++--- .../fabric/mounting/MountingTelemetry.cpp | 24 +++++++++++++++++++ .../fabric/mounting/MountingTelemetry.h | 6 +++++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/React/Fabric/Mounting/RCTMountingManager.mm b/React/Fabric/Mounting/RCTMountingManager.mm index f5e8317846b..709b2e302cb 100644 --- a/React/Fabric/Mounting/RCTMountingManager.mm +++ b/React/Fabric/Mounting/RCTMountingManager.mm @@ -269,12 +269,15 @@ static void RNPerformMountInstructions( } RCTAssertMainQueue(); - auto metadata = MountingTransactionMetadata{surfaceId, transaction->getNumber(), transaction->getTelemetry()}; + auto telemetry = transaction->getTelemetry(); + auto number = transaction->getNumber(); [self.delegate mountingManager:self willMountComponentsWithRootTag:surfaceId]; - _observerCoordinator.notifyObserversMountingTransactionWillMount(metadata); + _observerCoordinator.notifyObserversMountingTransactionWillMount({surfaceId, number, telemetry}); + telemetry.willMount(); RNPerformMountInstructions(mutations, self.componentViewRegistry, _observerCoordinator, surfaceId); - _observerCoordinator.notifyObserversMountingTransactionDidMount(metadata); + telemetry.didMount(); + _observerCoordinator.notifyObserversMountingTransactionDidMount({surfaceId, number, telemetry}); [self.delegate mountingManager:self didMountComponentsWithRootTag:surfaceId]; } diff --git a/ReactCommon/fabric/mounting/MountingTelemetry.cpp b/ReactCommon/fabric/mounting/MountingTelemetry.cpp index f96e4b1d292..a3f2f8bc2b7 100644 --- a/ReactCommon/fabric/mounting/MountingTelemetry.cpp +++ b/ReactCommon/fabric/mounting/MountingTelemetry.cpp @@ -51,6 +51,18 @@ void MountingTelemetry::didLayout() { layoutEndTime_ = monotonicTimeInMilliseconds(); } +void MountingTelemetry::willMount() { + assert(mountStartTime_ == kUndefinedTime); + assert(mountEndTime_ == kUndefinedTime); + mountStartTime_ = monotonicTimeInMilliseconds(); +} + +void MountingTelemetry::didMount() { + assert(mountStartTime_ != kUndefinedTime); + assert(mountEndTime_ == kUndefinedTime); + mountEndTime_ = monotonicTimeInMilliseconds(); +} + int64_t MountingTelemetry::getDiffStartTime() const { assert(diffStartTime_ != kUndefinedTime); assert(diffEndTime_ != kUndefinedTime); @@ -91,5 +103,17 @@ int64_t MountingTelemetry::getLayoutEndTime() const { return layoutEndTime_; } +int64_t MountingTelemetry::getMountStartTime() const { + assert(mountStartTime_ != kUndefinedTime); + assert(mountEndTime_ != kUndefinedTime); + return mountStartTime_; +} + +int64_t MountingTelemetry::getMountEndTime() const { + assert(mountStartTime_ != kUndefinedTime); + assert(mountEndTime_ != kUndefinedTime); + return mountEndTime_; +} + } // namespace react } // namespace facebook diff --git a/ReactCommon/fabric/mounting/MountingTelemetry.h b/ReactCommon/fabric/mounting/MountingTelemetry.h index aa2062cf1e9..97735a10c47 100644 --- a/ReactCommon/fabric/mounting/MountingTelemetry.h +++ b/ReactCommon/fabric/mounting/MountingTelemetry.h @@ -28,6 +28,8 @@ class MountingTelemetry final { void didCommit(); void willLayout(); void didLayout(); + void willMount(); + void didMount(); /* * Reading @@ -39,6 +41,8 @@ class MountingTelemetry final { int64_t getCommitStartTime() const; int64_t getCommitEndTime() const; int64_t getCommitNumber() const; + int64_t getMountStartTime() const; + int64_t getMountEndTime() const; private: constexpr static int64_t kUndefinedTime = std::numeric_limits::max(); @@ -50,6 +54,8 @@ class MountingTelemetry final { int64_t commitEndTime_{kUndefinedTime}; int64_t layoutStartTime_{kUndefinedTime}; int64_t layoutEndTime_{kUndefinedTime}; + int64_t mountStartTime_{kUndefinedTime}; + int64_t mountEndTime_{kUndefinedTime}; }; } // namespace react