gpt4 book ai didi

ios - 在 iPad 上测量函数的运行时间

转载 作者:行者123 更新时间:2023-12-01 18:27:33 25 4
gpt4 key购买 nike

我想知道在 iPad 上运行的某个功能所消耗的确切时间。
由于某种原因,我在运行应用程序时无法将 iPad 连接到 macbook(USB 被其他设备占用)。

我试过使用时钟(),像这样

clock_t start = clock();

/* Do something here */

double executionTime = (double)(clock()-start) / CLOCKS_PER_SEC;

我不知道为什么 executionTime 的值为 0。
开始时间和结束时间的差大约是 1,000,000,000(我自己计算)。但是我无法获得正确的 CLOCKS_PER_SEC(它每次都会改变),所以我不知道那个数字的含义。

我读了帖子“iOS 设备上的 ctime 不能正确测量时间”,但它没有帮助。
有没有办法修复 CLOCKS_PER_SEC?或者还有其他方法可以测量时间。

谢谢

CLK_TCK 的值为 1,000,000。
整个程序以 5 秒结束。

最佳答案

executionTime是 double 数,而不是整数。您必须使用 %f格式而不是 %d用于格式化。

关于ios - 在 iPad 上测量函数的运行时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12025520/

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