mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix warm start logging for ReactMarker (#41693)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/41693 This diff fixes app warm start time. Before this change, we cache the first time when app start timing is logged, and ignore future loggings. Some apps are warm started and the startup time should be updated. Reviewed By: dmitry-voronkevich Differential Revision: D50481710 fbshipit-source-id: 03e00b75ee7ac578209ae3478adabe567e92a950
This commit is contained in:
committed by
Facebook GitHub Bot
parent
88a55baeaa
commit
44109dc2c0
@@ -53,9 +53,13 @@ void StartupLogger::logStartupEvent(
|
||||
double markerTime) {
|
||||
switch (markerId) {
|
||||
case ReactMarkerId::APP_STARTUP_START:
|
||||
if (std::isnan(appStartupStartTime)) {
|
||||
appStartupStartTime = markerTime;
|
||||
if (!std::isnan(appStartupStartTime)) {
|
||||
// We had a startup start time, which indicates a warm start (user
|
||||
// closed the app and start again). In this case we need to invalidate
|
||||
// all other startup timings.
|
||||
reset();
|
||||
}
|
||||
appStartupStartTime = markerTime;
|
||||
return;
|
||||
|
||||
case ReactMarkerId::APP_STARTUP_STOP:
|
||||
@@ -93,6 +97,15 @@ void StartupLogger::logStartupEvent(
|
||||
}
|
||||
}
|
||||
|
||||
void StartupLogger::reset() {
|
||||
appStartupStartTime = std::nan("");
|
||||
appStartupEndTime = std::nan("");
|
||||
initReactRuntimeStartTime = std::nan("");
|
||||
initReactRuntimeEndTime = std::nan("");
|
||||
runJSBundleStartTime = std::nan("");
|
||||
runJSBundleEndTime = std::nan("");
|
||||
}
|
||||
|
||||
double StartupLogger::getAppStartupStartTime() {
|
||||
return appStartupStartTime;
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ class RN_EXPORT StartupLogger {
|
||||
static StartupLogger& getInstance();
|
||||
|
||||
void logStartupEvent(const ReactMarkerId markerName, double markerTime);
|
||||
void reset();
|
||||
double getAppStartupStartTime();
|
||||
double getInitReactRuntimeStartTime();
|
||||
double getInitReactRuntimeEndTime();
|
||||
|
||||
Reference in New Issue
Block a user