python 函数帧率测量(速率)

import time
st1 = time.perf_counter()

def fun():
    global st1
    while True:
        print('刷新帧率' + str((1 / (time.perf_counter() - st1)).__round__(1)) + 'fps')  # 显示帧率
        st1 = time.perf_counter()

        print("*" * 50)
        print("\n")

fun()



输出:

刷新帧率111111.1fps
**************************************************


刷新帧率114942.5fps
**************************************************


刷新帧率117647.1fps
**************************************************


刷新帧率119047.6fps
**************************************************

Guess you like

Origin blog.csdn.net/weixin_43134049/article/details/121263674