How do I automatically create performance reports for an iOS app?

continuous-integration, ios, performance-testing

Solution

I'm also using fruitstrap to install apps on the device in CI. In terms of booting the app, I know of two ways:

Use fruitstrap with the debugger attached

- I know teams that have done this to run KIF integration tests on devices in CI. I have played around with fruitstrap to get it booting apps on the device, but haven't myself taken the extra step of automating the whole thing

- shameless plug for my post on fruitstrap: http://www.stewgleadow.com/blog/2011/11/05/installing-ios-apps-on-the-device-from-the-command-line/

Use the `instruments` command line tool with UIAutomation

- I know the instruments tool can boot apps on the device automatically in CI (I wish it also installed them, but we have fruitstrap for that until Apple fixes it). So you could write a really simple little UIAutomation test that gave your app enough time to do its performance analysis.

- Jonathan Penn has a nice little demo project for UIAutomation and build script that could be integrated with an 'install' step using fruistrap to try it out on the device

In both cases, I uses a little wrapper around libusb to give me the device ID of attached devices, so the more devices I plug into my CI machine, the more devices it runs tests on, https://github.com/sgleadow/iphone_detect

Problem

For some of my iOS application projects, I would like my CI server to be able to report the following properties: - startup time - frame rate both as a graph over time, and with "low water marks" so the build fails if the measured results aren't within certain criteria. I've already found some of the things I need. - The CI server will be Jenkins. - I can use Transporter Chief to get the built app onto an iPad. - To measure the startup time I could find the duration between launching `main()` and leaving `application:didFinishLaunchingWithOptions:`. - To measure frame rate I can put a `CADisplayLink` into the app and sample its `duration` property. - If those tests output JMeter XML, then Jenkins can display the output via the Performance plugin. What I haven't worked out is, how should I embed those tests into my app and launch it on the iPad? As described above I can deploy the app to the iPad, but then I don't know how I would launch it to gather the results of the tests. My unit tests are running on the simulator - I don't want to run the performance tests there obviously :-). I imagine that there's a solution involving jailbreaking the iPad and controlling the app over SSH, I'd prefer not to go down that route if it's possible. If you have done that and can explain how it works, I'd still like to hear about it.

Original source