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

Side by Side Diff: tracing/tracing/metrics/system_health/loading_metric_test.html

Issue 2334233003: Merge NumericValue into Histogram (Closed)
Patch Set: fix rail_power_metric Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright (c) 2016 The Chromium Authors. All rights reserved. 3 Copyright (c) 2016 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 7
8 <link rel="import" href="/tracing/core/test_utils.html"> 8 <link rel="import" href="/tracing/core/test_utils.html">
9 <link rel="import" href="/tracing/metrics/system_health/loading_metric.html"> 9 <link rel="import" href="/tracing/metrics/system_health/loading_metric.html">
10 <link rel="import" href="/tracing/value/value_set.html"> 10 <link rel="import" href="/tracing/value/value_set.html">
(...skipping 20 matching lines...) Expand all
31 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 31 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
32 cat: 'blink.user_timing,rail', 32 cat: 'blink.user_timing,rail',
33 title: 'firstContentfulPaint', 33 title: 'firstContentfulPaint',
34 start: 1000, 34 start: 1000,
35 duration: 0.0, 35 duration: 0.0,
36 args: {frame: '0xdeadbeef'} 36 args: {frame: '0xdeadbeef'}
37 })); 37 }));
38 }); 38 });
39 var values = new tr.v.ValueSet(); 39 var values = new tr.v.ValueSet();
40 tr.metrics.sh.loadingMetric(values, model); 40 tr.metrics.sh.loadingMetric(values, model);
41 var numeric = values.valueDicts[0].numeric; 41 var numeric = tr.b.getOnlyElement(values.getValuesNamed(
42 'timeToFirstContentfulPaint'));
42 assert.equal(1, numeric.running.count); 43 assert.equal(1, numeric.running.count);
43 assert.equal(800, numeric.running.mean); 44 assert.equal(800, numeric.running.mean);
44 }); 45 });
45 46
46 test('timeToFirstContentfulPaintIgnoringWarmCache', function() { 47 test('timeToFirstContentfulPaintIgnoringWarmCache', function() {
47 var model = tr.c.TestUtils.newModel(function(model) { 48 var model = tr.c.TestUtils.newModel(function(model) {
48 var rendererProcess = model.getOrCreateProcess(1); 49 var rendererProcess = model.getOrCreateProcess(1);
49 var mainThread = rendererProcess.getOrCreateThread(2); 50 var mainThread = rendererProcess.getOrCreateThread(2);
50 mainThread.name = 'CrRendererMain'; 51 mainThread.name = 'CrRendererMain';
51 52
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 95 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
95 cat: 'blink.user_timing,rail', 96 cat: 'blink.user_timing,rail',
96 title: 'firstContentfulPaint', 97 title: 'firstContentfulPaint',
97 start: 2400, 98 start: 2400,
98 duration: 0.0, 99 duration: 0.0,
99 args: {frame: '0xdeadbeef'} 100 args: {frame: '0xdeadbeef'}
100 })); 101 }));
101 }); 102 });
102 var values = new tr.v.ValueSet(); 103 var values = new tr.v.ValueSet();
103 tr.metrics.sh.loadingMetric(values, model); 104 tr.metrics.sh.loadingMetric(values, model);
104 var numeric = values.valueDicts[0].numeric; 105 var numeric = tr.b.getOnlyElement(values.getValuesNamed(
106 'timeToFirstContentfulPaint'));
105 assert.equal(1, numeric.running.count); 107 assert.equal(1, numeric.running.count);
106 assert.equal(400, numeric.running.mean); 108 assert.equal(400, numeric.running.mean);
107 }); 109 });
108 110
109 test('timeToFirstMeaningfulPaint', function() { 111 test('timeToFirstMeaningfulPaint', function() {
110 var model = tr.c.TestUtils.newModel(function(model) { 112 var model = tr.c.TestUtils.newModel(function(model) {
111 var rendererProcess = model.getOrCreateProcess(1); 113 var rendererProcess = model.getOrCreateProcess(1);
112 var mainThread = rendererProcess.getOrCreateThread(2); 114 var mainThread = rendererProcess.getOrCreateThread(2);
113 mainThread.name = 'CrRendererMain'; 115 mainThread.name = 'CrRendererMain';
114 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 116 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
(...skipping 16 matching lines...) Expand all
131 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 133 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
132 cat: 'loading', 134 cat: 'loading',
133 title: 'firstMeaningfulPaintCandidate', 135 title: 'firstMeaningfulPaintCandidate',
134 start: 1000, 136 start: 1000,
135 duration: 0.0, 137 duration: 0.0,
136 args: {frame: '0xdeadbeef'} 138 args: {frame: '0xdeadbeef'}
137 })); 139 }));
138 }); 140 });
139 var values = new tr.v.ValueSet(); 141 var values = new tr.v.ValueSet();
140 tr.metrics.sh.loadingMetric(values, model); 142 tr.metrics.sh.loadingMetric(values, model);
141 var ttfmpEntries = values.valueDicts.filter( 143 var numeric = tr.b.getOnlyElement(values.getValuesNamed(
142 (dict) => dict.name === 'timeToFirstMeaningfulPaint'); 144 'timeToFirstMeaningfulPaint'));
143 var numeric = ttfmpEntries[0].numeric;
144 assert.equal(1, numeric.running.count); 145 assert.equal(1, numeric.running.count);
145 assert.equal(800, numeric.running.mean); 146 assert.equal(800, numeric.running.mean);
146 }); 147 });
147 148
148 test('timeToInteractive', function() { 149 test('timeToInteractive', function() {
149 // Our renderer thread would looks like 150 // Our renderer thread would looks like
150 // 151 //
151 // * * [ main thread busy ] * 152 // * * [ main thread busy ] *
152 // | | | 153 // | | |
153 // | | | 154 // | | |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 216
216 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 217 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
217 cat: 'toplevel', 218 cat: 'toplevel',
218 title: 'TaskQueueManager::ProcessTaskFromWorkQueue', 219 title: 'TaskQueueManager::ProcessTaskFromWorkQueue',
219 start: 22150, 220 start: 22150,
220 duration: 10, 221 duration: 10,
221 })); 222 }));
222 }); 223 });
223 var values = new tr.v.ValueSet(); 224 var values = new tr.v.ValueSet();
224 tr.metrics.sh.loadingMetric(values, model); 225 tr.metrics.sh.loadingMetric(values, model);
225 var ttiEntries = values.valueDicts.filter( 226 var numeric = tr.b.getOnlyElement(values.getValuesNamed(
226 (dict) => dict.name === 'timeToFirstInteractive'); 227 'timeToFirstInteractive'));
227 var numeric = ttiEntries[0].numeric;
228 assert.equal(1, numeric.running.count); 228 assert.equal(1, numeric.running.count);
229 assert.equal(15200, numeric.running.mean); 229 assert.equal(15200, numeric.running.mean);
230 var binsWithSampleDiagnosticMaps = numeric.centralBins.filter( 230 var binsWithSampleDiagnosticMaps = numeric.allBins.filter(
231 (bin) => bin.diagnosticMaps.length > 0); 231 bin => bin.diagnosticMaps.length > 0);
232 var diagnostic = binsWithSampleDiagnosticMaps[0].diagnosticMaps[0][ 232 var diagnostic = binsWithSampleDiagnosticMaps[0].diagnosticMaps[0].get(
233 'Navigation infos']; 233 'Navigation infos');
234 assert.equal(diagnostic.value.start, 200);
235 assert.equal(diagnostic.value.interactive, 15400);
234 assert.equal(diagnostic.value.pid, 1984); 236 assert.equal(diagnostic.value.pid, 1984);
235 }); 237 });
236 238
237 test('multiTimeToInteractive', function() { 239 test('multiTimeToInteractive', function() {
238 // Our renderer thread would looks like 240 // Our renderer thread would looks like
239 // 241 //
240 // * * [ main thread busy ] * * * 242 // * * [ main thread busy ] * * *
241 // | | | | | 243 // | | | | |
242 // | | | | | 244 // | | | | |
243 // v v v v v 245 // v v v v v
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 321
320 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ 322 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
321 cat: 'toplevel', 323 cat: 'toplevel',
322 title: 'TaskQueueManager::ProcessTaskFromWorkQueue', 324 title: 'TaskQueueManager::ProcessTaskFromWorkQueue',
323 start: 29150, 325 start: 29150,
324 duration: 10, 326 duration: 10,
325 })); 327 }));
326 }); 328 });
327 var values = new tr.v.ValueSet(); 329 var values = new tr.v.ValueSet();
328 tr.metrics.sh.loadingMetric(values, model); 330 tr.metrics.sh.loadingMetric(values, model);
329 var ttiEntries = values.valueDicts.filter( 331 var numeric = tr.b.getOnlyElement(values.getValuesNamed(
330 (dict) => dict.name === 'timeToFirstInteractive'); 332 'timeToFirstInteractive'));
331 var numeric = ttiEntries[0].numeric;
332 assert.equal(2, numeric.running.count); 333 assert.equal(2, numeric.running.count);
333 assert.equal(4000, numeric.running.min); 334 assert.equal(4000, numeric.running.min);
334 assert.equal(15200, numeric.running.max); 335 assert.equal(15200, numeric.running.max);
335 }); 336 });
336 }); 337 });
337 </script> 338 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698