commit about v 0.6.1

This commit is contained in:
沈瑗杰 2021-10-29 00:15:31 +08:00
parent 65a0260d91
commit 5ce329a73f
2 changed files with 18 additions and 10 deletions

View File

@ -193,7 +193,7 @@ class ClientWindow(pyglet.window.Window):
now_FPS = pyglet.clock.get_fps()
self.fps_log.update_tick(tick)
# self.fps_label.text = 'FPS: {:5.1f} {:.1f} ({:.1f}/{:.1f}) | MSPF: {:.5f} '.format(now_FPS, 1 / tick, self.fps_log.max_fps, self.fps_log.min_fps, tick)
self.fps_label.text = f'FPS: {now_FPS:>10.1f} {now_FPS:.1f} {self.fps_log.max_fps:>5.1f} {self.fps_log.min_fps:>5.1f}'
self.fps_label.text = f'FPS: {now_FPS:>10.1f} {self.fps_log.max_fps:>5.1f} {self.fps_log.min_fps:>5.1f}'
def on_draw(self):
self.clear()
@ -272,6 +272,7 @@ class ClientWindow(pyglet.window.Window):
def on_close(self, source: str = 'window') -> None:
self.logger.info(tr.lang('window', 'game.stop_get').format(tr.lang('window', f'game.{source}_stop')))
self.logger.info(tr.lang('window', 'game.stop'))
self.fps_log.check_list = False
if self.run_input:
self.run_input = False
self.save_info()

View File

@ -16,7 +16,7 @@ import decimal
from decimal import Decimal
from ..api.new_thread import new_thread
from ..api import new_thread
from libs import pyglet
@ -35,30 +35,37 @@ class FpsLogger:
self.stable_fps = stable_fps
self.wait_time = wait_time
self.fps_list = [[stable_fps, time.time_ns()]]
self._max_fps = stable_fps
self._min_fps = stable_fps
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()
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):
self.fps_list.pop(0)
@new_thread('fps_logger check_list', daemon=True)
def update_list(self):
now_time = time.time_ns()
for fps_time in self.fps_list:
if now_time - fps_time[1] >= self.wait_time * (10 ** 9):
del fps_time
while self.check_list:
now_time = time.time_ns()
for fps_time in self.fps_list:
if now_time - fps_time[1] >= self.wait_time * (10 ** 9):
del self.fps_list[self.fps_list.index(fps_time)]
time.sleep(1)
@property
def max_fps(self):
fps_list = [fpss[0] for fpss in self.fps_list]
return max(fps_list)
return self._max_fps
@property
def min_fps(self):
fps_list = [fpss[0] for fpss in self.fps_list]
return min(fps_list)
return self._min_fps