blob: 7d47baf0d9cb871b4ff38874470c57754d15e6dc [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright 2016 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.
-->
<link rel="import" href="/tracing/metrics/metric_registry.html">
<link rel="import" href="/tracing/metrics/system_health/utils.html">
<link rel="import" href="/tracing/value/histogram.html">
<script>
'use strict';
tr.exportTo('tr.metrics.sh', function() {
function webviewStartupMetric(values, model) {
var startupWallHist = new tr.v.Histogram('webview_startup_wall_time',
tr.b.Unit.byName.timeDurationInMs_smallerIsBetter);
startupWallHist.description = 'WebView startup wall time';
var startupCPUHist = new tr.v.Histogram('webview_startup_cpu_time',
tr.b.Unit.byName.timeDurationInMs_smallerIsBetter);
startupCPUHist.description = 'WebView startup CPU time';
var loadWallHist = new tr.v.Histogram('webview_url_load_wall_time',
tr.b.Unit.byName.timeDurationInMs_smallerIsBetter);
loadWallHist.description = 'WebView blank URL load wall time';
var loadCPUHist = new tr.v.Histogram('webview_url_load_cpu_time',
tr.b.Unit.byName.timeDurationInMs_smallerIsBetter);
loadCPUHist.description = 'WebView blank URL load CPU time';
// TODO(alexandermont): Only iterate over the processes and threads that
// could contain these events.
for (var slice of model.getDescendantEvents()) {
if (!(slice instanceof tr.model.ThreadSlice))
continue;
// WebViewStartupInterval is the title of the section of code that is
// entered (via android.os.Trace.beginSection) when WebView is started
// up. This value is defined in TelemetryActivity.java.
if (slice.title === 'WebViewStartupInterval') {
startupWallHist.addSample(slice.duration);
startupCPUHist.addSample(slice.cpuDuration);
}
// WebViewBlankUrlLoadInterval is the title of the section of code
// that is entered (via android.os.Trace.beginSection) when WebView
// is started up. This value is defined in TelemetryActivity.java.
if (slice.title === 'WebViewBlankUrlLoadInterval') {
loadWallHist.addSample(slice.duration);
loadCPUHist.addSample(slice.cpuDuration);
}
}
values.addHistogram(startupWallHist);
values.addHistogram(startupCPUHist);
values.addHistogram(loadWallHist);
values.addHistogram(loadCPUHist);
}
tr.metrics.MetricRegistry.register(webviewStartupMetric);
return {
webviewStartupMetric: webviewStartupMetric
};
});
</script>