menu
How to Monitor Performance of Mobile Apps Built with Xamarin « US English

How to Monitor Performance of Mobile Apps Built with Xamarin

SHARE ON:

According to a recent post on TechCrunch, both the Apple and Android App Stores have about 1.2 million apps each. Does that sound like too many? Not quite – especially when Apple reports that about 300 million users visit the App Store each week! Clearly, if you have a well-executed mobile app, there is money to be made. At least 9 million developers think so.

Building an app is not enough—it should perform     

1-star Appstore Review

When your app is slow, the last time you’re likely to hear from your end-users is when they leave a poor review on the app store.  It’s easy to get bug reports when the app crashes, but what about when the interface is just sluggish?  Often, end-user experience (EUE) problems come as a complete surprise because “it works great on my device.”  Fortunately, SteelCentral Web Analyzer (formerly called BrowserMetrix) makes it easy to monitor the performance for your Xamarin-based apps.

End-user experience may mean different things to different people.  Generally, we want to know how happy or frustrated the end-users are.  If the app feels unresponsive because the phone does not have the resources, or the web service is slow, users will be unhappy.  Conversely, if the app responds to inputs very quickly, the users will likely have a good experience.

Know your app’s end-user experience

SteelCentral Web Analyzer directly measures end-user experience inside the iOS app code. It includes an open-source library that sends data from each phone to a web application. In this article, we will also be using a wrapper library that exposes the native MAITI library functions in Xamarin.

The end result is a searchable database of “transactions” that include the response times for every important user interaction. For example, the screenshot below shows the response time for the "Load Graph" transaction.  

Transaction Results from Web Analyzer

In this example, loading and rendering a graph on the user's phone took 8.174 seconds.  Two downloads occur serially.  The first download comprised more than 80% of the total delay, while the second was much faster.

Getting Started

  • You must have an active Xamarin development license and a Mac OSX machine configured to develop Xamarin iOS apps.
  • You should also sign up for a SteelCentral Web Analyzer account.  Create a new “mobile” application and write down the customer ID and app ID.
  • Clone the MAITI Xamarin wrapper project.
  • In Xarmarin Studio, add the MAITI Xamarin project to your Xamarin solution.
  • Click Project -> Edit references and add the project as a reference to your iOS app

Instrumenting an application

Xamarin Studio with performance instrumentation code

Performance is instrumented by adding start and stop tags in the code.  The example above shows C# instrumentation inside Xamarin Studio.

SteelCentral Web Analyzer measures the performance for “transactions.”  A transaction can be anything that takes some amount of time to complete.  For example, you could define a “User Login” transaction that measures the time between a user tapping the “Connect” button and the interface becoming fully loaded.  In the code, you will add the following:

// The PerformanceLibrary object should be instantiated as a *Singleton*
PerformanceLibrary eue = new PerformanceLibrary(“[customer id]”, “[app id”]);
// Use the maiti_xamarin namespace
using maiti_xamarin;
                …
// Signal the start of a transaction – get the ID
String transactionID = eue.TransactionStart(“User Login”);

// Add a tag to the transaction (username in this case)
eue.setUserTag1(username, transactionID);

… [Authenticate login credentials, load the new view] …

// Signal that the transaction is complete
eue.transactionEnd(transactionID);

NOTE: The PerformanceLibrary object should be created as a singleton.  This is the most efficient way to use the library, and it allows for tracking performance across ViewControllers.

In the above example, we also added the user’s login name to the transaction as a tag.  This is a great way of adding searchable information to your transactions.  In this case, if a particular user complains of performance issues, you can search for those transactions easily in the SteelCentral Web Analyzer web interface.  This is also a great place to put error or debug information (e.g., details from a caught exception).

Web Analyzer Search results for user 'mahill'

Web Analyzer allows you to quickly search for important transactions.  In this example, we see the performance history for the user named 'mahill' as he navigated the mobile app.

This same code should be used throughout the application wherever there are transactions that are important to monitor. 

Performance data is yours!

Once enabled, the app will silently upload performance data for every user interaction.  This utilizes very few resources, but it may be a good idea to notify users.  One approach is to include an “Opt-In” notice when the application first loads where users can choose to allow their performance data to be monitored.  SteelCentral Web Analyzer can then be enabled or disabled via the “SetDisabled” method of the PerformanceLibrary class.

Opt-in screen on iPhone for End-User Experience

The end result is an app that will look exactly as it did before.  Under the hood, every important transaction is measured, tagged, and uploaded to a central location.  From here you can analyze the in-depth performance characteristics for all the various devices and users of your app.  Once you know where the problems are, you can be proactive and develop fixes.  With SteelCentral Web Analyzer monitoring your Xamarin apps, you will never read about performance issues in an app store review again. Sign up for a free trial today!

Related reading:

How to Monitor iOS and Android Mobile Apps with the MAITI API

SteelCentral Web Analyzer Review: What We Found Can Make Your Site Faster

top.name