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

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

Issue 1097463004: Add key_idle_power_cases for ensuring idle activity on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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.py ('k') | tools/perf/page_sets/key_power_cases.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..bdfcbcf99d678b40008a2d4564a8bc2f086629c3 100644
--- a/tools/perf/metrics/timeline.py
+++ b/tools/perf/metrics/timeline.py
@@ -127,23 +127,13 @@ def ThreadCategoryName(thread_name):
thread_category = TimelineThreadCategories[thread_name]
return thread_category
-def ThreadCpuTimeResultName(thread_category):
- # 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"
-
-def ThreadTasksResultName(thread_category):
- return "tasks_per_frame_" + thread_category
-
-def ThreadMeanFrameTimeResultName(thread_category):
- return "mean_frame_time_" + thread_category
-
def ThreadDetailResultName(thread_category, detail):
detail_sanitized = detail.replace('.','_')
return "thread_" + thread_category + "|" + detail_sanitized
class ResultsForThread(object):
- def __init__(self, model, record_ranges, name):
+ def __init__(self, model, record_ranges, name, measure_per_frame):
self.model = model
self.toplevel_slices = []
self.all_slices = []
@@ -151,6 +141,7 @@ class ResultsForThread(object):
self.record_ranges = record_ranges
self.all_action_time = \
sum([record_range.bounds for record_range in self.record_ranges])
+ self.measure_per_frame = measure_per_frame
@property
def clock_time(self):
@@ -191,25 +182,28 @@ class ResultsForThread(object):
# 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)
+ num_intervals = num_frames if self.measure_per_frame else 1
+ 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,
+ self.ThreadCpuTimeResultName(self.name), 'ms', cpu_per_interval))
results.AddValue(scalar.ScalarValue(
- results.current_page, ThreadTasksResultName(self.name),
- 'tasks', tasks_per_frame))
+ results.current_page, self.ThreadTasksResultName(self.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.
if self.name == FrameTraceThreadName:
- num_frames = self.CountTracesWithName(FrameTraceName)
- mean_frame_time = Rate(self.all_action_time, num_frames)
+ num_intervals = self.CountTracesWithName(FrameTraceName) \
+ if self.measure_per_frame else 1
+ frame_time = Rate(self.all_action_time, num_intervals)
results.AddValue(scalar.ScalarValue(
- results.current_page, ThreadMeanFrameTimeResultName(self.name),
- 'ms', mean_frame_time))
+ results.current_page, self.ThreadFrameTimeResultName(self.name),
+ 'ms', frame_time))
def AddDetailedResults(self, num_frames, results):
+ num_intervals = num_frames if self.measure_per_frame else 1
slices_by_category = collections.defaultdict(list)
for s in self.all_slices:
slices_by_category[s.category].append(s)
@@ -217,13 +211,15 @@ 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 = \
rnephew (Reviews Here) 2015/04/23 18:28:05 nit: use (...) instead of \
jdduke (slow) 2015/04/24 16:10:52 Done.
+ (float(self_time) / num_intervals) if num_intervals else 0
results.AddValue(scalar.ScalarValue(
results.current_page, ThreadDetailResultName(self.name, category),
'ms', self_time_result))
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 = \
rnephew (Reviews Here) 2015/04/23 18:28:05 Same
jdduke (slow) 2015/04/24 16:10:52 Done.
+ (float(idle_time) / num_intervals) if num_intervals else 0
results.AddValue(scalar.ScalarValue(
results.current_page, ThreadDetailResultName(self.name, "idle"),
'ms', idle_time_result))
@@ -235,19 +231,38 @@ class ResultsForThread(object):
count += 1
return count
+ def ThreadCpuTimeResultName(self, thread_category):
+ # This isn't a good name, but I don't want to change it and lose continuity.
+ if self.measure_per_frame:
+ return "thread_" + thread_category + "_cpu_time_per_frame"
+ return "thread_" + thread_category + "_cpu_time_total"
+
+ def ThreadTasksResultName(self, thread_category):
+ if self.measure_per_frame:
+ return "tasks_per_frame_" + thread_category
+ return "tasks_" + thread_category
+
+ def ThreadFrameTimeResultName(self, thread_category):
+ if self.measure_per_frame:
+ return "mean_frame_time_" + thread_category
+ return "total_frame_time_" + thread_category
+
+
class ThreadTimesTimelineMetric(timeline_based_metric.TimelineBasedMetric):
- def __init__(self):
+ def __init__(self, measure_per_frame=True):
super(ThreadTimesTimelineMetric, self).__init__()
# Minimal traces, for minimum noise in CPU-time measurements.
self.results_to_report = AllThreads
self.details_to_report = NoThreads
+ self.measure_per_frame = measure_per_frame
def AddResults(self, model, _, interaction_records, results):
# Set up each thread category for consistant results.
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,
rnephew (Reviews Here) 2015/04/23 18:28:05 nit: I know it was there before but it's under ind
jdduke (slow) 2015/04/24 16:10:52 Done.
+ self.measure_per_frame)
# Group the slices by their thread category.
for thread in model.GetAllThreads():
« no previous file with comments | « tools/perf/measurements/thread_times.py ('k') | tools/perf/page_sets/key_power_cases.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698