monitor.py (1863B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\carbonui\modules\monitor.py 2 import blue 3 from carbon.common.script.sys.service import Service 4 import uthread 5 6 class FpsMonitorSvc(Service): 7 __guid__ = 'svc.fpsMonitorSvc' 8 __servicename__ = 'Fps Monitor Service' 9 __displayname__ = 'Fps Monitor Service' 10 11 def Run(self, *args): 12 self.collectingFpsStats = False 13 self.fpsStat = blue.statistics.Find('FPS') 14 self.frameTimeStat = blue.statistics.Find('Trinity/FrameTime') 15 16 def GetFPS(self): 17 return self.fpsStat.value 18 19 def IsCollectingStats(self): 20 return self.collectingFpsStats 21 22 def GetStatsCollectionTime(self): 23 return blue.os.GetWallclockTime() - self.collectingFpsStats 24 25 def GetStatsData(self): 26 return self.statsData 27 28 def StartCollectingData(self, *args): 29 self.fpsStats = [] 30 self.statsData = {'fps': [], 31 'frametime': []} 32 uthread.new(self.CollectDataThread) 33 34 def CollectDataThread(self): 35 MAX_STATS = 36000 36 self.collectingFpsStats = blue.os.GetWallclockTime() 37 while self.collectingFpsStats: 38 deltaTime = blue.os.GetWallclockTime() - self.collectingFpsStats 39 self.fpsStats.append((deltaTime, self.fpsStat.value)) 40 fps = self.fpsStat.value 41 frametime = self.frameTimeStat.value 42 if fps: 43 self.statsData['fps'].append(fps) 44 if frametime: 45 self.statsData['frametime'].append(frametime) 46 if deltaTime > const.HOUR: 47 self.StopCollectingData() 48 return 49 blue.synchro.SleepWallclock(200) 50 51 def StopCollectingData(self, *args): 52 self.collectingFpsStats = None 53 ret = self.fpsStats[:] 54 self.fpsStats = [] 55 return ret