0.6.1 developing
This commit is contained in:
parent
5ce329a73f
commit
fd94062b66
12
Difficult_Rocket/crash/__init__.py
Normal file
12
Difficult_Rocket/crash/__init__.py
Normal 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
|
||||||
|
"""
|
@ -34,23 +34,30 @@ class FpsLogger:
|
|||||||
wait_time: int = 5):
|
wait_time: int = 5):
|
||||||
self.stable_fps = stable_fps
|
self.stable_fps = stable_fps
|
||||||
self.wait_time = wait_time
|
self.wait_time = wait_time
|
||||||
|
self.time = time.time_ns()
|
||||||
self.fps_list = [[stable_fps, time.time_ns()]]
|
self.fps_list = [[stable_fps, time.time_ns()]]
|
||||||
self._max_fps = stable_fps
|
self._max_fps = stable_fps
|
||||||
|
self._max_fps_tick = time.time_ns()
|
||||||
self._min_fps = stable_fps
|
self._min_fps = stable_fps
|
||||||
|
self._min_fps_tick = time.time_ns()
|
||||||
self.check_list = True
|
self.check_list = True
|
||||||
self.update_list()
|
self.update_list()
|
||||||
|
|
||||||
# @new_thread('fps_logger update', daemon=False, log_thread=False)
|
# @new_thread('fps_logger update', daemon=False, log_thread=False)
|
||||||
def update_tick(self,
|
def update_tick(self,
|
||||||
tick: Decimal):
|
tick: Decimal):
|
||||||
now_time = time.time_ns()
|
self.time = time.time_ns()
|
||||||
now_fps = pyglet.clock.get_fps()
|
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))
|
if now_fps > self.max_fps and not self.time - self._max_fps_tick >= self.wait_time:
|
||||||
tick_time = now_time - self.fps_list[-1][1]
|
self.max_fps = now_fps
|
||||||
self.fps_list.append([now_fps, now_time, tick_time, tick])
|
tick_time = self.time - self.fps_list[-1][1]
|
||||||
if now_time - self.fps_list[0][1] >= self.wait_time * (10 ** 9):
|
# 获取渲染用时
|
||||||
|
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)
|
self.fps_list.pop(0)
|
||||||
|
del now_fps
|
||||||
|
del tick_time
|
||||||
|
|
||||||
@new_thread('fps_logger check_list', daemon=True)
|
@new_thread('fps_logger check_list', daemon=True)
|
||||||
def update_list(self):
|
def update_list(self):
|
||||||
@ -65,7 +72,30 @@ class FpsLogger:
|
|||||||
def max_fps(self):
|
def max_fps(self):
|
||||||
return self._max_fps
|
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
|
@property
|
||||||
def min_fps(self):
|
def min_fps(self):
|
||||||
return self._min_fps
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user