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

Unified Diff: tools/telemetry/telemetry/web_perf/metrics/mainthread_jank.py

Issue 273103003: Add responsiveness_metric for timeline_based_measurement (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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
Index: tools/telemetry/telemetry/web_perf/metrics/mainthread_jank.py
diff --git a/tools/telemetry/telemetry/web_perf/metrics/mainthread_jank.py b/tools/telemetry/telemetry/web_perf/metrics/mainthread_jank.py
new file mode 100644
index 0000000000000000000000000000000000000000..4fc905dd6cc2cedd5958abb157053abeaef9618a
--- /dev/null
+++ b/tools/telemetry/telemetry/web_perf/metrics/mainthread_jank.py
@@ -0,0 +1,61 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
chrishenry 2014/05/13 03:22:38 nit: Filename should probably be main_thread_jank
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from telemetry.web_perf.metrics import timeline_based_metric
+
+
+PERCEIVABLE_DELAY_MS = 50
chrishenry 2014/05/13 03:22:38 Please doc this. Maybe name it as USER_PERCEIVABLE
nednguyen 2014/05/14 17:32:27 Done.
+
+
+class _MainThreadJankStat(object):
+ def __init__(self):
+ self.sum_top_slices_thread_time = 0
chrishenry 2014/05/13 03:22:38 Hm, slightly inconsistent. We seem to use top slic
nednguyen 2014/05/14 17:32:27 Done.
+ # slices whose overlapped duration that is more than PERCEIVABLE_DELAY_MS
+ self.num_big_top_slices = 0
+ self.sum_big_top_slices_thread_time = 0
+ self.biggest_top_slice_thread_time = 0
chrishenry 2014/05/13 03:22:38 Document each of this stats (if not here, somewher
+
+def _ComputeMainThreadJankStats(renderer_thread, thread_start, thread_end):
+ stat = _MainThreadJankStat()
+ for s in renderer_thread.IterAllSlicesOverlappedWithThreadTimeRange(
chrishenry 2014/05/13 03:22:38 Can you explain again as to the difference between
nednguyen 2014/05/14 17:32:27 Since what happens outside of the browser is uncon
chrishenry 2014/05/19 23:16:50 Ok, I agree.
+ thread_start, thread_end):
chrishenry 2014/05/13 03:22:38 4-col indent.
nednguyen 2014/05/14 17:32:27 Done. Just realize that my vim indent for python w
+ if not s.IsTopMessageLoop():
chrishenry 2014/05/13 03:22:38 Btw, maybe this should be a static function instea
nednguyen 2014/05/14 17:32:27 Done.
+ continue
+ jank_thread_duration = s.GetOverlappedThreadTimeDurationWithRange(
chrishenry 2014/05/13 03:22:38 Question on thread_time/thread_end applies here to
nednguyen 2014/05/14 17:32:27 Done.
+ thread_start, thread_end)
+ stat.sum_top_slices_thread_time += jank_thread_duration
+ stat.biggest_top_slice_thread_time = max(
+ stat.biggest_top_slice_thread_time, jank_thread_duration)
+ if jank_thread_duration > PERCEIVABLE_DELAY_MS:
+ stat.num_big_top_slices += 1
+ stat.sum_big_top_slices_thread_time += jank_thread_duration
+ return stat
+
+
+class MainthreadJankMetric(timeline_based_metric.TimelineBasedMetric):
chrishenry 2014/05/13 03:22:38 This is inconsistent, above you use MainThread, an
nednguyen 2014/05/14 17:32:27 Picked Mainthread.
+ def __init__(self):
+ super(MainthreadJankMetric, self).__init__()
+
+ def AddResults(self, _, renderer_thread, interaction_records, results):
+ self.VerifyNonOverlappedRecords(interaction_records)
chrishenry 2014/05/13 03:22:38 Why must the records be non-overlapping? Shouldn't
nednguyen 2014/05/14 17:32:27 This is supposed to return a summarized results fo
+ num_big_janks = 0
+ total_jank_thread_time = 0
+ total_big_jank_thread_time = 0
+ biggest_jank_thread_time = 0
+
+ for record in interaction_records:
+ record_jank_stat = _ComputeMainThreadJankStats(
+ renderer_thread, record.thread_start, record.thread_end)
chrishenry 2014/05/13 03:22:38 4-col hanging indent, same everywhere below too.
chrishenry 2014/05/13 03:22:38 renderer_thread isn't documented even in the base
nednguyen 2014/05/14 17:32:27 Ok. Will escalate this to Nat, who knows about thi
+ num_big_janks += record_jank_stat.num_big_top_slices
+ total_jank_thread_time += record_jank_stat.sum_top_slices_thread_time
+ total_big_jank_thread_time += (
+ record_jank_stat.sum_big_top_slices_thread_time)
+ biggest_jank_thread_time = (
+ max(biggest_jank_thread_time,
+ record_jank_stat.biggest_top_slice_thread_time))
+
+ results.Add('num_big_janks', 'score', num_big_janks)
+ results.Add('total_jank_thread_time', 'ms', total_jank_thread_time)
+ results.Add('total_big_jank_thread_time', 'ms', total_big_jank_thread_time)
+ results.Add('biggest_jank_thread_time', 'ms', biggest_jank_thread_time)

Powered by Google App Engine
This is Rietveld 408576698