def testAsyncTraceEventMetricsMultipleTests(self): model = model_module.TimelineModel() renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2) renderer_main.name = 'CrRendererMain' # Set up a main model that looks like: # [ blink_perf.run_test ] [ blink_perf.run_test ] # | | | | # [ foo ] # | [ foo ] # | | | | | | | | # 80 90 100 200 300 400 500 510 # CPU dur: None for all # self._AddBlinkTestSlice(renderer_main, 100, 200) self._AddBlinkTestSlice(renderer_main, 300, 400) # Both events totally intersect both tests. self._AddAsyncSlice(renderer_main, 'blink', 'foo', 80, 500) self._AddAsyncSlice(renderer_main, 'blink', 'bar', 90, 510) self.assertEquals( blink_perf._ComputeTraceEventsThreadTimeForBlinkPerf( model, renderer_main, ['foo', 'bar']), {'foo': [100, 100], 'bar': [100, 100]})
def testTraceEventMetricsNoDoubleCountingBasic(self): model = model_module.TimelineModel() renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2) renderer_main.name = 'CrRendererMain' # Set up a main thread model that looks like: # [ blink_perf.run_test ] # | [ foo ] [ foo ] | # | [ foo ] | | | # | | [ foo ] | | | | # | | | | | | | | # 100 120 140 400 420 440 510 550 # | | # CPU dur of | | # of top most event: 280 50 # self._AddBlinkTestSlice(renderer_main, 100, 550) renderer_main.BeginSlice('blink', 'foo', 120, 130) renderer_main.BeginSlice('blink', 'foo', 120, 130) renderer_main.BeginSlice('blink', 'foo', 140, 150) renderer_main.EndSlice(400, 390) renderer_main.EndSlice(420, 410) renderer_main.EndSlice(420, 410) renderer_main.BeginSlice('blink', 'foo', 440, 455) renderer_main.EndSlice(510, 505) self.assertEquals( blink_perf._ComputeTraceEventsThreadTimeForBlinkPerf( model, renderer_main, ['foo']), {'foo': [330]})
def testTraceEventMetricsNoDoubleCountingWithOtherSlidesMixedIn(self): model = model_module.TimelineModel() renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2) renderer_main.name = 'CrRendererMain' # Set up a main thread model that looks like: # [ blink_perf.run_test ] # | [ foo ] [ bar ] | # | | [ bar ] | | [ foo ] | | # | | | [ foo ] | | | | | | | # | | | | | | | | | | | | # 100 120 130 140 | 400 405 420 440 480 | 510 520 550 # | | # CPU dur of | | # of top most event: 280 (foo) & 270 (bar) 50 (bar) & 20 (foo) # self._AddBlinkTestSlice(renderer_main, 100, 550) renderer_main.BeginSlice('blink', 'foo', 120, 130) renderer_main.BeginSlice('blink', 'bar', 130, 135) renderer_main.BeginSlice('blink', 'foo', 140, 150) renderer_main.EndSlice(400, 390) renderer_main.EndSlice(405, 405) renderer_main.EndSlice(420, 410) renderer_main.BeginSlice('blink', 'bar', 440, 455) renderer_main.BeginSlice('blink', 'foo', 480, 490) renderer_main.EndSlice(510, 510) renderer_main.EndSlice(510, 505) self.assertEquals( blink_perf._ComputeTraceEventsThreadTimeForBlinkPerf( model, renderer_main, ['foo', 'bar']), {'foo': [300], 'bar': [320]})
def testTraceEventMetricsNoThreadTimeAvailable(self): model = model_module.TimelineModel() renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2) renderer_main.name = 'CrRendererMain' # Set up a main thread model that looks like: # [ blink_perf.run_test ] # | [ foo ] [ bar ] | # | | | | | | # 100 120 140 400 420 550 # | | # CPU dur: None None # self._AddBlinkTestSlice(renderer_main, 100, 550) renderer_main.BeginSlice('blink', 'foo', 120) renderer_main.EndSlice(140) renderer_main.BeginSlice('blink', 'bar', 400) renderer_main.EndSlice(420) self.assertEquals( blink_perf._ComputeTraceEventsThreadTimeForBlinkPerf( model, renderer_main, ['foo', 'bar']), {'foo': [20], 'bar': [20]})
def testTraceEventMetricsMultiBlinkTest(self): model = model_module.TimelineModel() renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2) renderer_main.name = 'CrRendererMain' # Set up a main thread model that looks like: # [ blink_perf.run_test ] [ blink_perf.run_test ] # | [ foo ] [ bar ] | [ | foo ] | # | | | | | | | | | | | # 100 120 140 400 420 440 500 520 600 640 # | | | # CPU dur: 15 18 40 # self._AddBlinkTestSlice(renderer_main, 100, 440) self._AddBlinkTestSlice(renderer_main, 520, 640) renderer_main.BeginSlice('blink', 'foo', 120, 122) renderer_main.EndSlice(140, 137) renderer_main.BeginSlice('blink', 'bar', 400, 402) renderer_main.EndSlice(420, 420) # Since this "foo" slice has CPU duration = 40ms, wall-time duration = 100ms # & its overalapped wall-time with "blink_perf.run_test" is 80 ms, its # overlapped CPU time with "blink_perf.run_test" is # 80 * 40 / 100 = 32ms. renderer_main.BeginSlice('blink', 'foo', 500, 520) renderer_main.EndSlice(600, 560) self.assertEquals( blink_perf._ComputeTraceEventsThreadTimeForBlinkPerf( model, renderer_main, ['foo', 'bar', 'baz']), {'foo': [15, 32], 'bar': [18, 0], 'baz': [0, 0]})
def testTraceEventMetricsSingleBlinkTest(self): model = model_module.TimelineModel() renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2) renderer_main.name = 'CrRendererMain' # Set up a main thread model that looks like: # [ blink_perf.run_test ] # | [ foo ] [ bar ] [ baz ] # | | | | | | | | # 100 120 140 400 420 500 550 600 # | | | # CPU dur: 15 18 70 # self._AddBlinkTestSlice(renderer_main, 100, 550) renderer_main.BeginSlice('blink', 'foo', 120, 122) renderer_main.EndSlice(140, 137) renderer_main.BeginSlice('blink', 'bar', 400, 402) renderer_main.EndSlice(420, 420) # Since this "baz" slice has CPU duration = 70ms, wall-time duration = 100ms # & its overalapped wall-time with "blink_perf.run_test" is 50 ms, its # overlapped CPU time with "blink_perf.run_test" is # 50 * 70 / 100 = 35ms. renderer_main.BeginSlice('blink', 'baz', 500, 520) renderer_main.EndSlice(600, 590) self.assertEquals( blink_perf._ComputeTraceEventsThreadTimeForBlinkPerf( model, renderer_main, ['foo', 'bar', 'baz']), {'foo': [15], 'bar': [18], 'baz': [35]})
def testAsyncTraceEventMetricsOverlapping(self): model = model_module.TimelineModel() renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2) renderer_main.name = 'CrRendererMain' # Set up a main thread model that looks like: # [ blink_perf.run_test ] # | [ foo ] [ bar ] | # | [ foo ] | | | | # | | | | | | | | # 100 110 120 130 140 400 420 550 # CPU dur: None for all. # self._AddBlinkTestSlice(renderer_main, 100, 550) self._AddAsyncSlice(renderer_main, 'blink', 'foo', 110, 130) self._AddAsyncSlice(renderer_main, 'blink', 'foo', 120, 140) self._AddAsyncSlice(renderer_main, 'blink', 'bar', 400, 420) self.assertEquals( blink_perf._ComputeTraceEventsThreadTimeForBlinkPerf( model, renderer_main, ['foo', 'bar']), { 'foo': [30], 'bar': [20] })
def testTraceEventMetricsMultiBlinkTestCrossProcesses(self): model = model_module.TimelineModel() renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2) renderer_main.name = 'CrRendererMain' foo_thread = model.GetOrCreateProcess(2).GetOrCreateThread(4) bar_thread = model.GetOrCreateProcess(2).GetOrCreateThread(5) # Set up a main model that looks like (P1 & P2 are different processes): # P1 [ blink_perf.run_test ] [ blink_perf.run_test ] # | | | | # P2 | [ foo ] | [ | foo ] | # | | | | [ bar ] | | | | | # | | | | | | | | | | | | | # 100 120 | 140 400 | 420 440 500 520 | 600 640 # | | | # CPU dur: 15 N/A 40 # self._AddBlinkTestSlice(renderer_main, 100, 440) self._AddBlinkTestSlice(renderer_main, 520, 640) foo_thread.BeginSlice('blink', 'foo', 120, 122) foo_thread.EndSlice(140, 137) bar_thread.BeginSlice('blink', 'bar', 400) bar_thread.EndSlice(420) # Since this "foo" slice has CPU duration = 40ms, wall-time duration = 100ms # & its overalapped wall-time with "blink_perf.run_test" is 80 ms, its # overlapped CPU time with "blink_perf.run_test" is # 80 * 40 / 100 = 32ms. foo_thread.BeginSlice('blink', 'foo', 500, 520) foo_thread.EndSlice(600, 560) self.assertEquals( blink_perf._ComputeTraceEventsThreadTimeForBlinkPerf( model, renderer_main, ['foo', 'bar', 'baz']), { 'foo': [15, 32], 'bar': [20, 0], 'baz': [0, 0] })