Refactor startup performance API implementation

Summary:
Refactor the startup performance API so that we are not using a vector to store only a few startup metrics values. This makes the metrics more strictly typed and concise.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D43860049

fbshipit-source-id: 2c2102de2b64e2c5cda509ac26f0d1d072287083
This commit is contained in:
Xin Chen
2023-03-09 08:34:58 -08:00
committed by Facebook GitHub Bot
parent bcec590071
commit 0018a695da
3 changed files with 46 additions and 48 deletions
+8 -19
View File
@@ -58,26 +58,15 @@ std::unordered_map<std::string, double> NativePerformance::getSimpleMemoryInfo(
ReactNativeStartupTiming NativePerformance::getReactNativeStartupTiming(
jsi::Runtime &rt) {
ReactNativeStartupTiming result = {0, 0, 0, 0};
result.startTime = ReactMarker::getAppStartTime();
auto startupReactMarkers =
ReactMarker::StartupLogger::getInstance().getStartupReactMarkers();
for (const auto &startupReactMarker : startupReactMarkers) {
auto time = startupReactMarker.time;
switch (startupReactMarker.markerId) {
case ReactMarker::ReactMarkerId::RUN_JS_BUNDLE_START:
result.executeJavaScriptBundleEntryPointStart = time;
break;
case ReactMarker::ReactMarkerId::RUN_JS_BUNDLE_STOP:
result.executeJavaScriptBundleEntryPointEnd = time;
result.endTime = time;
break;
default:
break;
}
}
ReactMarker::StartupLogger &startupLogger =
ReactMarker::StartupLogger::getInstance();
result.startTime = startupLogger.getAppStartTime();
result.executeJavaScriptBundleEntryPointStart =
startupLogger.getRunJSBundleStartTime();
result.executeJavaScriptBundleEntryPointEnd =
startupLogger.getRunJSBundleEndTime();
result.endTime = startupLogger.getRunJSBundleEndTime();
return result;
}