Benchmarking a specific method in Objective-C

I have a critical method in an Objective-C application that I need to optimize as much as possible. First I need to do some simple tests for this single method so that I can compare my progress with the optimization.

What is the easiest way to track the execution time of this method, for example, in milliseconds and print to the console.

+3
source share
4 answers

CFAbsoluteTimeGetCurrent () (about 6 microseconds) or mach_absolute_time () from mach / mach_time.h (somewhat faster, but you need to call mach_timebase_info () and do some conversions). Then you can print to stdout or use NSLog; note that NSLog takes age (50 ms?), so you want to do this after taking the measurements. It seems to me that stdout is a little faster, but it does not go to syslog (i.e. the console of the Xcode Organizer / iPhone configuration console).

+3
source

, ... , , . , , , , , - .

, , NSLogs .

+2

, / , , . , - .

+1
0

All Articles