| OLD | NEW |
| 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/histogram_set.html"> |
| 11 | 11 |
| 12 <script> | 12 <script> |
| 13 'use strict'; | 13 'use strict'; |
| 14 | 14 |
| 15 tr.b.unittest.testSuite(function() { | 15 tr.b.unittest.testSuite(function() { |
| 16 test('timeToFirstContentfulPaint', function() { | 16 test('timeToFirstContentfulPaint', function() { |
| 17 var model = tr.c.TestUtils.newModel(function(model) { | 17 var model = tr.c.TestUtils.newModel(function(model) { |
| 18 var rendererProcess = model.getOrCreateProcess(1); | 18 var rendererProcess = model.getOrCreateProcess(1); |
| 19 var mainThread = rendererProcess.getOrCreateThread(2); | 19 var mainThread = rendererProcess.getOrCreateThread(2); |
| 20 mainThread.name = 'CrRendererMain'; | 20 mainThread.name = 'CrRendererMain'; |
| 21 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ | 21 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ |
| 22 cat: 'blink.user_timing', | 22 cat: 'blink.user_timing', |
| 23 title: 'navigationStart', | 23 title: 'navigationStart', |
| 24 start: 200, | 24 start: 200, |
| 25 duration: 0.0, | 25 duration: 0.0, |
| 26 args: {frame: '0xdeadbeef'} | 26 args: {frame: '0xdeadbeef'} |
| 27 })); | 27 })); |
| 28 rendererProcess.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300, | 28 rendererProcess.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300, |
| 29 {isLoadingMainFrame: true, frame: {id_ref: '0xdeadbeef'}, | 29 {isLoadingMainFrame: true, frame: {id_ref: '0xdeadbeef'}, |
| 30 documentLoaderURL: 'http://example.com'}); | 30 documentLoaderURL: 'http://example.com'}); |
| 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.HistogramSet(); |
| 40 tr.metrics.sh.loadingMetric(values, model); | 40 tr.metrics.sh.loadingMetric(values, model); |
| 41 var numeric = tr.b.getOnlyElement(values.getValuesNamed( | 41 var numeric = tr.b.getOnlyElement(values.getValuesNamed( |
| 42 'timeToFirstContentfulPaint')); | 42 'timeToFirstContentfulPaint')); |
| 43 assert.equal(1, numeric.running.count); | 43 assert.equal(1, numeric.running.count); |
| 44 assert.equal(800, numeric.running.mean); | 44 assert.equal(800, numeric.running.mean); |
| 45 }); | 45 }); |
| 46 | 46 |
| 47 test('timeToFirstContentfulPaintIgnoringWarmCache', function() { | 47 test('timeToFirstContentfulPaintIgnoringWarmCache', function() { |
| 48 var model = tr.c.TestUtils.newModel(function(model) { | 48 var model = tr.c.TestUtils.newModel(function(model) { |
| 49 var rendererProcess = model.getOrCreateProcess(1); | 49 var rendererProcess = model.getOrCreateProcess(1); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 {isLoadingMainFrame: true, frame: {id_ref: '0xdeadbeef'}, | 93 {isLoadingMainFrame: true, frame: {id_ref: '0xdeadbeef'}, |
| 94 documentLoaderURL: 'http://example.com'}); | 94 documentLoaderURL: 'http://example.com'}); |
| 95 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ | 95 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ |
| 96 cat: 'blink.user_timing,rail', | 96 cat: 'blink.user_timing,rail', |
| 97 title: 'firstContentfulPaint', | 97 title: 'firstContentfulPaint', |
| 98 start: 2400, | 98 start: 2400, |
| 99 duration: 0.0, | 99 duration: 0.0, |
| 100 args: {frame: '0xdeadbeef'} | 100 args: {frame: '0xdeadbeef'} |
| 101 })); | 101 })); |
| 102 }); | 102 }); |
| 103 var values = new tr.v.ValueSet(); | 103 var values = new tr.v.HistogramSet(); |
| 104 tr.metrics.sh.loadingMetric(values, model); | 104 tr.metrics.sh.loadingMetric(values, model); |
| 105 var numeric = tr.b.getOnlyElement(values.getValuesNamed( | 105 var numeric = tr.b.getOnlyElement(values.getValuesNamed( |
| 106 'timeToFirstContentfulPaint')); | 106 'timeToFirstContentfulPaint')); |
| 107 assert.equal(1, numeric.running.count); | 107 assert.equal(1, numeric.running.count); |
| 108 assert.equal(400, numeric.running.mean); | 108 assert.equal(400, numeric.running.mean); |
| 109 }); | 109 }); |
| 110 | 110 |
| 111 test('timeToFirstMeaningfulPaint', function() { | 111 test('timeToFirstMeaningfulPaint', function() { |
| 112 var model = tr.c.TestUtils.newModel(function(model) { | 112 var model = tr.c.TestUtils.newModel(function(model) { |
| 113 var rendererProcess = model.getOrCreateProcess(1); | 113 var rendererProcess = model.getOrCreateProcess(1); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 131 args: {frame: '0xdeadbeef'} | 131 args: {frame: '0xdeadbeef'} |
| 132 })); | 132 })); |
| 133 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ | 133 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ |
| 134 cat: 'loading', | 134 cat: 'loading', |
| 135 title: 'firstMeaningfulPaintCandidate', | 135 title: 'firstMeaningfulPaintCandidate', |
| 136 start: 1000, | 136 start: 1000, |
| 137 duration: 0.0, | 137 duration: 0.0, |
| 138 args: {frame: '0xdeadbeef'} | 138 args: {frame: '0xdeadbeef'} |
| 139 })); | 139 })); |
| 140 }); | 140 }); |
| 141 var values = new tr.v.ValueSet(); | 141 var values = new tr.v.HistogramSet(); |
| 142 tr.metrics.sh.loadingMetric(values, model); | 142 tr.metrics.sh.loadingMetric(values, model); |
| 143 var numeric = tr.b.getOnlyElement(values.getValuesNamed( | 143 var numeric = tr.b.getOnlyElement(values.getValuesNamed( |
| 144 'timeToFirstMeaningfulPaint')); | 144 'timeToFirstMeaningfulPaint')); |
| 145 assert.equal(1, numeric.running.count); | 145 assert.equal(1, numeric.running.count); |
| 146 assert.equal(800, numeric.running.mean); | 146 assert.equal(800, numeric.running.mean); |
| 147 }); | 147 }); |
| 148 | 148 |
| 149 test('timeToInteractive', function() { | 149 test('timeToInteractive', function() { |
| 150 // Our renderer thread would looks like | 150 // Our renderer thread would looks like |
| 151 // | 151 // |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 duration: 500, | 214 duration: 500, |
| 215 })); | 215 })); |
| 216 | 216 |
| 217 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ | 217 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ |
| 218 cat: 'toplevel', | 218 cat: 'toplevel', |
| 219 title: 'TaskQueueManager::ProcessTaskFromWorkQueue', | 219 title: 'TaskQueueManager::ProcessTaskFromWorkQueue', |
| 220 start: 22150, | 220 start: 22150, |
| 221 duration: 10, | 221 duration: 10, |
| 222 })); | 222 })); |
| 223 }); | 223 }); |
| 224 var values = new tr.v.ValueSet(); | 224 var values = new tr.v.HistogramSet(); |
| 225 tr.metrics.sh.loadingMetric(values, model); | 225 tr.metrics.sh.loadingMetric(values, model); |
| 226 var numeric = tr.b.getOnlyElement(values.getValuesNamed( | 226 var numeric = tr.b.getOnlyElement(values.getValuesNamed( |
| 227 'timeToFirstInteractive')); | 227 'timeToFirstInteractive')); |
| 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.allBins.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].get( | 232 var diagnostic = binsWithSampleDiagnosticMaps[0].diagnosticMaps[0].get( |
| 233 'Navigation infos'); | 233 'Navigation infos'); |
| 234 assert.equal(diagnostic.value.start, 200); | 234 assert.equal(diagnostic.value.start, 200); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 args: {frame: '0xdeadbeef'} | 319 args: {frame: '0xdeadbeef'} |
| 320 })); | 320 })); |
| 321 | 321 |
| 322 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ | 322 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ |
| 323 cat: 'toplevel', | 323 cat: 'toplevel', |
| 324 title: 'TaskQueueManager::ProcessTaskFromWorkQueue', | 324 title: 'TaskQueueManager::ProcessTaskFromWorkQueue', |
| 325 start: 29150, | 325 start: 29150, |
| 326 duration: 10, | 326 duration: 10, |
| 327 })); | 327 })); |
| 328 }); | 328 }); |
| 329 var values = new tr.v.ValueSet(); | 329 var values = new tr.v.HistogramSet(); |
| 330 tr.metrics.sh.loadingMetric(values, model); | 330 tr.metrics.sh.loadingMetric(values, model); |
| 331 var numeric = tr.b.getOnlyElement(values.getValuesNamed( | 331 var numeric = tr.b.getOnlyElement(values.getValuesNamed( |
| 332 'timeToFirstInteractive')); | 332 'timeToFirstInteractive')); |
| 333 assert.equal(2, numeric.running.count); | 333 assert.equal(2, numeric.running.count); |
| 334 assert.equal(4000, numeric.running.min); | 334 assert.equal(4000, numeric.running.min); |
| 335 assert.equal(15200, numeric.running.max); | 335 assert.equal(15200, numeric.running.max); |
| 336 }); | 336 }); |
| 337 }); | 337 }); |
| 338 </script> | 338 </script> |
| OLD | NEW |