-(voID)myInterestingMethod{ [self startTrace]; // do something interesting and performance critical [self stopTrace];}
如果上述代码不可用,那么设置我自己的DTrace探针是否可行?
解决方法 看起来没有任何直接的东西,但有一个仪器命令行工具.这是一些快速脏代码,它将调用它并为调用进程提供cpu使用率示例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}
调用后,名为instrumentscli0.trace的文件将位于您的主目录中.
更新:Instruments 4.0在DTPerformanceSession for iOS应用程序中提供了DTSendSignalFlag.
总结以上是内存溢出为你收集整理的objective-c – 有一个Instruments API吗?全部内容,希望文章能够帮你解决objective-c – 有一个Instruments API吗?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)