简体   繁体   English

如何评估课程中每个功能的时间

[英]How to evaluate time of each function in a class

My UIViewController is loaded fairly slowly. 我的UIViewController加载速度相当慢。 There are several init functions in viewdidload. viewdidload中有几个init函数。 I am trying to figure out which function consumes such much time. 我试图弄清楚哪个功能会消耗很多时间。 Do you know how to evaluate time of each function in a specific class. 您知道如何评估特定类中每个函数的时间吗? I use iOS 7, XCODE 5. 我使用iOS 7,XCODE 5。

More specific, my UIViewController contains a UITableView. 更具体地说,我的UIViewController包含一个UITableView。 At the beginning, I think loading data for UITableView takes such time. 一开始,我认为为UITableView加载数据需要花费一些时间。 However, the loading time of this UITableView is not so much. 但是,此UITableView的加载时间不是很多。 I put a waiting dialog at the first point of ViewDidLoad, and then when a UITableView ends loading, I remove this dialog. 我在ViewDidLoad的第一点放置了一个等待对话框,然后在UITableView结束加载时,删除了此对话框。 This dialog since its appearance, ends very quickly. 该对话框自出现以来很快结束。 The problem is why the UIViewController appears so slowly. 问题是为什么UIViewController出现得如此缓慢。

Create a NSDate object before calling the method like NSDate *startTime = [NSDate date]; 在调用NSDate *startTime = [NSDate date];类的方法之前,先创建一个NSDate对象NSDate *startTime = [NSDate date]; and get the time interval after the method call to which you want to get the time interval. 并在要获取时间间隔的方法调用之后获取时间间隔。 NSTimeInterval interval = [startTime timeIntervalSinceNow];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM