0.6.1 developing

This commit is contained in:
沈瑗杰 2021-10-30 20:19:12 +08:00
parent 5ce329a73f
commit fd94062b66
26 changed files with 48 additions and 6 deletions

View File

@ -0,0 +1,12 @@
# -------------------------------
# Difficult Rocket
# Copyright © 2021 by shenjackyuanjie
# All rights reserved
# -------------------------------
"""
writen by shenjackyuanjie
mail: 3695888@qq.com
github: @shenjackyuanjie
gitee: @shenjackyuanjie
"""

View File

@ -34,23 +34,30 @@ class FpsLogger:
wait_time: int = 5):
self.stable_fps = stable_fps
self.wait_time = wait_time
self.time = time.time_ns()
self.fps_list = [[stable_fps, time.time_ns()]]
self._max_fps = stable_fps
self._max_fps_tick = time.time_ns()
self._min_fps = stable_fps
self._min_fps_tick = time.time_ns()
self.check_list = True
self.update_list()
# @new_thread('fps_logger update', daemon=False, log_thread=False)
def update_tick(self,
tick: Decimal):
now_time = time.time_ns()
self.time = time.time_ns()
now_fps = pyglet.clock.get_fps()
self._max_fps = max(self._max_fps, int(now_fps))
self._min_fps = min(self._min_fps, int(now_fps))
tick_time = now_time - self.fps_list[-1][1]
self.fps_list.append([now_fps, now_time, tick_time, tick])
if now_time - self.fps_list[0][1] >= self.wait_time * (10 ** 9):
# 获取当前信息
if now_fps > self.max_fps and not self.time - self._max_fps_tick >= self.wait_time:
self.max_fps = now_fps
tick_time = self.time - self.fps_list[-1][1]
# 获取渲染用时
self.fps_list.append([now_fps, self.time, tick_time, tick])
if self.time - self.fps_list[0][1] >= self.wait_time * (10 ** 9):
self.fps_list.pop(0)
del now_fps
del tick_time
@new_thread('fps_logger check_list', daemon=True)
def update_list(self):
@ -65,7 +72,30 @@ class FpsLogger:
def max_fps(self):
return self._max_fps
@max_fps.setter
def max_fps(self, value):
if self.time - self._max_fps_tick <= self.wait_time:
self._max_fps = value
self._max_fps_tick = time.time_ns()
else:
max_fps = self.list_max_fps
self._max_fps = max_fps[0]
self._max_fps_tick = max_fps[1]
del max_fps
@property
def min_fps(self):
return self._min_fps
@min_fps.setter
def min_fps(self, value):
self._min_fps = value
self._min_fps_tick = time.time_ns()
@property
def list_max_fps(self):
return max(self.fps_list)
@property
def list_min_fps(self):
return min(self.fps_list)