-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add performance.reactNativeStartupTiming API
Summary: This diff adds the `performance.reactNativeStartupTiming` API to the performance global object for RN. This property does not exist in web, and we are free to make up our own list of properties in the startup metrics to track RN app startup process. In our case, we have the following six properties to begin with (we may extend and add more to this list in the future): ``` - `(start|end)Time`: The time ‘zero’ for the startup timing and the end of app startup. RN has no knowledge of app start time, which will be provided by the platform. The `endTime` will be the time when the first JS bundle finishes executing (Note that RN supports multiple JS bundles, which can be loaded async) - `executeJavaScriptBundleEntryPoint(Start|End)`: The time for RN to execute the JS entry point (and finish all sync job) ``` Changelog: [General][Added] - Add new JS performance API to support getting RN app startup timings Reviewed By: rshest Differential Revision: D43326564 fbshipit-source-id: 7b4c7cae70ff64ba1714a1630cd5e183df6c06b0
- Loading branch information
1 parent
ba9327d
commit c1023c7
Showing
12 changed files
with
279 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
|
||
// flowlint unsafe-getters-setters:off | ||
|
||
import type {ReactNativeStartupTiming as ReactNativeStartupTimingType} from './NativePerformance'; | ||
|
||
// Read-only object with RN startup timing information. | ||
// This is returned by the performance.reactNativeStartup API. | ||
export default class ReactNativeStartupTiming { | ||
// All time information here are in ms. To match web spec, | ||
// the default value for timings are zero if not present. | ||
// See https://www.w3.org/TR/performance-timeline/#performancetiming-interface | ||
_startTime = 0; | ||
_endTime = 0; | ||
_executeJavaScriptBundleEntryPointStart = 0; | ||
_executeJavaScriptBundleEntryPointEnd = 0; | ||
|
||
constructor(startUpTiming: ?ReactNativeStartupTimingType) { | ||
if (startUpTiming != null) { | ||
this._startTime = startUpTiming.startTime; | ||
this._endTime = startUpTiming.endTime; | ||
this._executeJavaScriptBundleEntryPointStart = | ||
startUpTiming.executeJavaScriptBundleEntryPointStart; | ||
this._executeJavaScriptBundleEntryPointEnd = | ||
startUpTiming.executeJavaScriptBundleEntryPointEnd; | ||
} | ||
} | ||
|
||
/** | ||
* Start time of the RN app startup process. This is provided by the platform by implementing the `ReactMarker.setAppStartTime` API in the native platform code. | ||
*/ | ||
get startTime(): number { | ||
return this._startTime; | ||
} | ||
|
||
/** | ||
* End time of the RN app startup process. This is equal to `executeJavaScriptBundleEntryPointEnd`. | ||
*/ | ||
get endTime(): number { | ||
return this._endTime; | ||
} | ||
|
||
/** | ||
* Start time of JS bundle being executed. This indicates the RN JS bundle is loaded and start to be evaluated. | ||
*/ | ||
get executeJavaScriptBundleEntryPointStart(): number { | ||
return this._executeJavaScriptBundleEntryPointStart; | ||
} | ||
|
||
/** | ||
* End time of JS bundle being executed. This indicates all the synchronous entry point jobs are finished. | ||
*/ | ||
get executeJavaScriptBundleEntryPointEnd(): number { | ||
return this._executeJavaScriptBundleEntryPointEnd; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.