How do you check a clock's suitability for measuring inference duration?
get_clock_info reports clock properties including monotonicity. A monotonic clock supports measuring differences between readings within a run.
Python example and interpretation
Check the monotonic flag of perf_counter before timing repeated calls. Its readings should not be stored as calendar timestamps for events.
import time
time.get_clock_info('perf_counter').monotonicResult True
中文
怎样检查计时工具是否适合测推理耗时?
get_clock_info 报告时钟是否单调等属性。单调时钟适合计算同一次运行中两个读数之间的差。
Python 算例与适用条件
先核对 perf_counter 的单调属性,再计多次调用的时间差。该时钟的读数不应作为事件的日历时间戳。
import time
time.get_clock_info('perf_counter').monotonic结果 True