In the first part of the series about getting started with Instruments we had a look at the interface of Instruments.
Before we can do some actual testing with Instruments we are going to do some thinking about what we want to test, how we want to test and how to measure testing.
Using in the debugger
Using Instruments while running the debugger means that the app runs slower. However, doing tests in debug mode is hugely less annoying than having to build the app every time. Final testing should only be done with a built app.
What do you want to test?
The article from Ray Wenderlich’s website says that you should use Instruments just for the heck of it:
Besides improving your app by adding features though, there is one thing that all good app developers should do… instrument their code!
Nobody has time to have a detailed look at everything. Identify slow features and use Instruments there instead.
For my application Mail Archiver the bottle neck is usually archiving emails. But even there I could do wildly different tests:
- Archive lots of small emails.
- Archive a few really huge emails (we will to this later).
- Do some testing with AppleScripts - that’s always majorly unpleasant.
- Archive from emails clients versus IMAP.
And so on. There is lots of fun to be had.
You are not at the doctor. There is not one test after which the doctor tells you that your symptoms are all in your head. Test with intent but try to minimise your bias. At the beginning I told you how I thought that my application couldn’t become slower. Which was a pretty bad bias. And as usual I was proven wrong.
Preparing the app
Prepare your application so that you only have to do one or two clicks in the application when starting the test. Remember that you have to input your password when starting to record in Instruments.
Using Instruments then just means I have to start archiving by clicking on the Archive button.
How to measure
Fortunately, my application Mail Archiver has a simple measuring system built in, the Application Log window.
This information gives me the ultimate information about the speed of my application. It doesn’t matter at all if I improve the speed of an algorithm by 10 milliseconds. I need to see the improvement in the Application Log!
Select your test or your test data so that it takes enough time but isn’t too short. You only do an analysis in Instruments for a couple of seconds. Therefore, I’m usually using a special account for email archiving so that I see a practical difference.
Repeat your tests
Don’t run your tests once. Perhaps your computer needed a thinking pause. Or your backup started. Or a download started or the Favourite Sister started watching Netflix while I tried to do some testing on IMAP.
In the next part of the series we will finally do some testing.