| 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/color_scheme.html"> | 8 <link rel="import" href="/tracing/base/color_scheme.html"> |
| 9 <link rel="import" href="/tracing/base/guid.html"> | 9 <link rel="import" href="/tracing/base/guid.html"> |
| 10 <link rel="import" href="/tracing/base/sorted_array_utils.html"> | 10 <link rel="import" href="/tracing/base/math/sorted_array_utils.html"> |
| 11 <link rel="import" href="/tracing/core/filter.html"> | 11 <link rel="import" href="/tracing/core/filter.html"> |
| 12 <link rel="import" href="/tracing/model/event_container.html"> | 12 <link rel="import" href="/tracing/model/event_container.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 SliceGroup class. | 19 * @fileoverview Provides the SliceGroup class. |
| 20 */ | 20 */ |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 for (var i = 0; i < this.slices.length; i++) { | 306 for (var i = 0; i < this.slices.length; i++) { |
| 307 if (this.slices[i].title === title) { | 307 if (this.slices[i].title === title) { |
| 308 slices.push(this.slices[i]); | 308 slices.push(this.slices[i]); |
| 309 } | 309 } |
| 310 } | 310 } |
| 311 return slices; | 311 return slices; |
| 312 }, | 312 }, |
| 313 | 313 |
| 314 iterSlicesInTimeRange: function(callback, start, end) { | 314 iterSlicesInTimeRange: function(callback, start, end) { |
| 315 var ret = []; | 315 var ret = []; |
| 316 tr.b.iterateOverIntersectingIntervals( | 316 tr.b.math.iterateOverIntersectingIntervals( |
| 317 this.topLevelSlices, | 317 this.topLevelSlices, |
| 318 function(s) { return s.start; }, | 318 function(s) { return s.start; }, |
| 319 function(s) { return s.duration; }, | 319 function(s) { return s.duration; }, |
| 320 start, | 320 start, |
| 321 end, | 321 end, |
| 322 function(topLevelSlice) { | 322 function(topLevelSlice) { |
| 323 callback(topLevelSlice); | 323 callback(topLevelSlice); |
| 324 for (var slice of topLevelSlice.enumerateAllDescendents()) | 324 for (var slice of topLevelSlice.enumerateAllDescendents()) |
| 325 callback(slice); | 325 callback(slice); |
| 326 }); | 326 }); |
| 327 return ret; | 327 return ret; |
| 328 }, | 328 }, |
| 329 | 329 |
| 330 findFirstSlice: function() { | 330 findFirstSlice: function() { |
| 331 if (!this.haveTopLevelSlicesBeenBuilt) | 331 if (!this.haveTopLevelSlicesBeenBuilt) |
| 332 throw new Error('Nope'); | 332 throw new Error('Nope'); |
| 333 if (0 === this.slices.length) | 333 if (0 === this.slices.length) |
| 334 return undefined; | 334 return undefined; |
| 335 return this.slices[0]; | 335 return this.slices[0]; |
| 336 }, | 336 }, |
| 337 | 337 |
| 338 findSliceAtTs: function(ts) { | 338 findSliceAtTs: function(ts) { |
| 339 if (!this.haveTopLevelSlicesBeenBuilt) | 339 if (!this.haveTopLevelSlicesBeenBuilt) |
| 340 throw new Error('Nope'); | 340 throw new Error('Nope'); |
| 341 var i = tr.b.findIndexInSortedClosedIntervals( | 341 var i = tr.b.math.findIndexInSortedClosedIntervals( |
| 342 this.topLevelSlices, | 342 this.topLevelSlices, |
| 343 getSliceLo, getSliceHi, | 343 getSliceLo, getSliceHi, |
| 344 ts); | 344 ts); |
| 345 if (i === -1 || i === this.topLevelSlices.length) | 345 if (i === -1 || i === this.topLevelSlices.length) |
| 346 return undefined; | 346 return undefined; |
| 347 | 347 |
| 348 var curSlice = this.topLevelSlices[i]; | 348 var curSlice = this.topLevelSlices[i]; |
| 349 | 349 |
| 350 // Now recurse on slice looking for subSlice of given ts. | 350 // Now recurse on slice looking for subSlice of given ts. |
| 351 while (true) { | 351 while (true) { |
| 352 var i = tr.b.findIndexInSortedClosedIntervals( | 352 var i = tr.b.math.findIndexInSortedClosedIntervals( |
| 353 curSlice.subSlices, | 353 curSlice.subSlices, |
| 354 getSliceLo, getSliceHi, | 354 getSliceLo, getSliceHi, |
| 355 ts); | 355 ts); |
| 356 if (i === -1 || i === curSlice.subSlices.length) | 356 if (i === -1 || i === curSlice.subSlices.length) |
| 357 return curSlice; | 357 return curSlice; |
| 358 curSlice = curSlice.subSlices[i]; | 358 curSlice = curSlice.subSlices[i]; |
| 359 } | 359 } |
| 360 }, | 360 }, |
| 361 | 361 |
| 362 findNextSliceAfter: function(ts, refGuid) { | 362 findNextSliceAfter: function(ts, refGuid) { |
| 363 var i = tr.b.findLowIndexInSortedArray( | 363 var i = tr.b.math.findLowIndexInSortedArray( |
| 364 this.slices, getSliceLo, ts); | 364 this.slices, getSliceLo, ts); |
| 365 if (i === this.slices.length) | 365 if (i === this.slices.length) |
| 366 return undefined; | 366 return undefined; |
| 367 for (; i < this.slices.length; i++) { | 367 for (; i < this.slices.length; i++) { |
| 368 var slice = this.slices[i]; | 368 var slice = this.slices[i]; |
| 369 if (slice.start > ts) | 369 if (slice.start > ts) |
| 370 return slice; | 370 return slice; |
| 371 if (slice.guid <= refGuid) | 371 if (slice.guid <= refGuid) |
| 372 continue; | 372 continue; |
| 373 return slice; | 373 return slice; |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 closeOpenSlices(); | 679 closeOpenSlices(); |
| 680 | 680 |
| 681 return result; | 681 return result; |
| 682 }; | 682 }; |
| 683 | 683 |
| 684 return { | 684 return { |
| 685 SliceGroup, | 685 SliceGroup, |
| 686 }; | 686 }; |
| 687 }); | 687 }); |
| 688 </script> | 688 </script> |
| OLD | NEW |