[英]How do I time a Cocoa app?
What is an easy way to time a Cocoa application? 计时可可应用程序的简便方法是什么? (Alternatively, any good way to measure performance would suffice). (或者,任何衡量绩效的好方法都足够了)。
(I have two different frameworks and would like to compare their performances over some fixed input data) (我有两个不同的框架,想比较它们在某些固定输入数据上的性能)
Instruments will keep a clock for you, although you may find that the frameworks' difference is within the margin of how quickly you can start the app working on the data. 尽管您可能会发现框架之间的差异在您可以快速启动应用程序处理数据的范围之内,但Instruments会为您提供帮助。
You can use Shark and the CHUD framework to do a better job of this. 您可以使用Shark和CHUD框架来做得更好。 The framework lets you programmatically start and stop profiling; 该框架可让您以编程方式启动和停止分析。 you'll start at the beginning of the work and end at the end of the work, and then have a nice Shark document to show for it. 您将在工作开始时开始,在工作结束时结束,然后有一个很好的Shark文档来显示它。 The Shark manual has more details. Shark手册有更多详细信息。
NSDate *startDate = [NSDate date];
// ...
NSDate *stopDate = [NSDate date];
NSLog(@"-- time: %f", [stopDate timeIntervalSinceDate:startDate]);
You can calculate the time of a cocoa app by using the NSTimer class. 您可以使用NSTimer类来计算可可应用程序的时间。 start the timer when the program runs and end it after all program logic has been completed. 在程序运行时启动计时器,在所有程序逻辑完成后结束计时器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.