简体   繁体   English

我如何计时可可应用程序?

[英]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.

相关问题 如何禁用拖出我的可可应用程序的功能? - How do I disable dragging out of my Cocoa app? 如何在我的Cocoa Touch应用中实施“首次用户注册”工作流程? - How can I implement a “first time user registration” workflow in my Cocoa Touch app? 有时我想停止我的Cocoa应用程序的启动,如何在初始化中停止它? - Sometimes I want to stop my Cocoa app from launching, how do I stop it in init? 在运行应用程序时,如何使用我在Mac OS X Cocoa App中放入Xcode的文件? - How do I use files that I dropped into Xcode in a Mac OS X Cocoa App when running the application? 在可可中,如何使用NSTimeZone以字符串形式获取系统时区偏移量? - In Cocoa, how do I use NSTimeZone to get the system time zone offset as a string? 如何在Cocoa应用程序中为导出的JPEG图像设置每英寸的像素? - How do I set the pixels per inch for an exported JPEG image in a Cocoa app? 如何在Cocoa中获取当前日期 - How do I get the current date in Cocoa 如何在 Cocoa 中移动精灵? - How do I move a sprite in Cocoa? 可可/如何在应用程序委托中获取对当前窗口的contentViewController的引用? - Cocoa/ How do I get a reference to current window's contentViewController in app delegate? 如何使用 Cocoa 创建临时文件? - How do I create a temporary file with Cocoa?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM