From 36650251e8ebe956973c4623af0961c65a0abe50 Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Thu, 28 Mar 2024 15:05:37 +0100 Subject: [PATCH] feat: more startup marks --- .../src/main/java/com/expensify/chat/MainActivity.kt | 7 +++++++ .../main/java/com/expensify/chat/MainApplication.kt | 3 +++ src/libs/Performance.tsx | 12 ++++++++++++ 3 files changed, 22 insertions(+) diff --git a/android/app/src/main/java/com/expensify/chat/MainActivity.kt b/android/app/src/main/java/com/expensify/chat/MainActivity.kt index 935ba8c8825f..2daebb9b1c00 100644 --- a/android/app/src/main/java/com/expensify/chat/MainActivity.kt +++ b/android/app/src/main/java/com/expensify/chat/MainActivity.kt @@ -14,6 +14,8 @@ import com.facebook.react.ReactActivityDelegate import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled import com.facebook.react.defaults.DefaultReactActivityDelegate +import com.oblador.performance.RNPerformance + class MainActivity : ReactActivity() { /** * Returns the name of the main component registered from JavaScript. This is used to schedule @@ -82,4 +84,9 @@ class MainActivity : ReactActivity() { KeyCommandModule.getInstance().onKeyDownEvent(keyCode, event) return super.onKeyUp(keyCode, event) } + + override fun onStart() { + super.onStart() + RNPerformance.getInstance().mark("appCreationEnd", false); + } } diff --git a/android/app/src/main/java/com/expensify/chat/MainApplication.kt b/android/app/src/main/java/com/expensify/chat/MainApplication.kt index 2362af009979..e660a871359d 100644 --- a/android/app/src/main/java/com/expensify/chat/MainApplication.kt +++ b/android/app/src/main/java/com/expensify/chat/MainApplication.kt @@ -15,6 +15,7 @@ import com.facebook.react.defaults.DefaultReactNativeHost import com.facebook.react.modules.i18nmanager.I18nUtil import com.facebook.soloader.SoLoader import com.google.firebase.crashlytics.FirebaseCrashlytics +import com.oblador.performance.RNPerformance import expo.modules.ApplicationLifecycleDispatcher import expo.modules.ReactNativeHostWrapper @@ -42,6 +43,8 @@ class MainApplication : MultiDexApplication(), ReactApplication { override fun onCreate() { super.onCreate() + RNPerformance.getInstance().mark("appCreationStart", false); + if (isOnfidoProcess()) { return } diff --git a/src/libs/Performance.tsx b/src/libs/Performance.tsx index 8d812014dbf8..9302b538a621 100644 --- a/src/libs/Performance.tsx +++ b/src/libs/Performance.tsx @@ -134,6 +134,13 @@ if (Metrics.canCapturePerformanceMetrics()) { if (entry.name === 'runJsBundleEnd') { Performance.measureFailSafe('runJsBundle', 'runJsBundleStart', 'runJsBundleEnd'); } + if (entry.name === 'appCreationEnd') { + Performance.measureFailSafe('appCreation', 'appCreationStart', 'appCreationEnd'); + Performance.measureFailSafe('nativeLaunchEnd_To_appCreationStart', 'nativeLaunchEnd', 'appCreationStart'); + } + if (entry.name === 'contentAppeared') { + Performance.measureFailSafe('appCreationEnd_To_contentAppeared', 'appCreationEnd', 'contentAppeared'); + } // We don't need to keep the observer past this point if (entry.name === 'runJsBundleEnd' || entry.name === 'downloadEnd') { @@ -154,6 +161,7 @@ if (Metrics.canCapturePerformanceMetrics()) { // Capture any custom measures or metrics below if (mark.name === `${CONST.TIMING.SIDEBAR_LOADED}_end`) { + Performance.measureFailSafe('contentAppeared_To_screenTTI', 'contentAppeared', mark.name); Performance.measureTTI(mark.name); } }); @@ -163,6 +171,10 @@ if (Metrics.canCapturePerformanceMetrics()) { Performance.getPerformanceMetrics = (): PerformanceEntry[] => [ ...rnPerformance.getEntriesByName('nativeLaunch'), + ...rnPerformance.getEntriesByName('nativeLaunchEnd_To_appCreationStart'), + ...rnPerformance.getEntriesByName('appCreation'), + ...rnPerformance.getEntriesByName('appCreationEnd_To_contentAppeared'), + ...rnPerformance.getEntriesByName('contentAppeared_To_screenTTI'), ...rnPerformance.getEntriesByName('runJsBundle'), ...rnPerformance.getEntriesByName('jsBundleDownload'), ...rnPerformance.getEntriesByName('TTI'),