Overview
iOS profiling captures detailed data about your application’s performance during launch, helping you identify slow functions and optimize startup time. iOS profiling is built on top of the mach Kernel API and periodically samples all application threads to collect call stacks.
Prerequisites
- Your iOS application must use the Datadog iOS SDK version 3.6.0+.
- RUM without Limits must be enabled in your organization.
Setup
- Set up Mobile RUM for iOS.
- Initialize the RUM SDK and configure the
applicationLaunchSampleRate, which determines the percentage of application launches that are profiled (for example, 5% means profiling runs on 5 out of 100 launches).
If no value is specified, the default applicationLaunchSampleRate is 5 percent.
import DatadogCore
import DatadogRUM
import DatadogProfiling
// Initialize Datadog SDK with your configuration
Datadog.initialize(
with: Datadog.Configuration(
clientToken: "<client token>", // From Datadog UI
env: "<environment>", // for example, "production", "staging"
service: "<service name>" // Your app's service name
),
trackingConsent: trackingConsent // GDPR compliance setting
)
// Enable RUM feature
RUM.enable(
with: RUM.Configuration(
applicationID: "<rum application id>"
)
)
// Enable Profiling feature
Profiling.enable() // default is 5%
Explore profiling data
During the time to initial display
iOS application launch profiling data is attached to the time to initial display vital event in a RUM session. You can access the time to initial display from the session side panel, view side panel, or directly from the time to initial display vital side panel.
Use the flame graph to identify which functions consume the most Wall time during launch, the thread timeline to see parallel execution patterns, and the call graph to trace function dependencies. You can also download the profiling data for external analysis or deeper investigation.
Further Reading
Additional helpful documentation, links, and articles: