I have the following code that is taking a while to process:
self.itemsArray = [Helper changeTheA:self.itemsArray];
self.itemsArray = [Helper convertDates:self.itemsArray];
Is there a way, in Instruments or somewhere else, that I can measure the time is takes to go from the first line of code to the second line of code…. in ticks or milliseconds or something?
I want to do some tweaking but I need to be able to measure in order to see if I’m making an improvement over the previous code.
Quickest, dirtiest, possibly not very precise way
A slightly more involved but probably more useful solution, if you are doing some basic profiling can be seen here, it uses a C function that executes a block you provide.
Big side note
As Justin points out the actual act of creating an
NSDateand then logging it out will introduce interference to your measurements and so this technique is only really any good for getting ball park figures and even then you should probably run large amounts of iterations of your code within the timing block. If you require accurate measurements then skip to Justin’s answer