我是靠谱客的博主 幸福大碗,这篇文章主要介绍perf_counter()函数——time.perf_counter()time.perf_counter()自我理解1、Dash中函数说明2、标准库中定义,现在分享给大家,希望可以做个参考。

time.perf_counter()

自我理解

  • perf_counter()是第三方库time的函数
  • perf_counter()返回当前的计算机系统时间
  • 只有连续两次perf_counter()进行差值才能有意义,一般用于计算程序运行时间。
import time
start = time.perf_counter()
time.sleep(5)
end = time.perf_counter()
dur = start - end
print(dur)

使用sleep让程序休眠5s,dur就是程序运行消耗的时间。

1、Dash中函数说明

  • time.perf_counter() → float
    Return the value (in fractional seconds) of a performance counter, i.e. a clock with the highest available resolution to measure a short duration. It does include time elapsed during sleep and is system-wide. The reference point of the returned value is undefined, so that only the difference between the results of consecutive calls is valid.
  • 返回值为float类型
  • 返回计数器的值(以微秒为单位),即最高测量分辨率的时钟。包括睡眠时间和系统时间。返回值的引用点未定义,因此只有连续调用结果之间的差异才有效。

2、标准库中定义

def perf_counter(): # real signature unknown; restored from __doc__
    """
    perf_counter() -> float
    
    Performance counter for benchmarking.
    """
    return 0.0

最后

以上就是幸福大碗最近收集整理的关于perf_counter()函数——time.perf_counter()time.perf_counter()自我理解1、Dash中函数说明2、标准库中定义的全部内容,更多相关perf_counter()函数——time内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(197)

评论列表共有 0 条评论

立即
投稿
返回
顶部