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

Unified Diff: tracing/tracing/metrics/media_metric.html

Issue 2996233004: Port a media metric to TBMv2 (Closed)
Patch Set: Created 3 years, 4 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 | « tracing/tracing/metrics/all_metrics.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/metrics/media_metric.html
diff --git a/tracing/tracing/metrics/media_metric.html b/tracing/tracing/metrics/media_metric.html
new file mode 100644
index 0000000000000000000000000000000000000000..37af6da6a4fe191e2fe862f0f63831740b958724
--- /dev/null
+++ b/tracing/tracing/metrics/media_metric.html
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<!--
+Copyright 2017 The Chromium Authors. All rights reserved.
+Use of this source code is governed by a BSD-style license that can be
+found in the LICENSE file.
CalebRouleau 2017/08/18 22:10:03 There should be overall description of what mediaM
charliea (OOO until 10-5) 2017/08/25 19:35:09 There's definitely a way to add an OWNERS file and
benjhayden 2017/08/28 17:40:15 +100, thank you!
johnchen 2017/08/29 22:45:46 Added comments about the purpose of this metric, w
+-->
+
+<link rel="import" href="/tracing/metrics/metric_registry.html">
+<link rel="import" href="/tracing/value/histogram.html">
+
+<script>
+'use strict';
+
+tr.exportTo('tr.metrics', function() {
+ function mediaMetric(histograms, model) {
+ let playStart;
+ let timeToPlay;
+
+ for (const event of model.getDescendantEvents()) {
benjhayden 2017/08/28 17:40:15 Metric performance doesn't matter terribly much wh
johnchen 2017/08/29 22:45:46 Modified the code to look for events in the render
+ if (event.title === 'EventDispatch') {
+ const type = event.args.data.type;
+ if (type === 'willPlay') {
CalebRouleau 2017/08/18 22:10:03 Discussed offline: maybe we should either use "wil
benjhayden 2017/08/28 17:40:15 This is a metric design question, which is mostly
+ playStart = event.start;
+ } else if (type === 'play' || type === 'loadedmetadata') {
+ if (playStart === undefined) {
+ playStart = event.start;
+ }
+ } else if (type === 'playing') {
+ if (playStart !== undefined && timeToPlay === undefined) {
+ timeToPlay = event.start - playStart;
nednguyen 2017/08/18 23:50:55 How can we be sure that these two events belong to
johnchen 2017/08/29 22:45:46 For now we only support one video on the page, tho
+ }
+ }
+ }
+ }
+
+ if (timeToPlay !== undefined) {
+ addTimeValue(histograms, 'time_to_play', timeToPlay);
CalebRouleau 2017/08/18 22:10:03 Is there at place where time_to_play is documented
charliea (OOO until 10-5) 2017/08/25 19:35:09 Yea - I agree with you in this, but I'm not sure t
johnchen 2017/08/29 22:45:46 Added comments in the file header.
+ }
+ }
+
+ function addTimeValue(histograms, name, value) {
benjhayden 2017/08/28 17:40:15 Instead of defining this helper function, please u
johnchen 2017/08/29 22:45:46 Done.
+ const hist = new tr.v.Histogram(name,
+ tr.b.Unit.byName.timeDurationInMs_smallerIsBetter);
+ hist.addSample(value);
+ histograms.addHistogram(hist);
+ }
+
+ tr.metrics.MetricRegistry.register(mediaMetric);
+
+ return {
+ mediaMetric,
+ };
+});
+</script>
« no previous file with comments | « tracing/tracing/metrics/all_metrics.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698