It doesn't look like something straightforward, but there is an instrument command line tool. Here is some quick + dirty code that will call it and an example of CPU usage for the calling process
static void sampleMe() { // instruments -t '/Developer/Applications/Instruments.app/Contents/Resources/templates/CPU Sampler.tracetemplate' -p 26838 -l 5000 NSTask *task = [[NSTask alloc] init]; [task setLaunchPath:@"/usr/bin/instruments"]; [task setArguments:[NSArray arrayWithObjects: @"-t", @"/Developer/Applications/Instruments.app/Contents/Resources/templates/CPU Sampler.tracetemplate", @"-p", [NSString stringWithFormat:@"%ld", getpid()], @"-l", @"5000", nil]]; [task setCurrentDirectoryPath:NSHomeDirectory()]; [task setStandardInput:[NSPipe pipe]]; [task setStandardOutput:[NSPipe pipe]]; [task setStandardError:[NSPipe pipe]]; [task launch]; // purposely leak everything since I can't be bothered to figure out lifetimes }
After the call, a file named instrumentscli0.trace will be located in your home directory.
Update: Tools 4.0 offer DTSendSignalFlag in DTPerformanceSession apps for iOS.
source share