summaryrefslogtreecommitdiff
path: root/chromium/third_party/catapult/tracing/tracing/metrics/system_health/long_tasks_metric_test.html
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/catapult/tracing/tracing/metrics/system_health/long_tasks_metric_test.html')
-rw-r--r--chromium/third_party/catapult/tracing/tracing/metrics/system_health/long_tasks_metric_test.html113
1 files changed, 113 insertions, 0 deletions
diff --git a/chromium/third_party/catapult/tracing/tracing/metrics/system_health/long_tasks_metric_test.html b/chromium/third_party/catapult/tracing/tracing/metrics/system_health/long_tasks_metric_test.html
new file mode 100644
index 00000000000..60872ad5c6f
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/tracing/metrics/system_health/long_tasks_metric_test.html
@@ -0,0 +1,113 @@
+<!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/core/test_utils.html">
+<link rel="import" href="/tracing/extras/chrome/chrome_user_friendly_category_driver.html">
+<link rel="import" href="/tracing/metrics/system_health/long_tasks_metric.html">
+<link rel="import" href="/tracing/value/value_set.html">
+
+<script>
+'use strict';
+
+tr.b.unittest.testSuite(function() {
+ test('longTasksMetric', function() {
+ var model = tr.c.TestUtils.newModel(function(model) {
+ var proc = model.getOrCreateProcess(1);
+ var thread = proc.getOrCreateThread(2);
+ thread.name = 'CrRendererMain';
+ var longTask = tr.c.TestUtils.newSliceEx({
+ title: 'foo',
+ start: 0,
+ duration: 50,
+ });
+ thread.sliceGroup.pushSlice(longTask);
+
+ thread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ title: 'UpdateLayerTree',
+ start: 0,
+ duration: 1,
+ cpuStart: 0,
+ cpuDuration: 1,
+ }));
+
+ thread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ title: 'minorGC',
+ start: 1,
+ duration: 1,
+ cpuStart: 1,
+ cpuDuration: 1,
+ }));
+
+ thread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ title: 'Decode Image',
+ start: 2,
+ duration: 1,
+ cpuStart: 2,
+ cpuDuration: 1,
+ }));
+
+ thread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ title: 'Layout',
+ start: 3,
+ duration: 1,
+ cpuStart: 3,
+ cpuDuration: 1,
+ }));
+
+ model.addUserFriendlyCategoryDriver(
+ tr.e.chrome.ChromeUserFriendlyCategoryDriver);
+ });
+ var valueSet = new tr.v.ValueSet();
+ tr.metrics.sh.longTasksMetric(valueSet, model);
+ var longTaskHist = tr.b.getOnlyElement(
+ valueSet.getValuesNamed('long tasks'));
+ assert.strictEqual(1, longTaskHist.numValues);
+ assert.strictEqual(1, longTaskHist.centralBins[0].count);
+ assert.lengthOf(longTaskHist.centralBins[0].diagnosticMaps, 1);
+ var events =
+ longTaskHist.centralBins[0].diagnosticMaps[0].get('relatedEvents');
+ assert.instanceOf(events, tr.v.d.RelatedEventSet);
+ assert.strictEqual(tr.b.getOnlyElement(events).title,
+ 'foo');
+ var breakdown = longTaskHist.diagnostics.get('category');
+ assert.instanceOf(breakdown, tr.v.d.RelatedHistogramBreakdown);
+ assert.lengthOf(breakdown, 4);
+
+ var hist = breakdown.get('layout');
+ assert.instanceOf(hist, tr.v.Histogram);
+ assert.strictEqual(tr.b.getOnlyElement(valueSet.getValuesNamed(hist.name)),
+ hist);
+ assert.strictEqual(0, hist.name.indexOf(longTaskHist.name));
+ assert.strictEqual(1, hist.numValues);
+ assert.strictEqual(1, hist.centralBins[0].count);
+
+ hist = breakdown.get('gc');
+ assert.instanceOf(hist, tr.v.Histogram);
+ assert.strictEqual(tr.b.getOnlyElement(valueSet.getValuesNamed(hist.name)),
+ hist);
+ assert.strictEqual(0, hist.name.indexOf(longTaskHist.name));
+ assert.strictEqual(1, hist.numValues);
+ assert.strictEqual(1, hist.centralBins[0].count);
+
+ hist = breakdown.get('composite');
+ assert.instanceOf(hist, tr.v.Histogram);
+ assert.strictEqual(tr.b.getOnlyElement(valueSet.getValuesNamed(hist.name)),
+ hist);
+ assert.strictEqual(0, hist.name.indexOf(longTaskHist.name));
+ assert.strictEqual(1, hist.numValues);
+ assert.strictEqual(1, hist.centralBins[0].count);
+
+ hist = breakdown.get('imageDecode');
+ assert.instanceOf(hist, tr.v.Histogram);
+ assert.strictEqual(tr.b.getOnlyElement(valueSet.getValuesNamed(hist.name)),
+ hist);
+ assert.strictEqual(0, hist.name.indexOf(longTaskHist.name));
+ assert.strictEqual(1, hist.numValues);
+ assert.strictEqual(1, hist.centralBins[0].count);
+ });
+});
+</script>