You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Coarse Time
若仅从高性能的角度出发来寻找计时方案,可使用 Coarse Time,它牺牲了一定的精度换取高性能。在 Linux 环境下,以 CLOCK_MONOTONIC_COARSE 作为时间源参数,通过 clock_gettime 系统调用可获取 Coarse Time。Rust 社区也提供了库 coarsetime 获取 Coarse Time:
coarsetime::Instant::now()
Coarse Time 性能很高,在测试环境下完成两次调用仅需要 10ns。它的精度取决于 Linux 的 jiffies 配置,默认精度为 4ms。
代码中
// Standard library's `time.Now()` will invoke two syscalls in Linux. One is `CLOCK_REALTIME` and// another is `CLOCK_MONOTONIC`. In our case, we'd like to separate these two calls to measure// time for performance purpose.// `nanotime()` is identical to Linux's `clock_gettime(CLOCK_MONOTONIC, &ts)`funcmonotimeNs() uint64 {
returnuint64(nanotime())
}
Hello,
我有一个关于时间精度的问题想请教。
看了这篇文章 https://www.jianshu.com/p/d57b12d18c98
代码中
monotimeNs方法就是根据CLOCK_MONOTONIC_COARSE时间源吗? 那么是否有默认精度4ms的问题?
第二个问题是:
本库的实现原理好像和
https://github.com/tikv/minitrace-rust
不是一样的, 对吗?The text was updated successfully, but these errors were encountered: