Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Unified Diff: tools/perf/metrics/timeline.py

Issue 1084533005: Support total and per-second task/threadtime timeline metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use time from interaction_records Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/perf/measurements/thread_times_unittest.py ('k') | tools/perf/metrics/timeline_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/perf/metrics/timeline.py
diff --git a/tools/perf/metrics/timeline.py b/tools/perf/metrics/timeline.py
index 1a1ca25e219edde5f445920118c05da1725b3db6..a2b7931581bdc12ad409e7738861a5bb391f0ffc 100644
--- a/tools/perf/metrics/timeline.py
+++ b/tools/perf/metrics/timeline.py
@@ -101,6 +101,8 @@ OverheadTraceName = "overhead"
FrameTraceName = "::SwapBuffers"
FrameTraceThreadName = "renderer_compositor"
+IntervalNames = ["frame", "second"]
nednguyen(REVIEW IN OTHER ACC) 2015/05/01 22:00:45 Instead of seconds, we probably want to use ms for
jdduke (slow) 2015/05/01 23:49:01 Done.
+
def Rate(numerator, denominator):
return DivideIfPossibleOrZero(numerator, denominator)
@@ -127,19 +129,23 @@ def ThreadCategoryName(thread_name):
thread_category = TimelineThreadCategories[thread_name]
return thread_category
-def ThreadCpuTimeResultName(thread_category):
+def ThreadCpuTimeResultName(thread_category, interval_name):
# This isn't a good name, but I don't want to change it and lose continuity.
- return "thread_" + thread_category + "_cpu_time_per_frame"
+ return "thread_" + thread_category + "_cpu_time_per_" + interval_name
-def ThreadTasksResultName(thread_category):
- return "tasks_per_frame_" + thread_category
+def ThreadTasksResultName(thread_category, interval_name):
+ return "tasks_per_" + interval_name + "_" + thread_category
-def ThreadMeanFrameTimeResultName(thread_category):
- return "mean_frame_time_" + thread_category
+def ThreadMeanTimeResultName(thread_category, interval_name):
+ return "mean_" + interval_name + "_time_" + thread_category
-def ThreadDetailResultName(thread_category, detail):
+def ThreadDetailResultName(thread_category, interval_name, detail):
detail_sanitized = detail.replace('.','_')
- return "thread_" + thread_category + "|" + detail_sanitized
+ # Special-case per-frame detail names to preserve continuity.
+ interval_sanitized = (
+ "" if interval_name == "frame" else "_per_" + interval_name)
nednguyen(REVIEW IN OTHER ACC) 2015/05/01 22:00:45 This is a bit hard to read, can you change this to
jdduke (slow) 2015/05/01 23:49:01 Done.
+ return (
+ "thread_" + thread_category + interval_sanitized + "|" + detail_sanitized)
class ResultsForThread(object):
@@ -188,17 +194,18 @@ class ResultsForThread(object):
self.all_slices.extend(self.SlicesInActions(thread.all_slices))
self.toplevel_slices.extend(self.SlicesInActions(thread.toplevel_slices))
- # Currently we report cpu-time per frame, tasks per frame, and possibly
- # the mean frame (if there is a trace specified to find it).
- def AddResults(self, num_frames, results):
- cpu_per_frame = Rate(self.cpu_time, num_frames)
- tasks_per_frame = Rate(len(self.toplevel_slices), num_frames)
+ # Reports cpu-time per interval and tasks per interval.
+ def AddResults(self, num_intervals, interval_name, results):
+ cpu_per_interval = Rate(self.cpu_time, num_intervals)
+ tasks_per_interval = Rate(len(self.toplevel_slices), num_intervals)
results.AddValue(scalar.ScalarValue(
- results.current_page, ThreadCpuTimeResultName(self.name),
- 'ms', cpu_per_frame))
+ results.current_page,
+ ThreadCpuTimeResultName(self.name, interval_name),
+ 'ms', cpu_per_interval))
results.AddValue(scalar.ScalarValue(
- results.current_page, ThreadTasksResultName(self.name),
- 'tasks', tasks_per_frame))
+ results.current_page,
+ ThreadTasksResultName(self.name, interval_name),
+ 'tasks', tasks_per_interval))
# Report mean frame time if this is the thread we are using for normalizing
# other results. We could report other frame rates (eg. renderer_main) but
# this might get confusing.
@@ -206,10 +213,11 @@ class ResultsForThread(object):
num_frames = self.CountTracesWithName(FrameTraceName)
mean_frame_time = Rate(self.all_action_time, num_frames)
nednguyen(REVIEW IN OTHER ACC) 2015/05/01 22:00:45 This computation only applies for per_frames metri
jdduke (slow) 2015/05/01 23:49:01 Right, I'll move it out.
results.AddValue(scalar.ScalarValue(
- results.current_page, ThreadMeanFrameTimeResultName(self.name),
+ results.current_page,
+ ThreadMeanTimeResultName(self.name, interval_name),
'ms', mean_frame_time))
- def AddDetailedResults(self, num_frames, results):
+ def AddDetailedResults(self, num_intervals, interval_name, results):
slices_by_category = collections.defaultdict(list)
for s in self.all_slices:
slices_by_category[s.category].append(s)
@@ -217,15 +225,19 @@ class ResultsForThread(object):
for category, slices_in_category in slices_by_category.iteritems():
self_time = sum([x.self_time for x in slices_in_category])
all_self_times.append(self_time)
- self_time_result = (float(self_time) / num_frames) if num_frames else 0
+ self_time_result = (
+ (float(self_time) / num_intervals) if num_intervals else 0)
results.AddValue(scalar.ScalarValue(
- results.current_page, ThreadDetailResultName(self.name, category),
+ results.current_page,
+ ThreadDetailResultName(self.name, interval_name, category),
'ms', self_time_result))
nednguyen(REVIEW IN OTHER ACC) 2015/05/01 22:00:44 With the per second metrics, the unit 'ms' here is
jdduke (slow) 2015/05/01 23:49:01 Seconds as an interval is nice because it's slight
all_measured_time = sum(all_self_times)
idle_time = max(0, self.all_action_time - all_measured_time)
- idle_time_result = (float(idle_time) / num_frames) if num_frames else 0
+ idle_time_result = (
+ (float(idle_time) / num_intervals) if num_intervals else 0)
results.AddValue(scalar.ScalarValue(
- results.current_page, ThreadDetailResultName(self.name, "idle"),
+ results.current_page,
+ ThreadDetailResultName(self.name, interval_name, "idle"),
'ms', idle_time_result))
def CountTracesWithName(self, substring):
@@ -235,6 +247,7 @@ class ResultsForThread(object):
count += 1
return count
+
class ThreadTimesTimelineMetric(timeline_based_metric.TimelineBasedMetric):
def __init__(self):
super(ThreadTimesTimelineMetric, self).__init__()
@@ -247,7 +260,7 @@ class ThreadTimesTimelineMetric(timeline_based_metric.TimelineBasedMetric):
thread_category_results = {}
for name in TimelineThreadCategories.values():
thread_category_results[name] = ResultsForThread(
- model, [r.GetBounds() for r in interaction_records], name)
+ model, [r.GetBounds() for r in interaction_records], name)
# Group the slices by their thread category.
for thread in model.GetAllThreads():
@@ -263,15 +276,22 @@ class ThreadTimesTimelineMetric(timeline_based_metric.TimelineBasedMetric):
if ThreadCategoryName(thread.name) in FastPathThreads:
thread_category_results['total_fast_path'].AppendThreadSlices(thread)
- # Calculate the number of frames.
+ # Calculate the interaction's number of frames.
frame_rate_thread = thread_category_results[FrameTraceThreadName]
num_frames = frame_rate_thread.CountTracesWithName(FrameTraceName)
- # Report the desired results and details.
- for thread_results in thread_category_results.values():
- if thread_results.name in self.results_to_report:
- thread_results.AddResults(num_frames, results)
- # TOOD(nduca): When generic results objects are done, this special case
- # can be replaced with a generic UI feature.
- if thread_results.name in self.details_to_report:
- thread_results.AddDetailedResults(num_frames, results)
+ # Calculate the interaction's duration.
+ all_threads = thread_category_results['total_all']
+ num_seconds = all_threads.all_action_time / 1000.0
+
+ # Report the desired results and details for each interval type.
+ intervals = [("frame", num_frames), ("second", num_seconds)]
+ for (interval_name, num_intervals) in intervals:
+ for thread_results in thread_category_results.values():
+ if thread_results.name in self.results_to_report:
+ thread_results.AddResults(num_intervals, interval_name, results)
+ # TOOD(nduca): When generic results objects are done, this special case
+ # can be replaced with a generic UI feature.
+ if thread_results.name in self.details_to_report:
+ thread_results.AddDetailedResults(
+ num_intervals, interval_name, results)
« no previous file with comments | « tools/perf/measurements/thread_times_unittest.py ('k') | tools/perf/metrics/timeline_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698