| 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/guid.html"> | 8 <link rel="import" href="/tracing/base/guid.html"> |
| 9 <link rel="import" href="/tracing/base/range.html"> | 9 <link rel="import" href="/tracing/base/math/range.html"> |
| 10 <link rel="import" href="/tracing/model/async_slice_group.html"> | 10 <link rel="import" href="/tracing/model/async_slice_group.html"> |
| 11 <link rel="import" href="/tracing/model/event_container.html"> | 11 <link rel="import" href="/tracing/model/event_container.html"> |
| 12 <link rel="import" href="/tracing/model/slice_group.html"> | 12 <link rel="import" href="/tracing/model/slice_group.html"> |
| 13 <link rel="import" href="/tracing/model/thread_slice.html"> | 13 <link rel="import" href="/tracing/model/thread_slice.html"> |
| 14 | 14 |
| 15 <script> | 15 <script> |
| 16 'use strict'; | 16 'use strict'; |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * @fileoverview Provides the Thread class. | 19 * @fileoverview Provides the Thread class. |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 }, | 218 }, |
| 219 | 219 |
| 220 getProcess: function() { | 220 getProcess: function() { |
| 221 return this.parent; | 221 return this.parent; |
| 222 }, | 222 }, |
| 223 | 223 |
| 224 /* | 224 /* |
| 225 * Returns the index of the slice in the timeSlices array, or undefined. | 225 * Returns the index of the slice in the timeSlices array, or undefined. |
| 226 */ | 226 */ |
| 227 indexOfTimeSlice: function(timeSlice) { | 227 indexOfTimeSlice: function(timeSlice) { |
| 228 var i = tr.b.findLowIndexInSortedArray( | 228 var i = tr.b.math.findLowIndexInSortedArray( |
| 229 this.timeSlices, | 229 this.timeSlices, |
| 230 function(slice) { return slice.start; }, | 230 function(slice) { return slice.start; }, |
| 231 timeSlice.start); | 231 timeSlice.start); |
| 232 if (this.timeSlices[i] !== timeSlice) | 232 if (this.timeSlices[i] !== timeSlice) |
| 233 return undefined; | 233 return undefined; |
| 234 return i; | 234 return i; |
| 235 }, | 235 }, |
| 236 | 236 |
| 237 /* | 237 /* |
| 238 * Returns an object with the CPU number used as keys, | 238 * Returns an object with the CPU number used as keys, |
| 239 * and the value of each key object is the amount of milliseconds spent | 239 * and the value of each key object is the amount of milliseconds spent |
| 240 * running on this CPU. | 240 * running on this CPU. |
| 241 * Additionally, stats.total contains the total time | 241 * Additionally, stats.total contains the total time |
| 242 * spent running on all CPUs. | 242 * spent running on all CPUs. |
| 243 */ | 243 */ |
| 244 getCpuStatsForRange: function(range) { | 244 getCpuStatsForRange: function(range) { |
| 245 var stats = {}; | 245 var stats = {}; |
| 246 stats.total = 0; | 246 stats.total = 0; |
| 247 | 247 |
| 248 if (!this.timeSlices) | 248 if (!this.timeSlices) |
| 249 return stats; | 249 return stats; |
| 250 | 250 |
| 251 function addStatsForSlice(threadTimeSlice) { | 251 function addStatsForSlice(threadTimeSlice) { |
| 252 var freqRange = tr.b.Range.fromExplicitRange(threadTimeSlice.start, | 252 var freqRange = tr.b.math.Range.fromExplicitRange(threadTimeSlice.start, |
| 253 threadTimeSlice.end); | 253 threadTimeSlice.end); |
| 254 var intersection = freqRange.findIntersection(range); | 254 var intersection = freqRange.findIntersection(range); |
| 255 | 255 |
| 256 if (threadTimeSlice.schedulingState === | 256 if (threadTimeSlice.schedulingState === |
| 257 tr.model.SCHEDULING_STATE.RUNNING) { | 257 tr.model.SCHEDULING_STATE.RUNNING) { |
| 258 var cpu = threadTimeSlice.cpuOnWhichThreadWasRunning; | 258 var cpu = threadTimeSlice.cpuOnWhichThreadWasRunning; |
| 259 if (!(cpu.cpuNumber in stats)) | 259 if (!(cpu.cpuNumber in stats)) |
| 260 stats[cpu.cpuNumber] = 0; | 260 stats[cpu.cpuNumber] = 0; |
| 261 | 261 |
| 262 stats[cpu.cpuNumber] += intersection.duration; | 262 stats[cpu.cpuNumber] += intersection.duration; |
| 263 stats.total += intersection.duration; | 263 stats.total += intersection.duration; |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 | 266 |
| 267 tr.b.iterateOverIntersectingIntervals(this.timeSlices, | 267 tr.b.math.iterateOverIntersectingIntervals(this.timeSlices, |
| 268 function(x) { return x.start; }, | 268 function(x) { return x.start; }, |
| 269 function(x) { return x.end; }, | 269 function(x) { return x.end; }, |
| 270 range.min, | 270 range.min, |
| 271 range.max, | 271 range.max, |
| 272 addStatsForSlice); | 272 addStatsForSlice); |
| 273 return stats; | 273 return stats; |
| 274 }, | 274 }, |
| 275 | 275 |
| 276 getSchedulingStatsForRange: function(start, end) { | 276 getSchedulingStatsForRange: function(start, end) { |
| 277 var stats = {}; | 277 var stats = {}; |
| 278 | 278 |
| 279 if (!this.timeSlices) return stats; | 279 if (!this.timeSlices) return stats; |
| 280 | 280 |
| 281 function addStatsForSlice(threadTimeSlice) { | 281 function addStatsForSlice(threadTimeSlice) { |
| 282 var overlapStart = Math.max(threadTimeSlice.start, start); | 282 var overlapStart = Math.max(threadTimeSlice.start, start); |
| 283 var overlapEnd = Math.min(threadTimeSlice.end, end); | 283 var overlapEnd = Math.min(threadTimeSlice.end, end); |
| 284 var schedulingState = threadTimeSlice.schedulingState; | 284 var schedulingState = threadTimeSlice.schedulingState; |
| 285 | 285 |
| 286 if (!(schedulingState in stats)) | 286 if (!(schedulingState in stats)) |
| 287 stats[schedulingState] = 0; | 287 stats[schedulingState] = 0; |
| 288 stats[schedulingState] += overlapEnd - overlapStart; | 288 stats[schedulingState] += overlapEnd - overlapStart; |
| 289 } | 289 } |
| 290 | 290 |
| 291 tr.b.iterateOverIntersectingIntervals(this.timeSlices, | 291 tr.b.math.iterateOverIntersectingIntervals(this.timeSlices, |
| 292 function(x) { return x.start; }, | 292 function(x) { return x.start; }, |
| 293 function(x) { return x.end; }, | 293 function(x) { return x.end; }, |
| 294 start, | 294 start, |
| 295 end, | 295 end, |
| 296 addStatsForSlice); | 296 addStatsForSlice); |
| 297 return stats; | 297 return stats; |
| 298 }, | 298 }, |
| 299 | 299 |
| 300 get samples() { | 300 get samples() { |
| 301 return this.samples_; | 301 return this.samples_; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 322 return tmp; | 322 return tmp; |
| 323 | 323 |
| 324 return x.tid - y.tid; | 324 return x.tid - y.tid; |
| 325 }; | 325 }; |
| 326 | 326 |
| 327 return { | 327 return { |
| 328 Thread, | 328 Thread, |
| 329 }; | 329 }; |
| 330 }); | 330 }); |
| 331 </script> | 331 </script> |
| OLD | NEW |