gpt4 book ai didi

c - Ubuntu 中的时间每次都返回 0/如何

转载 作者:太空宇宙 更新时间:2023-11-04 08:29:30 24 4
gpt4 key购买 nike

我正在尝试使用 sys/times.h 中包含的时间函数来测量 sys、usr 和实时。

但每当我尝试检索实时时,我得到的是 0。

根据 this文档:

The data returned by times() is valid only if time accounting is enabled. This is the default, but it may be disabled to save time and memory when an operating system image is built using the buildqnx utility. When disabled, the struct tms members will always be zero.

我找不到任何方法来检查它是否在我的 Ubuntu 上被禁用。在程序的某些时间点获取时间值的任何替代方法?

谢谢!

最佳答案

您可以多次访问手册页找到您需要的内容,特别是使用 3 获取 C/API 文档:

man 3 times

此外,您还可以在那里找到示例代码。

关于c - Ubuntu 中的时间每次都返回 0/如何,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29052718/

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