Commit 67966175 authored by epenner@chromium.org's avatar epenner@chromium.org

Telemetry: Fix timeline frame counting on Mac

We want to count the last the last swap in the embedding
chain. Usually there is a hardware swap for this but on mac
there doesn't appear to be one. This uses the decoder swap
for now until we know the canonical swap call and add a trace
there.

TBR=nduca@chromium.org
NOTRY=true

No-try since this is blocking this from working on the mac and I've run the tests locally.

Review URL: https://codereview.chromium.org/141163004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245478 0039d316-1c4b-4281-b951-d872f2087c98
parent 496b1765
......@@ -149,6 +149,13 @@ FastPathDetails = NoThreads
SilkResults = ["renderer_main", "total_all"]
SilkDetails = MainThread
# TODO(epenner): Thread names above are likely fairly stable but trace names
# could change. We should formalize this trace to keep this robust.
GpuFrameTraceName = ":RealSwapBuffers"
# TODO(epenner): The decoder swap-buffers can be used by several producers.
# we need to find the canonical swap buffers on Mac.
GpuFrameTraceNameMac = "GLES2DecoderImpl::DoSwapBuffers"
def ThreadCategoryName(thread_name):
thread_category = "other"
for substring, category in TimelineThreadCategories.iteritems():
......@@ -226,20 +233,14 @@ class ThreadTimesTimelineMetric(TimelineMetric):
self.results_to_report = AllThreads
self.details_to_report = NoThreads
def CalcFrameCount(self):
gpu_swaps = 0
for thread in self._model.GetAllThreads():
if (ThreadCategoryName(thread.name) == "GPU"):
for event in thread.IterAllSlices():
if ":RealSwapBuffers" in event.name:
gpu_swaps += 1
return gpu_swaps
def CountSlices(self, slices, substring):
count = 0
for event in slices:
if substring in event.name:
count += 1
return count
def AddResults(self, tab, results):
num_frames = self.CalcFrameCount()
if not num_frames:
raise MissingFramesError()
# Set up each thread category for consistant results.
thread_category_results = {}
for name in TimelineThreadCategories.values():
......@@ -259,6 +260,14 @@ class ThreadTimesTimelineMetric(TimelineMetric):
if ThreadCategoryName(thread.name) in FastPath:
thread_category_results['total_fast_path'].AppendThreadSlices(thread)
# Calculate the number of frames from the GPU thread.
gpu_slices = thread_category_results['GPU'].all_slices
num_frames = self.CountSlices(gpu_slices, GpuFrameTraceName)
if not num_frames:
num_frames = self.CountSlices(gpu_slices, GpuFrameTraceNameMac)
if not num_frames:
raise MissingFramesError()
# Report the desired results and details.
for thread_results in thread_category_results.values():
if thread_results.name in self.results_to_report:
......
......@@ -78,7 +78,7 @@ class ThreadTimesTimelineMetricUnittest(unittest.TestCase):
# Create two frame swaps (Results times should be divided by two)
gpu_main = model.GetOrCreateProcess(1).GetOrCreateThread(3)
gpu_main.name = 'CrGPUMain'
gpu_main.name = 'CrGpuMain'
gpu_main.BeginSlice('gpucat', ':RealSwapBuffers', 10, 10)
gpu_main.EndSlice(11, 11)
gpu_main.BeginSlice('gpucat', ':RealSwapBuffers', 12, 12)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment