鱼C论坛

 找回密码
 立即注册
查看: 2983|回复: 1

time.perf_counter()返回性能计数器的值(以秒的小数部分为单位),我的输出不符标准

[复制链接]
发表于 2022-10-22 21:25:51 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
import threading  # 线程模块
import time


def eat_breakfast():
    time.sleep(3)
    print("You eat breakfast")


def drink_coffee():
    time.sleep(4)
    print("You drank coffee")


def study():
    time.sleep(5)
    print("You finish studying")


x = threading.Thread(target=eat_breakfast, args=())
x.start()

y = threading.Thread(target=drink_coffee, args=())
y.start()

z = threading.Thread(target=study, args=())
z.start()

x.join()     # thread synchronization(线程同步)
y.join()     # thread synchronize and join(线程同步并加入)
z.join()


# eat_breakfast()
# drink_coffee()
# study()


print(threading.active_count())  # 函数名活动计数
print(threading.enumerate())  # 函数名枚举
print(time.perf_counter())  # performance counter function(函数名性能计数器)

console window:
You eat breakfast
You drank coffee
You finish studying
1
[<_MainThread(MainThread, started 14744)>]
9517.6617491
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2022-10-23 02:52:30 | 显示全部楼层
视频教程输出只有5.1390643s,我的输出是9517.6617491s,这没道理呀
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-9-25 23:24

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表