python - 相当于 Linux 上的 GetTickCount()

标签 python c linux time

我正在寻找等同于 GetTickCount() 的内容在 Linux 上。

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

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/3327163/

相关文章:

c - extern 和 static 的正确用法是什么?

python - 如何从 USB pendrive 运行 c 代码?

linux - Shell 脚本未按预期工作

python - 将数据从 excel 电子表格导入到 django 模型

c++ - 如何识别C或C++

linux - 如何通过命令行编辑和保存Python文件

node.js - Dockerfile ubuntu只安装node版本4.2

python - 如何配置 Django、PostgreSQL、Apache 和 Python?

python - Pyranges 中重叠和相交方法的区别

python - 从转储数据中排除 admin.logenty