Skip to main content

probe

Function probe 

Source
pub fn probe() -> u64
Available on crate feature rand only.
Expand description

采集硬件时间戳并归一化到 1GHz 的原始熵源。

读取 x86(RDTSC)/aarch64(CNTVCT_EL0)/RISC-V(rdtime) 等计数器, 用 Q48 定点乘子换算为纳秒级单调时钟。 连续调用通常递增,但在虚拟化/热迁移下不保证严格单调;求差值请用 wrapping_sub。

§Feature Requirement

需要启用 "rand" 特性。

§Examples

use lib_unknown::rand::probe;

let t1 = probe();
let t2 = probe();
let _delta_ns = t2.wrapping_sub(t1);