| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <!-- | 2 <!-- |
| 3 Copyright 2016 The Chromium Authors. All rights reserved. | 3 Copyright 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/metrics/v8/utils.html"> | 9 <link rel="import" href="/tracing/metrics/v8/utils.html"> |
| 10 <link rel="import" href="/tracing/model/memory_dump_test_utils.html"> |
| 9 | 11 |
| 10 <script> | 12 <script> |
| 11 'use strict'; | 13 'use strict'; |
| 12 | 14 |
| 13 tr.b.unittest.testSuite(function() { | 15 tr.b.unittest.testSuite(function() { |
| 14 | 16 |
| 15 var unionOfIntervals = tr.metrics.v8.utils.unionOfIntervals; | 17 var unionOfIntervals = tr.metrics.v8.utils.unionOfIntervals; |
| 16 | 18 |
| 17 function interval(start, end) { | 19 function interval(start, end) { |
| 18 return {start: start, end: end}; | 20 return {start: start, end: end}; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 interval(80, 88)]; | 136 interval(80, 88)]; |
| 135 actual = tr.metrics.v8.utils.mutatorUtilization(0, 100, 7, pauses); | 137 actual = tr.metrics.v8.utils.mutatorUtilization(0, 100, 7, pauses); |
| 136 expected = mutatorUtilizationSlow(0, 100, 7, pauses); | 138 expected = mutatorUtilizationSlow(0, 100, 7, pauses); |
| 137 assert.closeTo(expected.average, actual.average, 1e-3); | 139 assert.closeTo(expected.average, actual.average, 1e-3); |
| 138 assert.closeTo(expected.max, actual.max, 1e-3); | 140 assert.closeTo(expected.max, actual.max, 1e-3); |
| 139 assert.closeTo(expected.min, actual.min, 1e-3); | 141 assert.closeTo(expected.min, actual.min, 1e-3); |
| 140 assert.closeTo(expected.percentile(0.5), actual.percentile(0.5), 1e-3); | 142 assert.closeTo(expected.percentile(0.5), actual.percentile(0.5), 1e-3); |
| 141 assert.closeTo(expected.percentile(0.9), actual.percentile(0.9), 1e-3); | 143 assert.closeTo(expected.percentile(0.9), actual.percentile(0.9), 1e-3); |
| 142 }); | 144 }); |
| 143 | 145 |
| 146 function addDumpWithAllocator(model, process, allocator, start) { |
| 147 var gmd = tr.model.MemoryDumpTestUtils.addGlobalMemoryDump( |
| 148 model, {ts: start}); |
| 149 var pmd = tr.model.MemoryDumpTestUtils.addProcessMemoryDump(gmd, process); |
| 150 pmd.memoryAllocatorDumps = |
| 151 [tr.model.MemoryDumpTestUtils.newAllocatorDump(pmd, allocator)]; |
| 152 } |
| 153 |
| 154 test('rangeForMemoryDumps', function() { |
| 155 var model = tr.c.TestUtils.newModel(function(model) { |
| 156 var process = model.getOrCreateProcess(1); |
| 157 addDumpWithAllocator(model, process, 'dummy', 10); |
| 158 addDumpWithAllocator(model, process, 'v8', 20); |
| 159 }); |
| 160 var range = tr.metrics.v8.utils.rangeForMemoryDumps(model); |
| 161 assert.isFalse(range.isEmpty); |
| 162 assert.strictEqual(range.min, 20); |
| 163 assert.strictEqual(range.max, Infinity); |
| 164 }); |
| 165 |
| 166 test('rangeForMemoryDumpsEmpty', function() { |
| 167 var model = tr.c.TestUtils.newModel(function(model) { |
| 168 var process = model.getOrCreateProcess(1); |
| 169 addDumpWithAllocator(model, process, 'dummy', 10); |
| 170 addDumpWithAllocator(model, process, 'dummy', 20); |
| 171 }); |
| 172 var range = tr.metrics.v8.utils.rangeForMemoryDumps(model); |
| 173 assert.isTrue(range.isEmpty); |
| 174 }); |
| 144 }); | 175 }); |
| 145 </script> | 176 </script> |
| OLD | NEW |