renderjobprofiler.py (3256B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\devtools\script\renderjobprofiler.py 2 from __future__ import print_function 3 import blue 4 from carbonui.control.combo import Combo 5 from carbonui.primitives.container import Container 6 from carbonui import const as uiconst 7 import trinity 8 import uthread2 9 from carbonui.control.window import Window 10 from eve.client.script.ui.control.entries.generic import Generic 11 from eve.client.script.ui.control.entries.util import GetFromClass 12 from eve.client.script.ui.control.eveLabel import Label 13 from eve.client.script.ui.control.eveScroll import Scroll 14 from carbonui.control.button import Button 15 PANEL_HEIGHT = 250 16 PANEL_WIDTH = 450 17 18 class RenderJobProfiler(Window): 19 default_width = PANEL_WIDTH 20 default_height = PANEL_HEIGHT 21 default_minSize = (default_width, default_height) 22 23 def ApplyAttributes(self, attributes): 24 super(RenderJobProfiler, self).ApplyAttributes(attributes) 25 self.SetCaption('Render Job Profiler') 26 self._renderJob = None 27 parent = self.GetMainArea() 28 parent.SetAlign(uiconst.TOALL) 29 parent.padding = 5 30 top = Container(parent=parent, align=uiconst.TOTOP, height=Combo.default_height) 31 Label(text='Render Job', parent=top, align=uiconst.TOLEFT, padding=4) 32 combo = Combo(parent=top, options=[ (rj.name, rj) for rj in trinity.renderJobs.recurring ], callback=self._OnRenderJob, align=uiconst.TOALL) 33 bottom = Container(parent=parent, align=uiconst.TOBOTTOM, height=Button.default_height, padding=2) 34 Button(parent=bottom, align=uiconst.CENTER, label='Copy', func=self._Copy, args=()) 35 self._scroll = Scroll(parent=parent, align=uiconst.TOALL, top=4) 36 self._OnRenderJob(None, None, combo.selectedValue) 37 uthread2.StartTasklet(self._UpdateTiming) 38 39 def _Copy(self): 40 if not self._renderJob: 41 return 42 table = '\n'.join(('{0}\t{1:.4f}\t{2:.4f}'.format(step.name or type(step).__name__, step.cpuTime, step.gpuTime) for step in self._renderJob.steps)) 43 print(table) 44 blue.pyos.SetClipboardData(table) 45 46 def _UpdateTiming(self): 47 while self.state != uiconst.UI_HIDDEN: 48 for each in self._scroll.GetNodes(): 49 if each['panel']: 50 step = each['step'] 51 each['panel'].sr.label.text = '{0}<t>{1:.4f}<t>{2:.4f}'.format(step.name or type(step).__name__, step.cpuTime, step.gpuTime) 52 53 uthread2.Sleep(0.03) 54 55 def _OnRenderJob(self, _, __, value): 56 if value == self._renderJob: 57 return 58 if self._renderJob: 59 for step in self._renderJob.steps: 60 step.debugCaptureCpuTime = False 61 step.debugCaptureGpuTime = False 62 63 self._renderJob = value 64 contentList = [] 65 if value: 66 for step in value.steps: 67 step.debugCaptureCpuTime = True 68 step.debugCaptureGpuTime = True 69 contentList.append(GetFromClass(Generic, {'label': '%s<t><t>' % (step.name or type(step).__name__), 70 'step': step})) 71 72 self._scroll.Load(contentList=contentList, headers=['Step', 'CPU Time', 'GPU Time'], fixedEntryHeight=18)