Skip to content

Profiling App Launch

Rolf Bjarne Kvinge edited this page Sep 2, 2022 · 2 revisions

This document will explain how to profile the startup of the .NET Podcasts app on an iOS device. It assumes you already have .NET and the mobile workloads installed.

See Profiling for information about how to profile the app using .NET's profiler.

  1. Clone the dotnet-podcasts repository:

    $ git clone https://github.com/microsoft/dotnet-podcasts
  2. Build the project for Release:

    $ cd dotnet-podcasts/src/Mobile
    $ dotnet build /bl /p:Configuration=Release /p:NoSymbolStrip=true Microsoft.NetConf2021.Maui.csproj

    We build for Release to make sure we're not wasting time profiling debug code.

    We also add NoSymbolStrip=true to the build, which will make sure we don't strip away native symbols from the executable. This way stack traces in Instruments will be much more helpful.

  3. Run the project to install the app on your device

    $ dotnet build /bl /p:Configuration=Release /p:NoSymbolStrip=true Microsoft.NetConf2021.Maui.csproj /t:Run

    This will install the app on your device so that Instruments will find it.

  4. Profiling the app

    • Launch Instruments.

    • Select your device at the top.

    • Select the .NET Pods app in the list of installed apps.

    • Select the App Launch instrument.

      Launching Instruments

    • Click Choose

      Ready to launch

    • Hit the Record button in the top-left corner.

    • The app will now launch. Since we're only interested in the startup sequence, we can stop profiling (by hitting the stop button) once the app has launched.

      Profile completed

    • Selecting the third row (App Lifecycle) will show the lifecycle of the app. Usually the most interesting data point is when the app has completed launching, this is the last row in the table at the bottom ("Currently running in the foreground..."). For this particular launch it took the app 0.522s to complete launching.

      Lifecycle

  5. Further reading

    Instruments is an extremely powerful profiling tool, and there are a wealth of options and ways to dig into the profiling data. More information about Instruments can be found online - this page about Reducing App Launch Time could be a good start.

Clone this wiki locally