Performance/Fenix/Debug API: Difference between revisions

→‎Usage for start up: Switch code sample from diff to kotlin
m (→‎Usage for start up: Change warning to italics instead of bold)
(→‎Usage for start up: Switch code sample from diff to kotlin)
Line 18: Line 18:
First, you need to start tracing. Add the following to <code>FenixApplication.kt</code> to measure start up as early as possible:
First, you need to start tracing. Add the following to <code>FenixApplication.kt</code> to measure start up as early as possible:


<syntaxhighlight lang="diff">
<syntaxhighlight lang="kotlin">
+    override fun attachBaseContext(base: Context) {
    override fun attachBaseContext(base: Context) {
+        if (base.isMainProcess()) {
        if (base.isMainProcess()) {
+            Debug.startMethodTracingSampling(
            Debug.startMethodTracingSampling(
+                "startup",
                "startup",
+                0,
                0,
+                TimeUnit.MILLISECONDS.toMicros(1).toInt()
                TimeUnit.MILLISECONDS.toMicros(1).toInt()
+            )
            )
+        }
        }
+        super.attachBaseContext(base)
        super.attachBaseContext(base)
+    }
    }
</syntaxhighlight>
</syntaxhighlight>


Confirmed users
975

edits