| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <!-- | 2 <!-- |
| 3 Copyright (c) 2015 The Chromium Authors. All rights reserved. | 3 Copyright (c) 2015 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" | 9 <link rel="import" |
| 10 href="/tracing/metrics/system_health/hazard_metric.html"> | 10 href="/tracing/metrics/system_health/hazard_metric.html"> |
| 11 <link rel="import" href="/tracing/value/value_set.html"> | 11 <link rel="import" href="/tracing/value/histogram_set.html"> |
| 12 | 12 |
| 13 <script> | 13 <script> |
| 14 'use strict'; | 14 'use strict'; |
| 15 | 15 |
| 16 tr.b.unittest.testSuite(function() { | 16 tr.b.unittest.testSuite(function() { |
| 17 function computeHazardValue(customizeModelCallback) { | 17 function computeHazardValue(customizeModelCallback) { |
| 18 var model = tr.c.TestUtils.newModel(function(model) { | 18 var model = tr.c.TestUtils.newModel(function(model) { |
| 19 model.rendererProcess = model.getOrCreateProcess(2); | 19 model.rendererProcess = model.getOrCreateProcess(2); |
| 20 model.rendererMain = model.rendererProcess.getOrCreateThread(3); | 20 model.rendererMain = model.rendererProcess.getOrCreateThread(3); |
| 21 model.rendererMain.name = 'CrRendererMain'; | 21 model.rendererMain.name = 'CrRendererMain'; |
| 22 | 22 |
| 23 customizeModelCallback(model); | 23 customizeModelCallback(model); |
| 24 }); | 24 }); |
| 25 var values = new tr.v.ValueSet(); | 25 var values = new tr.v.HistogramSet(); |
| 26 tr.metrics.sh.hazardMetric(values, model); | 26 tr.metrics.sh.hazardMetric(values, model); |
| 27 return tr.b.getOnlyElement(values); | 27 return tr.b.getOnlyElement(values); |
| 28 } | 28 } |
| 29 | 29 |
| 30 test('minimalHazard', function() { | 30 test('minimalHazard', function() { |
| 31 var duration = 50 + 1e-4; | 31 var duration = 50 + 1e-4; |
| 32 var value = computeHazardValue(function(model) { | 32 var value = computeHazardValue(function(model) { |
| 33 model.rendererMain.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ | 33 model.rendererMain.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ |
| 34 type: tr.model.ThreadSlice, | 34 type: tr.model.ThreadSlice, |
| 35 isTopLevel: true, | 35 isTopLevel: true, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 type: tr.model.ThreadSlice, | 77 type: tr.model.ThreadSlice, |
| 78 isTopLevel: true, | 78 isTopLevel: true, |
| 79 start: 0, | 79 start: 0, |
| 80 duration: 400 | 80 duration: 400 |
| 81 })); | 81 })); |
| 82 }); | 82 }); |
| 83 assert.closeTo(0.92144, value.average, 1e-4); | 83 assert.closeTo(0.92144, value.average, 1e-4); |
| 84 }); | 84 }); |
| 85 }); | 85 }); |
| 86 </script> | 86 </script> |
| OLD | NEW |