gpt4 book ai didi

python - 等效于 Linux 上的 GetTickCount()

转载 作者:IT老高 更新时间:2023-10-28 22:12:06 25 4
gpt4 key购买 nike

我正在寻找与 GetTickCount() 等效的版本在 Linux 上。

目前我正在使用 Python 的 time.time()大概是调用到 gettimeofday() .我担心的是,如果时钟被 NTP 弄乱,返回的时间(unix 纪元)可能会发生不规律的变化。一个简单的过程或系统挂墙时间,仅以恒定速率正增加就足够了。

C 或 Python 中是否存在这样的时间函数?

最佳答案

您可以使用 CLOCK_MONOTONIC例如在 C 中:

struct timespec ts;
if(clock_gettime(CLOCK_MONOTONIC,&ts) != 0) {
//error
}

查看此问题以了解 Python 方式 - How do I get monotonic time durations in python?

关于python - 等效于 Linux 上的 GetTickCount(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2958291/

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