Skip to content

Commit

Permalink
Merge pull request #39181 from margelo/feat/more-startup-marks
Browse files Browse the repository at this point in the history
[NoQA] feat: more startup marks
  • Loading branch information
mountiny authored Apr 2, 2024
2 parents 5cdfbb7 + 3665025 commit bf1ec5a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions android/app/src/main/java/com/expensify/chat/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -42,6 +43,8 @@ class MainApplication : MultiDexApplication(), ReactApplication {
override fun onCreate() {
super.onCreate()

RNPerformance.getInstance().mark("appCreationStart", false);

if (isOnfidoProcess()) {
return
}
Expand Down
12 changes: 12 additions & 0 deletions src/libs/Performance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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);
}
});
Expand All @@ -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'),
Expand Down

0 comments on commit bf1ec5a

Please sign in to comment.