gpt4 book ai didi

iphone - 用于测量 iPad 或手机代码内精确执行时间的代码?

转载 作者:IT王子 更新时间:2023-10-29 07:58:19 26 4
gpt4 key购买 nike

使用 ma​​ch_absolute_time 和下面 golden eagle 解释的简单 NSDate 方法有什么区别吗?

这是使用 mach 方法的一个很好的解释...

How do I accurately time how long it takes to call a function on the iPhone?

Measure time between library call and callback

最佳答案

loop
{
NSDate *start = [NSDate date];

// a considerable amount of difficult processing here
// a considerable amount of difficult processing here
// a considerable amount of difficult processing here

NSDate *methodFinish = [NSDate date];
NSTimeInterval executionTime = [methodFinish timeIntervalSinceDate:start];

NSLog(@"Execution Time: %f", executionTime);
}

应该可以。

关于iphone - 用于测量 iPad 或手机代码内精确执行时间的代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4773654/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com