Cross Platform
Android
iOS
Mac

Profiling Xamarin.iOS Applications with Instruments

In this article, we’ll describe how to use Instruments on any iOS device and any Xamarin.iOS application. We’ll also look at how to profile applications in the simulator.

Overview

We can use the iOS developer app to profile Instruments in Xamarin.iOS or we can use the simulator. Mono uses its Just-in-Time model to compile code and Instruments doesn’t interpret this kind of data well, so it can be difficult to work with output from simulator-based applications that use Instruments. Because of this issue, we’ll concentrate on how to use the developer app to interpret Instruments output in this document.

You will need to switch over to your Mac to use Instruments on your Xamarin.iOS for Visual Studio project.

Opening the Instruments App

Select your device and run the Instruments app

  1. Open your project.
  2. Select the Debug|iPhone configuration.
  3. In the main menu, select Run -> Upload to Device. The application will now be built and uploaded to your device.
  4. Open a terminal window and execute: open /Developer/Applications/Instruments.app

Instruments will now open, and you’ll see the following:

Make sure iOS/Memory is selected on the left, and Allocations on the right, as in the screenshot. You can choose other profilers (CPU, I/O Activity, etc), but the following screenshots are all from the Memory/Allocations profiler.

Click Choose button, and you’ll be presented with this screen:

Now we need to choose the right target on which to execute:

If you don't see your device listed under the Choose Target menu, check the Console for error messages, and ensure you have set up your device for development through the Xcode Organizer (Window->Organizer menu in Xcode):

Click Record to start profiling.

The following screenshot shows an example of profiling using Instruments.

Summary

In this brief topic, we’ve described how to configure an environment, select your iOS device, and how to use the iOS Instruments developer app to profile a Xamarin.iOS application.