OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2013 The Chromium Authors. All rights reserved. | 3 Copyright (c) 2013 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/base/range.html"> | 8 <link rel="import" href="/tracing/base/math/range.html"> |
9 <link rel="import" href="/tracing/core/test_utils.html"> | 9 <link rel="import" href="/tracing/core/test_utils.html"> |
10 <link rel="import" href="/tracing/model/model.html"> | 10 <link rel="import" href="/tracing/model/model.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 var ThreadSlice = tr.model.ThreadSlice; | 16 var ThreadSlice = tr.model.ThreadSlice; |
17 var Process = tr.model.Process; | 17 var Process = tr.model.Process; |
18 var Thread = tr.model.Thread; | 18 var Thread = tr.model.Thread; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 test('getCpuStatsForRange', function() { | 140 test('getCpuStatsForRange', function() { |
141 var model = tr.c.TestUtils.newModel(function(model) { | 141 var model = tr.c.TestUtils.newModel(function(model) { |
142 var cpu0 = model.kernel.getOrCreateCpu(0); | 142 var cpu0 = model.kernel.getOrCreateCpu(0); |
143 var cpu1 = model.kernel.getOrCreateCpu(1); | 143 var cpu1 = model.kernel.getOrCreateCpu(1); |
144 var thread = model.getOrCreateProcess(1).getOrCreateThread(1); | 144 var thread = model.getOrCreateProcess(1).getOrCreateThread(1); |
145 thread.timeSlices = [ | 145 thread.timeSlices = [ |
146 newThreadSlice(thread, SCHEDULING_STATE.RUNNING, 0, 3, cpu0), | 146 newThreadSlice(thread, SCHEDULING_STATE.RUNNING, 0, 3, cpu0), |
147 newThreadSlice(thread, SCHEDULING_STATE.RUNNING, 8, 2, cpu1), | 147 newThreadSlice(thread, SCHEDULING_STATE.RUNNING, 8, 2, cpu1), |
148 newThreadSlice(thread, SCHEDULING_STATE.RUNNING, 20, 5, cpu1) | 148 newThreadSlice(thread, SCHEDULING_STATE.RUNNING, 20, 5, cpu1) |
149 ]; | 149 ]; |
150 var range = tr.b.Range.fromExplicitRange(1, 22); | 150 var range = tr.b.math.Range.fromExplicitRange(1, 22); |
151 var stats = thread.getCpuStatsForRange(range); | 151 var stats = thread.getCpuStatsForRange(range); |
152 assert.deepEqual(stats, { | 152 assert.deepEqual(stats, { |
153 0: 2, | 153 0: 2, |
154 1: 4, | 154 1: 4, |
155 total: 6 | 155 total: 6 |
156 }); | 156 }); |
157 }); | 157 }); |
158 }); | 158 }); |
159 | 159 |
160 test('getCpuStatsForRange_excludesNotRunningThreads', function() { | 160 test('getCpuStatsForRange_excludesNotRunningThreads', function() { |
161 var model = tr.c.TestUtils.newModel(function(model) { | 161 var model = tr.c.TestUtils.newModel(function(model) { |
162 var cpu0 = model.kernel.getOrCreateCpu(0); | 162 var cpu0 = model.kernel.getOrCreateCpu(0); |
163 var cpu1 = model.kernel.getOrCreateCpu(1); | 163 var cpu1 = model.kernel.getOrCreateCpu(1); |
164 var thread = model.getOrCreateProcess(1).getOrCreateThread(1); | 164 var thread = model.getOrCreateProcess(1).getOrCreateThread(1); |
165 thread.timeSlices = [ | 165 thread.timeSlices = [ |
166 newThreadSlice(thread, SCHEDULING_STATE.RUNNING, 0, 8, cpu0), | 166 newThreadSlice(thread, SCHEDULING_STATE.RUNNING, 0, 8, cpu0), |
167 newThreadSlice(thread, SCHEDULING_STATE.RUNNABLE, 8, 3), | 167 newThreadSlice(thread, SCHEDULING_STATE.RUNNABLE, 8, 3), |
168 newThreadSlice(thread, SCHEDULING_STATE.RUNNING, 11, 4, cpu1), | 168 newThreadSlice(thread, SCHEDULING_STATE.RUNNING, 11, 4, cpu1), |
169 newThreadSlice(thread, SCHEDULING_STATE.SLEEPING, 15, 10), | 169 newThreadSlice(thread, SCHEDULING_STATE.SLEEPING, 15, 10), |
170 newThreadSlice(thread, SCHEDULING_STATE.RUNNING, 25, 10, cpu1) | 170 newThreadSlice(thread, SCHEDULING_STATE.RUNNING, 25, 10, cpu1) |
171 ]; | 171 ]; |
172 var range = tr.b.Range.fromExplicitRange(1, 26); | 172 var range = tr.b.math.Range.fromExplicitRange(1, 26); |
173 var stats = thread.getCpuStatsForRange(range); | 173 var stats = thread.getCpuStatsForRange(range); |
174 assert.deepEqual(stats, { | 174 assert.deepEqual(stats, { |
175 0: 7, | 175 0: 7, |
176 1: 5, | 176 1: 5, |
177 total: 12 | 177 total: 12 |
178 }); | 178 }); |
179 }); | 179 }); |
180 }); | 180 }); |
181 }); | 181 }); |
182 </script> | 182 </script> |
183 | 183 |
OLD | NEW |