NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

uiPerformanceTestWnd.py (2589B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\devtools\script\uiPerformanceTestWnd.py
      2 from __future__ import print_function
      3 import blue
      4 import carbonui.const as uiconst
      5 from carbonui.control.button import Button
      6 from carbonui.control.window import Window
      7 from eve.devtools.script.uiPerformanceTests import PerformanceTests
      8 from player_messaging.client.ui_message import prompt_player_fsd_dialog
      9 
     10 class UIPerformanceTestWnd(Window):
     11     default_caption = 'UI Performance Test Utility'
     12     default_windowID = 'UIPerformanceTestID'
     13     default_fixedWidth = 380
     14     default_fixedHeight = 100
     15 
     16     def ApplyAttributes(self, attributes):
     17         Window.ApplyAttributes(self, attributes)
     18         self.isTesting = False
     19         self.startBtn = Button(name='self.startBtn', parent=self.sr.main, align=uiconst.CENTER, label='Start Test', func=self.OnStartBtn)
     20 
     21     def OnStartBtn(self, *args):
     22         self.startBtn.Disable()
     23         self.RunAllTests()
     24         self.startBtn.Enable()
     25 
     26     def RunAllTests(self):
     27         self.HideScene()
     28         results = PerformanceTests().RunTests()
     29         self.ShowScene()
     30         self.DisplayResults(results)
     31         prompt_player_fsd_dialog('CustomNotify', {'notify': 'All Tests successful. Results copied to clipboard'})
     32 
     33     def HideScene(self):
     34         scene = sm.GetService('sceneManager').GetActiveScene()
     35         scene.display = False
     36         scene.update = False
     37 
     38     def ShowScene(self):
     39         scene = sm.GetService('sceneManager').GetActiveScene()
     40         scene.display = True
     41         scene.update = True
     42 
     43     def DisplayResults(self, results):
     44         txt = ''
     45         for description, stats in results:
     46             txt += '%s:\n' % description
     47             for t, value in stats:
     48                 txt += '%.1f\t%6.2f\n' % (t / float(const.SEC), value)
     49 
     50             txt += '\n'
     51 
     52         txt += 'SUMMARY'
     53         totalTime = 0
     54         for description, stats in results:
     55             txt += '\n%s:' % description
     56             values = [ value for t, value in stats ]
     57             txt += '\nMedian FPS: %s' % median(values)
     58             txt += '\nAverage FPS: %s' % (sum(values) / float(len(values)))
     59             txt += '\n'
     60             time = [ t for t, value in stats ]
     61             totalTime += time[-1]
     62 
     63         txt += '\nTotal time: %s' % (totalTime / float(const.SEC))
     64         print(txt)
     65         blue.pyos.SetClipboardData(txt)
     66 
     67 
     68 def median(mylist):
     69     sorts = sorted(mylist)
     70     length = len(sorts)
     71     if not length % 2:
     72         return (sorts[length / 2] + sorts[length / 2 - 1]) / 2.0
     73     return sorts[length / 2]