Index: tools/perf/metrics/timeline.py |
diff --git a/tools/perf/metrics/timeline.py b/tools/perf/metrics/timeline.py |
index 19db3d59ad1985c1cebcc645f45719e60ae55cb0..32e675ac146b5b1f0d78fe7f092d2e68aa62ea6a 100644 |
--- a/tools/perf/metrics/timeline.py |
+++ b/tools/perf/metrics/timeline.py |
@@ -103,6 +103,8 @@ OverheadTraceName = "overhead" |
FrameTraceName = "::SwapBuffers" |
FrameTraceThreadName = "renderer_compositor" |
+def Rate(numerator, denominator): |
+ return (float(numerator) / denominator) if denominator else 0 |
def ClockOverheadForEvent(event): |
if (event.category == OverheadTraceCategory and |
@@ -127,12 +129,16 @@ def ThreadCategoryName(thread_name): |
thread_category = TimelineThreadCategories[thread_name] |
return thread_category |
-def ThreadTimeResultName(thread_category): |
- return "thread_" + thread_category + "_clock_time_per_frame" |
- |
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 ThreadMeanFrameResultName(thread_category): |
ernstm
2014/10/14 17:06:11
I would rename this to ThreadMeanFrameTimeResultNa
epenner
2014/10/18 01:02:30
Done.
|
+ return "mean_frame_time_" + thread_category |
+ |
def ThreadDetailResultName(thread_category, detail): |
detail_sanitized = detail.replace('.','_') |
return "thread_" + thread_category + "|" + detail_sanitized |
@@ -145,6 +151,8 @@ class ResultsForThread(object): |
self.all_slices = [] |
self.name = name |
self.record_ranges = record_ranges |
+ self.all_action_time = \ |
+ sum([record_range.bounds for record_range in self.record_ranges]) |
@property |
def clock_time(self): |
@@ -182,11 +190,26 @@ 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 = (float(self.cpu_time) / num_frames) if num_frames else 0 |
+ cpu_per_frame = Rate(self.cpu_time, num_frames) |
+ tasks_per_frame = Rate(len(self.toplevel_slices), num_frames) |
results.AddValue(scalar.ScalarValue( |
results.current_page, ThreadCpuTimeResultName(self.name), |
'ms', cpu_per_frame)) |
+ results.AddValue(scalar.ScalarValue( |
+ results.current_page, ThreadTasksResultName(self.name), |
+ 'tasks', tasks_per_frame)) |
+ # 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 = Rate(self.all_action_time, num_frames) |
ernstm
2014/10/14 17:06:11
mean_frame -> mean_frame_time
epenner
2014/10/18 01:02:30
Done.
|
+ results.AddValue(scalar.ScalarValue( |
+ results.current_page, ThreadMeanFrameResultName(self.name), |
+ 'ms', mean_frame)) |
def AddDetailedResults(self, num_frames, results): |
slices_by_category = collections.defaultdict(list) |
@@ -201,14 +224,18 @@ class ResultsForThread(object): |
results.current_page, ThreadDetailResultName(self.name, category), |
'ms', self_time_result)) |
all_measured_time = sum(all_self_times) |
- all_action_time = \ |
- sum([record_range.bounds for record_range in self.record_ranges]) |
- idle_time = max(0, all_action_time - all_measured_time) |
+ idle_time = max(0, self.all_action_time - all_measured_time) |
idle_time_result = (float(idle_time) / num_frames) if num_frames else 0 |
results.AddValue(scalar.ScalarValue( |
results.current_page, ThreadDetailResultName(self.name, "idle"), |
'ms', idle_time_result)) |
+ def CountTracesWithName(self, substring): |
+ count = 0 |
+ for event in self.all_slices: |
+ if substring in event.name: |
+ count += 1 |
+ return count |
class ThreadTimesTimelineMetric(timeline_based_metric.TimelineBasedMetric): |
def __init__(self): |
@@ -217,13 +244,6 @@ class ThreadTimesTimelineMetric(timeline_based_metric.TimelineBasedMetric): |
self.results_to_report = AllThreads |
self.details_to_report = NoThreads |
- def CountSlices(self, slices, substring): |
- count = 0 |
- for event in slices: |
- if substring in event.name: |
- count += 1 |
- return count |
- |
def AddResults(self, model, _, interaction_records, results): |
# Set up each thread category for consistant results. |
thread_category_results = {} |
@@ -246,8 +266,8 @@ class ThreadTimesTimelineMetric(timeline_based_metric.TimelineBasedMetric): |
thread_category_results['total_fast_path'].AppendThreadSlices(thread) |
# Calculate the number of frames. |
- frame_slices = thread_category_results[FrameTraceThreadName].all_slices |
- num_frames = self.CountSlices(frame_slices, FrameTraceName) |
+ 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(): |