Chromium Code Reviews| Index: tools/perf/metrics/timeline.py |
| diff --git a/tools/perf/metrics/timeline.py b/tools/perf/metrics/timeline.py |
| index 19db3d59ad1985c1cebcc645f45719e60ae55cb0..6255285a61432832fb7d2171c2fece2ca288d61b 100644 |
| --- a/tools/perf/metrics/timeline.py |
| +++ b/tools/perf/metrics/timeline.py |
| @@ -84,6 +84,12 @@ TimelineThreadCategories = { |
| "DummyThreadName3" : "total_all" |
| } |
| +# Normalizing cpu-time by different rates might get confusing, but we could |
| +# report different frame-rates by adding their associated trace here. |
|
ernstm
2014/10/11 00:24:22
Why add this if we don't use it? You could instead
epenner
2014/10/13 22:20:32
Ahh, yeah my original goal was to remove those oth
|
| +ThreadFrameTraceName = { |
| + "renderer_compositor": "::SwapBuffers", |
| +} |
| + |
| _MatchBySubString = ["IOThread", "CompositorRasterWorker"] |
| AllThreads = TimelineThreadCategories.values() |
| @@ -103,6 +109,8 @@ OverheadTraceName = "overhead" |
| FrameTraceName = "::SwapBuffers" |
| FrameTraceThreadName = "renderer_compositor" |
| +def Rate(numerator, denominator): |
|
ernstm
2014/10/11 00:24:22
We have telmetry.util.statistics.DivideIfPossibleO
epenner
2014/10/13 22:20:32
That doesn't cast to float. If you think I can cha
ernstm
2014/10/14 17:06:11
Please change DivideIfPossibleOrZero to cast to fl
|
| + return (float(numerator) / denominator) if denominator else 0 |
| def ClockOverheadForEvent(event): |
| if (event.category == OverheadTraceCategory and |
| @@ -127,12 +135,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 name sucks but I don't want to change it and lose continuity |
|
ernstm
2014/10/11 00:24:22
Metrics can be migrated to new names on the dashbo
epenner
2014/10/13 22:20:32
That sounds cool. Got some documentation on that?
ernstm
2014/10/14 17:06:11
qyearsley can help with the data migration. It is
epenner
2014/10/18 01:02:30
Acknowledged.
|
| return "thread_" + thread_category + "_cpu_time_per_frame" |
| +def ThreadTasksResultName(thread_category): |
| + return "tasks_per_frame_" + thread_category |
| + |
| +def ThreadFpsResultName(thread_category): |
| + return "fps_" + thread_category |
| + |
| def ThreadDetailResultName(thread_category, detail): |
| detail_sanitized = detail.replace('.','_') |
| return "thread_" + thread_category + "|" + detail_sanitized |
| @@ -145,6 +157,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 +196,23 @@ 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 frame rate (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)) |
| + if self.name in ThreadFrameTraceName: |
| + num_frames = self.CountTracesWithName(ThreadFrameTraceName[self.name]) |
| + frame_rate = Rate(num_frames, self.all_action_time) * 1000 |
| + results.AddValue(scalar.ScalarValue( |
| + results.current_page, ThreadFpsResultName(self.name), |
| + 'fps', frame_rate)) |
| def AddDetailedResults(self, num_frames, results): |
| slices_by_category = collections.defaultdict(list) |
| @@ -201,14 +227,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 +247,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 = {} |
| @@ -245,9 +268,9 @@ 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. |
| - frame_slices = thread_category_results[FrameTraceThreadName].all_slices |
| - num_frames = self.CountSlices(frame_slices, FrameTraceName) |
| + # Calculate the number of frames / frame-rate. |
| + 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(): |