get_clock_info因变量获得时钟的基础消息,获得的值因各别体例生存分别,因变量原形比拟大略:
time.get_clock_info(name)
个中 name 不妨取下述值:
monotonic:time.monotonic()
perf_counter: time.perf_counter()
process_time: time.process_time()
thread_time: time.thread_time()
time: time.time()
该因变量的归来值具备以部下性:
adjustable : 归来 True 大概 False。即使时钟不妨机动变动(比方经过 NTP 保护步调)或由体例处置员手动变动,则为 True ,要不为 False ;
implementation : 用来获得时钟值的普通 C 因变量的称呼,即是挪用底层 C 的因变量;
monotonic :即使时钟不许停滞,则为 True ,要不为 False;
resolution : 以秒为单元的时钟辨别率( float )。
import time
available_clocks = [
('clock', time.clock),
('monotonic', time.monotonic),
('perf_counter', time.perf_counter),
('process_time', time.process_time),
('time', time.time),
]
for clock_name, func in available_clocks:
print('''
{name}:
adjustable : {info.adjustable}
implementation: {info.implementation}
monotonic : {info.monotonic}
resolution : {info.resolution}
current : {current}
'''.format(
name=clock_name,
info=time.get_clock_info(clock_name),
current=func()))
上海图书馆表露橡皮擦的计划机在 clock 与 perf_counter 中,挪用底层 C 因变量是普遍的。