diff options
Diffstat (limited to 'chromium/third_party/catapult/tracing/tracing/model')
120 files changed, 0 insertions, 22315 deletions
diff --git a/chromium/third_party/catapult/tracing/tracing/model/activity.html b/chromium/third_party/catapult/tracing/tracing/model/activity.html deleted file mode 100644 index c86edab2ea1..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/activity.html +++ /dev/null @@ -1,56 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/color_scheme.html"> - -<script> -'use strict'; - -/** - * @fileoverview Class representing a user activity that is running - * in the process. - * On the Android platform, activities are mapped to Android Activities - * running in the foreground of the process. - * On Windows/OS X this could for example represent - * the currently active window of the process. - */ -tr.exportTo('tr.model', function() { - var ColorScheme = tr.b.ColorScheme; - - /** - * @constructor - * @param {String} name Name of the activity - * @param {String} category Category of the activities - * @param {String} range The time range where the activity was running - * @param {String} args Additional arguments - */ - function Activity(name, category, range, args) { - tr.model.TimedEvent.call(this, range.min); - this.title = name; - this.category = category; - this.colorId = ColorScheme.getColorIdForGeneralPurposeString(name); - this.duration = range.duration; - this.args = args; - this.name = name; - }; - - Activity.prototype = { - __proto__: tr.model.TimedEvent.prototype, - - shiftTimestampsForward: function(amount) { - this.start += amount; - }, - - addBoundsToRange: function(range) { - range.addValue(this.start); - range.addValue(this.end); - } - }; - return { - Activity: Activity - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/alert.html b/chromium/third_party/catapult/tracing/tracing/model/alert.html deleted file mode 100644 index 53a2fa74217..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/alert.html +++ /dev/null @@ -1,58 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/event_info.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/timed_event.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - - function Alert(info, start, opt_associatedEvents, opt_args) { - tr.model.TimedEvent.call(this, start); - this.info = info; - this.args = opt_args || {}; - this.associatedEvents = new tr.model.EventSet(opt_associatedEvents); - this.associatedEvents.forEach(function(event) { - event.addAssociatedAlert(this); - }, this); - } - - Alert.prototype = { - __proto__: tr.model.TimedEvent.prototype, - - get title() { - return this.info.title; - }, - - get colorId() { - return this.info.colorId; - }, - - get userFriendlyName() { - return 'Alert ' + this.title + ' at ' + - tr.v.Unit.byName.timeStampInMs.format(this.start); - } - }; - - tr.model.EventRegistry.register( - Alert, - { - name: 'alert', - pluralName: 'alerts', - singleViewElementName: 'tr-ui-a-alert-sub-view', - multiViewElementName: 'tr-ui-a-alert-sub-view' - }); - - return { - Alert: Alert - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/annotation.html b/chromium/third_party/catapult/tracing/tracing/model/annotation.html deleted file mode 100644 index cea718342cb..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/annotation.html +++ /dev/null @@ -1,83 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/extension_registry.html"> -<link rel="import" href="/tracing/base/guid.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - /** - * Annotation is a base class that represents all annotation objects that - * can be drawn on the timeline. - * - * @constructor - */ - function Annotation() { - this.guid_ = tr.b.GUID.allocateSimple(); - this.view_ = undefined; - }; - - Annotation.fromDictIfPossible = function(args) { - if (args.typeName === undefined) - throw new Error('Missing typeName argument'); - - var typeInfo = Annotation.findTypeInfoMatching(function(typeInfo) { - return typeInfo.metadata.typeName === args.typeName; - }); - - if (typeInfo === undefined) - return undefined; - - return typeInfo.constructor.fromDict(args); - }; - - Annotation.fromDict = function() { - throw new Error('Not implemented'); - }; - - Annotation.prototype = { - get guid() { - return this.guid_; - }, - - // Invoked by trace model when this annotation is removed. - onRemove: function() { - }, - - toDict: function() { - throw new Error('Not implemented'); - }, - - getOrCreateView: function(viewport) { - if (!this.view_) - this.view_ = this.createView_(viewport); - return this.view_; - }, - - createView_: function() { - throw new Error('Not implemented'); - } - }; - - var options = new tr.b.ExtensionRegistryOptions(tr.b. BASIC_REGISTRY_MODE); - tr.b.decorateExtensionRegistry(Annotation, options); - - Annotation.addEventListener('will-register', function(e) { - if (!e.typeInfo.constructor.hasOwnProperty('fromDict')) - throw new Error('Must have fromDict method'); - - if (!e.typeInfo.metadata.typeName) - throw new Error('Registered Annotations must provide typeName'); - }); - - return { - Annotation: Annotation - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/annotation_test.html b/chromium/third_party/catapult/tracing/tracing/model/annotation_test.html deleted file mode 100644 index a5b6c3e6fea..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/annotation_test.html +++ /dev/null @@ -1,45 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/location.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/comment_box_annotation.html"> -<link rel="import" href="/tracing/model/rect_annotation.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/x_marker_annotation.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - - test('rectAnnotation', function() { - var fakeYComponents1 = [{stableId: '1.2', yPercentOffset: 0.3}]; - var fakeYComponents2 = [{stableId: '1.2', yPercentOffset: 0.9}]; - var start = new tr.model.Location(50, fakeYComponents1); - var end = new tr.model.Location(100, fakeYComponents2); - var rectAnnotation = new tr.model.RectAnnotation(start, end); - assert.equal(rectAnnotation.startLocation, start); - assert.equal(rectAnnotation.endLocation, end); - }); - - test('xMarkerAnnotation', function() { - var xMarkerAnnotation = new tr.model.XMarkerAnnotation(90); - assert.equal(xMarkerAnnotation.timestamp, 90); - }); - - test('commentBoxAnnotation', function() { - var fakeYComponents = [{stableId: '1.2', yPercentOffset: 0.5}]; - var location = new tr.model.Location(120, fakeYComponents); - var text = 'abc'; - var commentBoxAnnotation = - new tr.model.CommentBoxAnnotation(location, text); - assert.equal(commentBoxAnnotation.location, location); - assert.equal(commentBoxAnnotation.text, text); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/async_slice.html b/chromium/third_party/catapult/tracing/tracing/model/async_slice.html deleted file mode 100644 index 325ef09d0a8..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/async_slice.html +++ /dev/null @@ -1,160 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/extension_registry.html"> -<link rel="import" href="/tracing/model/timed_event.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the AsyncSlice class. - */ -tr.exportTo('tr.model', function() { - /** - * A AsyncSlice represents an interval of time during which an - * asynchronous operation is in progress. An AsyncSlice consumes no CPU time - * itself and so is only associated with Threads at its start and end point. - * - * @constructor - */ - function AsyncSlice(category, title, colorId, start, args, duration, - opt_isTopLevel, opt_cpuStart, opt_cpuDuration, - opt_argsStripped) { - tr.model.TimedEvent.call(this, start); - - this.category = category || ''; - // We keep the original title from the trace file in originalTitle since - // some sub-classes, e.g. NetAsyncSlice, change the title field. - this.originalTitle = title; - this.title = title; - this.colorId = colorId; - this.args = args; - this.startStackFrame = undefined; - this.endStackFrame = undefined; - this.didNotFinish = false; - this.important = false; - this.subSlices = []; - this.parentContainer_ = undefined; - - this.id = undefined; - this.startThread = undefined; - this.endThread = undefined; - this.cpuStart = undefined; - this.cpuDuration = undefined; - this.argsStripped = false; - - this.startStackFrame = undefined; - this.endStackFrame = undefined; - - this.duration = duration; - - // isTopLevel is set at import because only NESTABLE_ASYNC events might not - // be topLevel. All legacy async events are toplevel by definition. - this.isTopLevel = (opt_isTopLevel === true); - - if (opt_cpuStart !== undefined) - this.cpuStart = opt_cpuStart; - - if (opt_cpuDuration !== undefined) - this.cpuDuration = opt_cpuDuration; - - if (opt_argsStripped !== undefined) - this.argsStripped = opt_argsStripped; - }; - - AsyncSlice.prototype = { - __proto__: tr.model.TimedEvent.prototype, - - get analysisTypeName() { - return this.title; - }, - - get parentContainer() { - return this.parentContainer_; - }, - - set parentContainer(parentContainer) { - this.parentContainer_ = parentContainer; - for (var i = 0; i < this.subSlices.length; i++) { - var subSlice = this.subSlices[i]; - if (subSlice.parentContainer === undefined) - subSlice.parentContainer = parentContainer; - } - }, - - get viewSubGroupTitle() { - return this.title; - }, - - get userFriendlyName() { - return 'Async slice ' + this.title + ' at ' + - tr.v.Unit.byName.timeStampInMs.format(this.start); - }, - - get stableId() { - var parentAsyncSliceGroup = this.parentContainer.asyncSliceGroup; - return parentAsyncSliceGroup.stableId + '.' + - parentAsyncSliceGroup.slices.indexOf(this); - }, - - findTopmostSlicesRelativeToThisSlice: function*(eventPredicate, opt_this) { - if (eventPredicate(this)) { - yield this; - return; - } - for (var s of this.subSlices) - yield * s.findTopmostSlicesRelativeToThisSlice(eventPredicate); - }, - - findDescendentSlice: function(targetTitle) { - if (!this.subSlices) - return undefined; - - for (var i = 0; i < this.subSlices.length; i++) { - if (this.subSlices[i].title == targetTitle) - return this.subSlices[i]; - var slice = this.subSlices[i].findDescendentSlice(targetTitle); - if (slice) return slice; - } - return undefined; - }, - - iterateAllDescendents: function(callback, opt_this) { - this.subSlices.forEach(callback, opt_this); - this.subSlices.forEach(function(subSlice) { - subSlice.iterateAllDescendents(callback, opt_this); - }, opt_this); - }, - - compareTo: function(that) { - return this.title.localeCompare(that.title); - } - }; - - tr.model.EventRegistry.register( - AsyncSlice, - { - name: 'asyncSlice', - pluralName: 'asyncSlices', - singleViewElementName: 'tr-ui-a-single-async-slice-sub-view', - multiViewElementName: 'tr-ui-a-multi-async-slice-sub-view' - }); - - - var options = new tr.b.ExtensionRegistryOptions( - tr.b.TYPE_BASED_REGISTRY_MODE); - options.mandatoryBaseClass = AsyncSlice; - options.defaultConstructor = AsyncSlice; - tr.b.decorateExtensionRegistry(AsyncSlice, options); - - return { - AsyncSlice: AsyncSlice - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/async_slice_group.html b/chromium/third_party/catapult/tracing/tracing/model/async_slice_group.html deleted file mode 100644 index 926864103c0..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/async_slice_group.html +++ /dev/null @@ -1,166 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/guid.html"> -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/model/async_slice.html"> -<link rel="import" href="/tracing/model/event_container.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the AsyncSliceGroup class. - */ -tr.exportTo('tr.model', function() { - /** - * A group of AsyncSlices associated with a thread. - * @constructor - * @extends {tr.model.EventContainer} - */ - function AsyncSliceGroup(parentContainer, opt_name) { - tr.model.EventContainer.call(this); - this.parentContainer_ = parentContainer; - this.slices = []; - this.name_ = opt_name; - this.viewSubGroups_ = undefined; - } - - AsyncSliceGroup.prototype = { - __proto__: tr.model.EventContainer.prototype, - - get parentContainer() { - return this.parentContainer_; - }, - - get model() { - return this.parentContainer_.parent.model; - }, - - get stableId() { - return this.parentContainer_.stableId + '.AsyncSliceGroup'; - }, - - getSettingsKey: function() { - if (!this.name_) - return undefined; - var parentKey = this.parentContainer_.getSettingsKey(); - if (!parentKey) - return undefined; - return parentKey + '.' + this.name_; - }, - - /** - * Helper function that pushes the provided slice onto the slices array. - */ - push: function(slice) { - slice.parentContainer = this.parentContainer; - this.slices.push(slice); - return slice; - }, - - /** - * @return {Number} The number of slices in this group. - */ - get length() { - return this.slices.length; - }, - - /** - * Shifts all the timestamps inside this group forward by the amount - * specified, including all nested subSlices if there are any. - */ - shiftTimestampsForward: function(amount) { - for (var sI = 0; sI < this.slices.length; sI++) { - var slice = this.slices[sI]; - slice.start = (slice.start + amount); - // Shift all nested subSlices recursively. - var shiftSubSlices = function(subSlices) { - if (subSlices === undefined || subSlices.length === 0) - return; - for (var sJ = 0; sJ < subSlices.length; sJ++) { - subSlices[sJ].start += amount; - shiftSubSlices(subSlices[sJ].subSlices); - } - }; - shiftSubSlices(slice.subSlices); - } - }, - - /** - * Updates the bounds for this group based on the slices it contains. - */ - updateBounds: function() { - this.bounds.reset(); - for (var i = 0; i < this.slices.length; i++) { - this.bounds.addValue(this.slices[i].start); - this.bounds.addValue(this.slices[i].end); - } - }, - - /** - * Gets the sub-groups in this A-S-G defined by the group titles. - * - * @return {Array} An array of AsyncSliceGroups where each group has - * slices that started on the same thread. - */ - get viewSubGroups() { - if (this.viewSubGroups_ === undefined) { - var prefix = ''; - if (this.name !== undefined) - prefix = this.name + '.'; - else - prefix = ''; - - var subGroupsByTitle = {}; - for (var i = 0; i < this.slices.length; ++i) { - var slice = this.slices[i]; - var subGroupTitle = slice.viewSubGroupTitle; - if (!subGroupsByTitle[subGroupTitle]) { - subGroupsByTitle[subGroupTitle] = new AsyncSliceGroup( - this.parentContainer_, prefix + subGroupTitle); - } - subGroupsByTitle[subGroupTitle].push(slice); - } - this.viewSubGroups_ = tr.b.dictionaryValues(subGroupsByTitle); - this.viewSubGroups_.sort(function(a, b) { - return a.slices[0].compareTo(b.slices[0]); - }); - } - return this.viewSubGroups_; - }, - - findTopmostSlicesInThisContainer: function*(eventPredicate, opt_this) { - for (var slice of this.slices) { - if (slice.isTopLevel) { - yield * slice.findTopmostSlicesRelativeToThisSlice( - eventPredicate, opt_this); - } - } - }, - - childEvents: function*() { - // Async slices normally don't have sub-slices, and when they do, - // the sub-slice is specific to the type of async slice. Thus, - // it is not expected for sub-slices to themselves have sub-sub-slices, - // which is why we don't recurse into the sub-slices here. - for (var slice of this.slices) { - yield slice; - if (slice.subSlices) - yield * slice.subSlices; - } - }, - - childEventContainers: function*() { - } - }; - - return { - AsyncSliceGroup: AsyncSliceGroup - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/async_slice_group_test.html b/chromium/third_party/catapult/tracing/tracing/model/async_slice_group_test.html deleted file mode 100644 index 7306ca8a1bc..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/async_slice_group_test.html +++ /dev/null @@ -1,68 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/model.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Process = tr.model.Process; - var Thread = tr.model.Thread; - var AsyncSlice = tr.model.AsyncSlice; - var AsyncSliceGroup = tr.model.AsyncSliceGroup; - var newAsyncSlice = tr.c.TestUtils.newAsyncSlice; - var newAsyncSliceEx = tr.c.TestUtils.newAsyncSliceEx; - var newModel = tr.c.TestUtils.newModel; - - test('asyncSliceGroupBounds_Empty', function() { - var thread = {}; - var g = new AsyncSliceGroup(thread); - g.updateBounds(); - assert.isTrue(g.bounds.isEmpty); - }); - - test('asyncSliceGroupBounds_Basic', function() { - var model = new tr.Model(); - var p1 = new Process(model, 1); - var t1 = new Thread(p1, 1); - var g = new AsyncSliceGroup(t1); - g.push(newAsyncSlice(0, 1, t1, t1)); - g.push(newAsyncSlice(1, 1.5, t1, t1)); - assert.equal(g.length, 2); - g.updateBounds(); - assert.equal(g.bounds.min, 0); - assert.equal(g.bounds.max, 2.5); - }); - - test('asyncSliceGroupStableId', function() { - var model = new tr.Model(); - var process = model.getOrCreateProcess(123); - var thread = process.getOrCreateThread(456); - var group = new AsyncSliceGroup(thread); - - assert.equal(process.stableId, 123); - assert.equal(thread.stableId, '123.456'); - assert.equal(group.stableId, '123.456.AsyncSliceGroup'); - }); - - test('asyncSliceParentContainerSetAtPush', function() { - var m = newModel(function(m) { - m.process = m.getOrCreateProcess(123); - m.thread = m.process.getOrCreateThread(456); - m.group = new AsyncSliceGroup(m.thread); - - m.sA = m.group.push(newAsyncSliceEx( - { title: 'sA', start: 0.0, duration: 10.0 })); - }); - - assert.deepEqual(m.sA.parentContainer, m.thread); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/async_slice_test.html b/chromium/third_party/catapult/tracing/tracing/model/async_slice_test.html deleted file mode 100644 index 3fadbcb0844..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/async_slice_test.html +++ /dev/null @@ -1,57 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var AsyncSlice = tr.model.AsyncSlice; - var Process = tr.model.Process; - var Thread = tr.model.Thread; - var newAsyncSlice = tr.c.TestUtils.newAsyncSlice; - var newAsyncSliceEx = tr.c.TestUtils.newAsyncSliceEx; - var newFakeThread = tr.c.TestUtils.newFakeThread; - - test('stableId', function() { - var thread = newFakeThread(); - var group = thread.asyncSliceGroup; - - var sA = group.push(newAsyncSliceEx( - { title: 'sA', start: 0.0, duration: 10.0 })); - var sB = group.push(newAsyncSliceEx( - { title: 'sB', start: 10.0, duration: 20.0 })); - var sC = group.push(newAsyncSliceEx( - { title: 'sC', start: 20.0, duration: 30.0 })); - - assert.equal(group.stableId + '.0', sA.stableId); - assert.equal(group.stableId + '.1', sB.stableId); - assert.equal(group.stableId + '.2', sC.stableId); - }); - - test('setParentContainerForSubSlices', function() { - var model = new tr.Model(); - var p1 = new Process(model, 1); - var t1 = new Thread(p1, 1); - var asyncSlice = newAsyncSlice(0, 10, t1, t1); - var subSlice1 = newAsyncSlice(1, 5, t1, t1); - var subSlice2 = newAsyncSlice(6, 9, t1, t1); - var subSlice3 = newAsyncSlice(2, 3, t1, t1); - subSlice1.subSlices.push(subSlice3); - asyncSlice.subSlices.push(subSlice1); - asyncSlice.subSlices.push(subSlice2); - asyncSlice.parentContainer = t1; - assert.equal(asyncSlice.subSlices.length, 2); - assert.equal(subSlice1.subSlices.length, 1); - assert.deepEqual(asyncSlice.parentContainer, t1); - assert.deepEqual(subSlice1.parentContainer, t1); - assert.deepEqual(subSlice2.parentContainer, t1); - assert.deepEqual(subSlice3.parentContainer, t1); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/clock_sync_manager.html b/chromium/third_party/catapult/tracing/tracing/model/clock_sync_manager.html deleted file mode 100644 index 37e10a2cff9..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/clock_sync_manager.html +++ /dev/null @@ -1,380 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - var ClockDomainId = { - BATTOR: 'BATTOR', - - // NOTE: Exists for backwards compatibility with old Chrome traces which - // didn't explicitly specify the clock being used. - UNKNOWN_CHROME_LEGACY: 'UNKNOWN_CHROME_LEGACY', - - LINUX_CLOCK_MONOTONIC: 'LINUX_CLOCK_MONOTONIC', - LINUX_FTRACE_GLOBAL: 'LINUX_FTRACE_GLOBAL', - MAC_MACH_ABSOLUTE_TIME: 'MAC_MACH_ABSOLUTE_TIME', - WIN_ROLLOVER_PROTECTED_TIME_GET_TIME: - 'WIN_ROLLOVER_PROTECTED_TIME_GET_TIME', - WIN_QPC: 'WIN_QPC', - - // "Telemetry" isn't really a clock domain because Telemetry actually - // can use one of several clock domains, just like Chrome. However, - // because there's a chance that Telemetry is running off of the same - // clock as Chrome (e.g. LINUX_CLOCK_MONOTONIC) but on a separate device - // (i.e. on a host computer with Chrome running on an attached phone), - // there's a chance that Chrome and Telemetry will erroneously get put into - // the same clock domain. The solution for this is that clock domains should - // actually be some (unique_device_id, clock_id) tuple. For now, though, - // we'll hack around this by putting Telemetry into its own clock domain. - TELEMETRY: 'TELEMETRY' - }; - - var POSSIBLE_CHROME_CLOCK_DOMAINS = new Set([ - ClockDomainId.UNKNOWN_CHROME_LEGACY, - ClockDomainId.LINUX_CLOCK_MONOTONIC, - ClockDomainId.MAC_MACH_ABSOLUTE_TIME, - ClockDomainId.WIN_ROLLOVER_PROTECTED_TIME_GET_TIME, - ClockDomainId.WIN_QPC - ]); - - // The number of milliseconds above which the BattOr sync is no longer - // considered "fast", and it's more accurate to use the sync start timestamp - // instead of the normal sync timestamp due to a bug in the Chrome serial code - // making serial reads too slow. - var BATTOR_FAST_SYNC_THRESHOLD_MS = 3; - - /** - * Returns a function that, given a timestamp in |fromMarker|'s domain, - * returns a timestamp in |toMarker|'s domain. - */ - function createTransformer(fromMarker, toMarker) { - var fromTs = fromMarker.ts, toTs = toMarker.ts; - - // TODO(charliea): Usually, we estimate that the clock sync marker is - // issued by the agent exactly in the middle of the controller's start and - // end timestamps. However, there's currently a bug in the Chrome serial - // code that's making the clock sync ack for BattOr take much longer to - // read than it should (by about 8ms). This is causing the above estimate - // of the controller's sync timestamp to be off by a substantial enough - // amount that it makes traces hard to read. For now, make an exception - // for BattOr and just use the controller's start timestamp as the sync - // time. In the medium term, we should fix the Chrome serial code in order - // to remove this special logic and get an even more accurate estimate. - if (fromMarker.domainId === ClockDomainId.BATTOR && - toMarker.duration > BATTOR_FAST_SYNC_THRESHOLD_MS) { - toTs = toMarker.startTs; - } else if (toMarker.domainId === ClockDomainId.BATTOR && - fromMarker.duration > BATTOR_FAST_SYNC_THRESHOLD_MS) { - fromTs = fromMarker.startTs; - } - - var tsShift = toTs - fromTs; - return function(ts) { return ts + tsShift; }; - } - - /** - * Given two transformers, creates a third that's a composition of the two. - * - * @param {function(Number): Number} aToB A function capable of converting a - * timestamp from domain A to domain B. - * @param {function(Number): Number} bToC A function capable of converting a - * timestamp from domain B to domain C. - * - * @return {function(Number): Number} A function capable of converting a - * timestamp from domain A to domain C. - */ - function composeTransformers(aToB, bToC) { - return function(ts) { - return bToC(aToB(ts)); - }; - } - - /** - * A ClockSyncManager holds clock sync markers and uses them to shift - * timestamps from agents' clock domains onto the model's clock domain. - * - * In this context, a "clock domain" is a single perspective on the passage - * of time. A single computer can have multiple clock domains because it - * can have multiple methods of retrieving a timestamp (e.g. - * clock_gettime(CLOCK_MONOTONIC) and clock_gettime(CLOCK_REALTIME) on Linux). - * Another common reason for multiple clock domains within a single trace - * is that traces can span devices (e.g. a laptop collecting a Chrome trace - * can have its power consumption recorded by a second device and the two - * traces can be viewed alongside each other). - * - * For more information on how to synchronize multiple time domains using this - * method, see: http://bit.ly/1OVkqju. - * - * @constructor - */ - function ClockSyncManager() { - // A set of all domains seen by the ClockSyncManager. - this.domainsSeen_ = new Set(); - this.markersBySyncId_ = new Map(); - // transformerMapByDomainId_[fromDomainId][toDomainId] returns the function - // that converts timestamps in the "from" domain to timestamps in the "to" - // domain. - this.transformerMapByDomainId_ = {}; - } - - ClockSyncManager.prototype = { - /** - * Adds a clock sync marker to the list of known markers. - * - * @param {string} domainId The clock domain that the marker is in. - * @param {string} syncId The identifier shared by both sides of the clock - * sync marker. - * @param {number} startTs The time (in ms) at which the sync started. - * @param {number=} opt_endTs The time (in ms) at which the sync ended. If - * unspecified, it's assumed to be the same as the start, - * indicating an instantaneous sync. - */ - addClockSyncMarker: function(domainId, syncId, startTs, opt_endTs) { - this.onDomainSeen_(domainId); - - if (tr.b.dictionaryValues(ClockDomainId).indexOf(domainId) < 0) { - throw new Error('"' + domainId + '" is not in the list of known ' + - 'clock domain IDs.'); - } - - if (this.modelDomainId_) { - throw new Error('Cannot add new clock sync markers after getting ' + - 'a model time transformer.'); - } - - var marker = new ClockSyncMarker(domainId, startTs, opt_endTs); - - if (!this.markersBySyncId_.has(syncId)) { - this.markersBySyncId_.set(syncId, [marker]); - return; - } - - var markers = this.markersBySyncId_.get(syncId); - - if (markers.length === 2) { - throw new Error('Clock sync with ID "' + syncId + '" is already ' + - 'complete - cannot add a third clock sync marker to it.'); - } - - if (markers[0].domainId === domainId) - throw new Error('A clock domain cannot sync with itself.'); - - // TODO(charliea): Allow multiple paths between clock domains by selecting - // the path with the least potential error. - if (this.getTransformerBetween_(markers[0].domainId, domainId)) { - throw new Error('The current code cannot handle multiple paths ' + - 'between the same clock domains. However, this is a valid ' + - 'operation.'); - } - - markers.push(marker); - - this.getOrCreateTransformerMap_(markers[0].domainId)[domainId] = - createTransformer(markers[0], marker); - this.getOrCreateTransformerMap_(domainId)[markers[0].domainId] = - createTransformer(marker, markers[0]); - }, - - get markersBySyncId() { - return this.markersBySyncId_; - }, - - /** - * Returns a function that, given a timestamp in the domain with |domainId|, - * returns a timestamp in the model's clock domain. - * - * NOTE: All clock sync markers should be added before calling this function - * for the first time. This is because the first time that this function is - * called, a model clock domain is selected. This clock domain must have - * syncs connecting it with all other clock domains. If multiple clock - * domains are viable candidates, the one with the clock domain ID that is - * the first alphabetically is selected. - */ - getModelTimeTransformer: function(domainId) { - this.onDomainSeen_(domainId); - - if (!this.modelDomainId_) - this.selectModelDomainId_(); - - var transformer = - this.getTransformerBetween_(domainId, this.modelDomainId_); - if (!transformer) { - throw new Error('No clock sync markers exist pairing clock domain "' + - domainId + '" ' + 'with model clock domain "' + - this.modelDomainId_ + '".'); - } - - return transformer; - }, - - /** - * Returns a function that, given a timestamp in the "from" domain, returns - * a timestamp in the "to" domain. - */ - getTransformerBetween_: function(fromDomainId, toDomainId) { - // Do a breadth-first search from the "from" domain until we reach the - // "to" domain. - var visitedDomainIds = new Set(); - // Keep a queue of nodes to visit, starting with the "from" domain. - var queue = []; - queue.push({ domainId: fromDomainId, transformer: tr.b.identity }); - - while (queue.length > 0) { - var current = queue.shift(); - - if (current.domainId === toDomainId) - return current.transformer; - - if (visitedDomainIds.has(current.domainId)) - continue; - visitedDomainIds.add(current.domainId); - - var outgoingTransformers = - this.transformerMapByDomainId_[current.domainId]; - - if (!outgoingTransformers) - continue; - - // Add all nodes that are directly connected to this one to the queue. - for (var outgoingDomainId in outgoingTransformers) { - // We have two transformers: one to get us from the "from" domain to - // the current domain, and another to get us from the current domain - // to the next domain. By composing those two transformers, we can - // create one that gets us from the "from" domain to the next domain. - var toNextDomainTransformer = outgoingTransformers[outgoingDomainId]; - var toCurrentDomainTransformer = current.transformer; - - queue.push({ - domainId: outgoingDomainId, - transformer: composeTransformers( - toNextDomainTransformer, toCurrentDomainTransformer) - }); - } - } - - return undefined; - }, - - /** - * Selects the domain to use as the model domain from among the domains - * with registered markers. - * - * This is necessary because some common domain must be chosen before all - * timestamps can be shifted onto the same domain. - * - * For the time being, preference is given to Chrome clock domains. If no - * Chrome clock domain is present, the first clock domain alphabetically - * is selected. - */ - selectModelDomainId_: function() { - this.ensureAllDomainsAreConnected_(); - - // While we're migrating to the new clock sync system, we have to make - // sure to prefer the Chrome clock domain because legacy clock sync - // mechanisms assume that's the case. - for (var chromeDomainId of POSSIBLE_CHROME_CLOCK_DOMAINS) { - if (this.domainsSeen_.has(chromeDomainId)) { - this.modelDomainId_ = chromeDomainId; - return; - } - } - - var domainsSeenArray = Array.from(this.domainsSeen_); - domainsSeenArray.sort(); - this.modelDomainId_ = domainsSeenArray[0]; - }, - - /** Throws an error if all domains are not connected. */ - ensureAllDomainsAreConnected_: function() { - // NOTE: this is a ridiculously inefficient way to do this. Given how few - // clock domains we're likely to have, this shouldn't be a problem. - var firstDomainId = undefined; - for (var domainId of this.domainsSeen_) { - if (!firstDomainId) { - firstDomainId = domainId; - continue; - } - - if (!this.getTransformerBetween_(firstDomainId, domainId)) { - throw new Error('Unable to select a master clock domain because no ' + - 'path can be found from "' + firstDomainId + '" to "' + domainId + - '".'); - } - } - - return true; - }, - - /** Observer called each time that a clock domain is seen. */ - onDomainSeen_: function(domainId) { - if (domainId === ClockDomainId.UNKNOWN_CHROME_LEGACY && - !this.domainsSeen_.has(ClockDomainId.UNKNOWN_CHROME_LEGACY)) { - // UNKNOWN_CHROME_LEGACY was just seen for the first time: collapse it - // and the other Chrome clock domains into one. - // - // This makes sure that we don't have two separate clock sync graphs: - // one attached to UNKNOWN_CHROME_LEGACY and the other attached to the - // real Chrome clock domain. - for (var chromeDomainId of POSSIBLE_CHROME_CLOCK_DOMAINS) { - if (chromeDomainId === ClockDomainId.UNKNOWN_CHROME_LEGACY) - continue; - - this.collapseDomains_( - ClockDomainId.UNKNOWN_CHROME_LEGACY, chromeDomainId); - } - } - - this.domainsSeen_.add(domainId); - }, - - /** Makes timestamps in the two clock domains interchangeable. */ - collapseDomains_: function(domain1Id, domain2Id) { - this.getOrCreateTransformerMap_(domain1Id)[domain2Id] = - this.getOrCreateTransformerMap_(domain2Id)[domain1Id] = tr.b.identity; - }, - - /** - * Returns (and creates if it doesn't exist) the transformer map describing - * how to transform timestamps between directly connected clock domains. - */ - getOrCreateTransformerMap_: function(domainId) { - if (!this.transformerMapByDomainId_[domainId]) - this.transformerMapByDomainId_[domainId] = {}; - - return this.transformerMapByDomainId_[domainId]; - } - }; - - /** - * A ClockSyncMarker is an internal entity that represents a marker in a - * trace log indicating that a clock sync happened at a specified time. - * - * If no end timestamp argument is specified in the constructor, it's assumed - * that the end timestamp is the same as the start (i.e. the clock sync - * was instantaneous). - */ - function ClockSyncMarker(domainId, startTs, opt_endTs) { - this.domainId = domainId; - this.startTs = startTs; - this.endTs = opt_endTs === undefined ? startTs : opt_endTs; - } - - ClockSyncMarker.prototype = { - get duration() { return this.endTs - this.startTs; }, - get ts() { return this.startTs + this.duration / 2; } - }; - - return { - ClockDomainId: ClockDomainId, - ClockSyncManager: ClockSyncManager - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/clock_sync_manager_test.html b/chromium/third_party/catapult/tracing/tracing/model/clock_sync_manager_test.html deleted file mode 100644 index 6caad9b7d46..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/clock_sync_manager_test.html +++ /dev/null @@ -1,363 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/clock_sync_manager.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - - var ClockDomainId = tr.model.ClockDomainId; - var ClockSyncManager = tr.model.ClockSyncManager; - - var testOptions = { - setUp: function() { - // Add a few testing clock domains to the list of permissible domains. - ClockDomainId.DOMAIN_1 = 'DOMAIN1'; - ClockDomainId.DOMAIN_2 = 'DOMAIN2'; - ClockDomainId.DOMAIN_3 = 'DOMAIN3'; - ClockDomainId.DOMAIN_4 = 'DOMAIN4'; - ClockDomainId.DOMAIN_5 = 'DOMAIN5'; - }, - - tearDown: function() { - delete ClockDomainId.DOMAIN_1; - delete ClockDomainId.DOMAIN_2; - delete ClockDomainId.DOMAIN_3; - delete ClockDomainId.DOMAIN_4; - delete ClockDomainId.DOMAIN_5; - } - }; - - test('addClockSyncMarker_throwsWithUnknownDomain', function() { - var mgr = new ClockSyncManager(); - - assert.throws(function() { - mgr.addClockSyncMarker('unknown', 'sync1', 100, 200); - }, '"unknown" is not in the list of known clock domain IDs.'); - }, testOptions); - - - test('addClockSyncMarker_throwsWhenSelfSyncing', function() { - var mgr = new ClockSyncManager(); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_1, 'sync1', 100, 200); - - assert.throws(function() { - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_1, 'sync1', 200, 300); - }, 'A clock domain cannot sync with itself.'); - }, testOptions); - - test('addClockSyncMarker_throwsWhenAddingThirdSyncMarkerToSync', function() { - var mgr = new ClockSyncManager(); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_1, 'sync1', 100); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_2, 'sync1', 100); - - assert.throws(function() { - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_3, 'sync1', 100); - }, 'Clock sync with ID "sync1" is already complete - cannot add a third ' + - 'clock sync marker to it.'); - }, testOptions); - - test('addClockSyncMarker_throwsWhenAddingDuplicatePaths', function() { - var mgr = new ClockSyncManager(); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_1, 'sync1', 100); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_2, 'sync1', 100); - - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_1, 'sync2', 100); - - assert.throws(function() { - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_2, 'sync2', 100); - }, 'The current code cannot handle multiple paths between the same clock ' + - 'domains. However, this is a valid operation.'); - }, testOptions); - - test('addClockSyncMarker_throwsAfterGetModelTimeTransformer', function() { - var mgr = new ClockSyncManager(); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_1, 'sync1', 100); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_2, 'sync1', 100); - - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_1); - - assert.throws(function() { - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_2, 'sync2', 100); - }, 'Cannot add new clock sync markers after getting a model time ' + - 'transformer.'); - }, testOptions); - - test('getModelTimeTransformer_noMarkers', function() { - var mgr = new ClockSyncManager(); - - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_1)(100), 100); - }, testOptions); - - test('getModelTimeTransformer_noMarkersSecondDomainThrows', function() { - var mgr = new ClockSyncManager(); - - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_1); - - assert.throws(function() { - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_2); - }, 'No clock sync markers exist pairing clock domain "DOMAIN2" with model' + - ' clock domain "DOMAIN1".'); - }, testOptions); - - test('getModelTimeTransformer_noMarkersChromeLegacyFirst', function() { - var mgr = new ClockSyncManager(); - - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.UNKNOWN_CHROME_LEGACY)(100), - 100); - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.LINUX_CLOCK_MONOTONIC)(100), - 100); - }, testOptions); - - test('getModelTimeTransformer_noMarkersChromeLegacySecond', function() { - var mgr = new ClockSyncManager(); - - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.LINUX_CLOCK_MONOTONIC)(100), - 100); - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.UNKNOWN_CHROME_LEGACY)(100), - 100); - }, testOptions); - - test('getModelTimeTransformer_oneMarker', function() { - var mgr = new ClockSyncManager(); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_1, 'sync1', 100); - - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_1)(100), 100); - }, testOptions); - - test('getModelTimeTransformer_oneCompleteSync', function() { - var mgr = new ClockSyncManager(); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_1, 'sync1', 100); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_2, 'sync1', 350); - - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_2)(350), 100); - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_1)(100), 100); - }, testOptions); - - test('getModelTimeTransformer_oneCompleteSyncWithChromeLegacyBefore', - function() { - var mgr = new ClockSyncManager(); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_1, 'sync1', 100); - mgr.addClockSyncMarker(ClockDomainId.UNKNOWN_CHROME_LEGACY, 'sync1', 350); - - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.UNKNOWN_CHROME_LEGACY)(350), - 350); - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_1)(100), 350); - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.LINUX_CLOCK_MONOTONIC)(350), - 350); - }, testOptions); - - test('getModelTimeTransformer_oneCompleteSyncWithChromeLegacyAfter', - function() { - var mgr = new ClockSyncManager(); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_1, 'sync1', 100); - mgr.addClockSyncMarker(ClockDomainId.LINUX_CLOCK_MONOTONIC, 'sync1', 350); - - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.UNKNOWN_CHROME_LEGACY)(350), - 350); - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_1)(100), 350); - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.LINUX_CLOCK_MONOTONIC)(350), - 350); - }, testOptions); - - test('getModelTimeTransformer_twoCompleteSyncs', function() { - var mgr = new ClockSyncManager(); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_1, 'sync1', 100); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_2, 'sync1', 350); - - var tx = mgr.getTransformerBetween_('DOMAIN1', 'DOMAIN3'); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_1, 'sync2', 200); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_3, 'sync2', 250); - - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_2)(350), 100); - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_1)(100), 100); - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_3)(250), 200); - }, testOptions); - - test('getModelTimeTransformer_twoSyncMarkersWithEndTs', function() { - var mgr = new ClockSyncManager(); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_1, 'sync1', 100, 200); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_2, 'sync1', 350); - - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_2)(350), 150); - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_1)(150), 150); - }, testOptions); - - test('getModelTimeTransformer_indirectlyConnectedGraph', - function() { - var mgr = new ClockSyncManager(); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_1, 'sync1', 100); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_2, 'sync1', 200); - - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_2, 'sync2', 200); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_3, 'sync2', 300); - - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_1)(100), 100); - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_3)(300), 100); - }, testOptions); - - test('getModelTimeTransformer_battorSyncUsesNormalTimestampWhenFast', - function() { - var mgr = new ClockSyncManager(); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_1, 'sync1', 100, 102); - mgr.addClockSyncMarker(ClockDomainId.BATTOR, 'sync1', 350); - - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_1)(101), - 350); - }, testOptions); - - test('getModelTimeTransformer_battorSyncUsesChromeLegacyStartTsWhenTooSlow', - function() { - var mgr = new ClockSyncManager(); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_1, 'sync1', 100, 200); - mgr.addClockSyncMarker(ClockDomainId.BATTOR, 'sync1', 350); - - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_1)(100), - 350); - }, testOptions); - - test('getModelTimeTransformer_prefersChromeLegacyDomain', function() { - var mgr = new ClockSyncManager(); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_1, 'sync1', 100); - mgr.addClockSyncMarker(ClockDomainId.UNKNOWN_CHROME_LEGACY, 'sync1', 350); - - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_1)(100), - 350); - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.UNKNOWN_CHROME_LEGACY)(350), - 350); - }, testOptions); - - test('getModelTimeTransformer_collapsesUnknownChromeLegacyDomainLinux', - function() { - var mgr = new ClockSyncManager(); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_1, 'sync1', 100); - mgr.addClockSyncMarker(ClockDomainId.UNKNOWN_CHROME_LEGACY, 'sync1', 350); - - mgr.addClockSyncMarker(ClockDomainId.LINUX_CLOCK_MONOTONIC, 'sync2', 350); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_2, 'sync2', 450); - - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_1)(100), 350); - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_2)(450), 350); - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.LINUX_CLOCK_MONOTONIC)(350), - 350); - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.UNKNOWN_CHROME_LEGACY)(350), - 350); - }, testOptions); - - test('getModelTimeTransformer_collapsesUnknownChromeLegacyDomainMac', - function() { - var mgr = new ClockSyncManager(); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_1, 'sync1', 100); - mgr.addClockSyncMarker(ClockDomainId.UNKNOWN_CHROME_LEGACY, 'sync1', 350); - - mgr.addClockSyncMarker(ClockDomainId.MAC_MACH_ABSOLUTE_TIME, 'sync2', 350); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_2, 'sync2', 450); - - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_1)(100), 350); - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_2)(450), 350); - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.MAC_MACH_ABSOLUTE_TIME)(350), - 350); - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.UNKNOWN_CHROME_LEGACY)(350), - 350); - }, testOptions); - - test('getModelTimeTransformer_collapsesUnknownChromeLegacyDomainWinLoRes', - function() { - var mgr = new ClockSyncManager(); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_1, 'sync1', 100); - mgr.addClockSyncMarker(ClockDomainId.UNKNOWN_CHROME_LEGACY, 'sync1', 350); - - mgr.addClockSyncMarker( - ClockDomainId.WIN_ROLLOVER_PROTECTED_TIME_GET_TIME, 'sync2', 350); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_2, 'sync2', 450); - - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_1)(100), 350); - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_2)(450), 350); - assert.strictEqual( - mgr.getModelTimeTransformer( - ClockDomainId.WIN_ROLLOVER_PROTECTED_TIME_GET_TIME)(350), - 350); - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.UNKNOWN_CHROME_LEGACY)(350), - 350); - }, testOptions); - - test('getModelTimeTransformer_collapsesChromeLegacyDomainWinHiRes', - function() { - var mgr = new ClockSyncManager(); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_1, 'sync1', 100); - mgr.addClockSyncMarker(ClockDomainId.UNKNOWN_CHROME_LEGACY, 'sync1', 350); - - mgr.addClockSyncMarker(ClockDomainId.WIN_QPC, 'sync2', 350); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_2, 'sync2', 450); - - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_1)(100), 350); - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_2)(450), 350); - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.WIN_QPC)(350), 350); - assert.strictEqual( - mgr.getModelTimeTransformer(ClockDomainId.UNKNOWN_CHROME_LEGACY)(350), - 350); - }, testOptions); - - test('getModelTimeTransformer_throwsWithTwoDistinctGraphs', function() { - var mgr = new ClockSyncManager(); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_1, 'sync1', 100); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_2, 'sync1', 100); - - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_1, 'sync2', 100); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_3, 'sync2', 100); - - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_4, 'sync3', 100); - mgr.addClockSyncMarker(ClockDomainId.DOMAIN_5, 'sync3', 100); - - assert.throws(function() { - mgr.getModelTimeTransformer(ClockDomainId.DOMAIN_5); - }, 'Unable to select a master clock domain because no path can be found ' + - 'from "DOMAIN1" to "DOMAIN4"'); - }, testOptions); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/comment_box_annotation.html b/chromium/third_party/catapult/tracing/tracing/model/comment_box_annotation.html deleted file mode 100644 index 5c76b8d9fc6..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/comment_box_annotation.html +++ /dev/null @@ -1,61 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/location.html"> -<link rel="import" href="/tracing/model/annotation.html"> -<link rel="import" href="/tracing/model/rect_annotation.html"> -<link rel="import" href="/tracing/ui/annotations/comment_box_annotation_view.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - - function CommentBoxAnnotation(location, text) { - tr.model.Annotation.apply(this, arguments); - - this.location = location; - this.text = text; - } - - CommentBoxAnnotation.fromDict = function(dict) { - var args = dict.args; - var location = - new tr.model.Location(args.location.xWorld, args.location.yComponents); - return new tr.model.CommentBoxAnnotation(location, args.text); - }; - - CommentBoxAnnotation.prototype = { - __proto__: tr.model.Annotation.prototype, - - onRemove: function() { - this.view_.removeTextArea(); - }, - - toDict: function() { - return { - typeName: 'comment_box', - args: { - text: this.text, - location: this.location.toDict() - } - }; - }, - - createView_: function(viewport) { - return new tr.ui.annotations.CommentBoxAnnotationView(viewport, this); - } - }; - - tr.model.Annotation.register( - CommentBoxAnnotation, {typeName: 'comment_box'}); - - return { - CommentBoxAnnotation: CommentBoxAnnotation - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/compound_event_selection_state.html b/chromium/third_party/catapult/tracing/tracing/model/compound_event_selection_state.html deleted file mode 100644 index bf35ab5c131..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/compound_event_selection_state.html +++ /dev/null @@ -1,40 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - - /** - * Indicates how much of a compound-event is selected [if any]. - * - * The CompoundEventSelectionState enum is used with events that are - * directly selectable, but also have associated events, too, that can be - * selected. In this situation, there are a variety of different - * selected states other than just "yes, no". This enum encodes those - * various possible states. - */ - var CompoundEventSelectionState = { - // Basic bit states. - NOT_SELECTED: 0, - EVENT_SELECTED: 0x1, - SOME_ASSOCIATED_EVENTS_SELECTED: 0x2, - ALL_ASSOCIATED_EVENTS_SELECTED: 0x4, - - // Common combinations. - EVENT_AND_SOME_ASSOCIATED_SELECTED: 0x1 | 0x2, - EVENT_AND_ALL_ASSOCIATED_SELECTED: 0x1 | 0x4 - }; - - return { - CompoundEventSelectionState: CompoundEventSelectionState - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/constants.html b/chromium/third_party/catapult/tracing/tracing/model/constants.html deleted file mode 100644 index 3c1ec4ff24b..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/constants.html +++ /dev/null @@ -1,25 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2012 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - return { - // Since the PID of the browser process is not known to the child processes, - // we let them use "pid_ref = -1" to reference an object created in the - // browser process. - BROWSER_PROCESS_PID_REF: -1, - - // The default scope of object events, when not explicitly specified. - OBJECT_DEFAULT_SCOPE: 'ptr' - }; -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/container_memory_dump.html b/chromium/third_party/catapult/tracing/tracing/model/container_memory_dump.html deleted file mode 100644 index 3abda063566..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/container_memory_dump.html +++ /dev/null @@ -1,93 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/timed_event.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the ContainerMemoryDump class. - */ -tr.exportTo('tr.model', function() { - /** - * The ContainerMemoryDump represents an abstract container memory dump. - * @constructor - */ - function ContainerMemoryDump(start) { - tr.model.TimedEvent.call(this, start); - - this.levelOfDetail = undefined; - - this.memoryAllocatorDumps_ = undefined; - this.memoryAllocatorDumpsByFullName_ = undefined; - }; - - /** - * Memory dump level of detail. See base::trace_event::MemoryDumpLevelOfDetail - * in the Chromium repository. - * - * @enum - */ - ContainerMemoryDump.LevelOfDetail = { - LIGHT: 0, - DETAILED: 1 - }; - - ContainerMemoryDump.prototype = { - __proto__: tr.model.TimedEvent.prototype, - - shiftTimestampsForward: function(amount) { - this.start += amount; - }, - - get memoryAllocatorDumps() { - return this.memoryAllocatorDumps_; - }, - - set memoryAllocatorDumps(memoryAllocatorDumps) { - this.memoryAllocatorDumps_ = memoryAllocatorDumps; - this.forceRebuildingMemoryAllocatorDumpByFullNameIndex(); - }, - - getMemoryAllocatorDumpByFullName: function(fullName) { - if (this.memoryAllocatorDumps_ === undefined) - return undefined; - - // Lazily generate the index if necessary. - if (this.memoryAllocatorDumpsByFullName_ === undefined) { - var index = {}; - function addDumpsToIndex(dumps) { - dumps.forEach(function(dump) { - index[dump.fullName] = dump; - addDumpsToIndex(dump.children); - }); - }; - addDumpsToIndex(this.memoryAllocatorDumps_); - this.memoryAllocatorDumpsByFullName_ = index; - } - - return this.memoryAllocatorDumpsByFullName_[fullName]; - }, - - forceRebuildingMemoryAllocatorDumpByFullNameIndex: function() { - // Clear the index and generate it lazily. - this.memoryAllocatorDumpsByFullName_ = undefined; - }, - - iterateRootAllocatorDumps: function(fn, opt_this) { - if (this.memoryAllocatorDumps === undefined) - return; - this.memoryAllocatorDumps.forEach(fn, opt_this || this); - } - }; - - return { - ContainerMemoryDump: ContainerMemoryDump - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/container_memory_dump_test.html b/chromium/third_party/catapult/tracing/tracing/model/container_memory_dump_test.html deleted file mode 100644 index 6c8bc649bf1..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/container_memory_dump_test.html +++ /dev/null @@ -1,177 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/container_memory_dump.html"> -<link rel="import" href="/tracing/model/memory_allocator_dump.html"> -<link rel="import" href="/tracing/model/memory_dump_test_utils.html"> -<link rel="import" href="/tracing/value/numeric.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var ContainerMemoryDump = tr.model.ContainerMemoryDump; - var MemoryAllocatorDump = tr.model.MemoryAllocatorDump; - var ScalarNumeric = tr.v.ScalarNumeric; - var unitlessNumber_smallerIsBetter = - tr.v.Unit.byName.unitlessNumber_smallerIsBetter; - var newAllocatorDump = tr.model.MemoryDumpTestUtils.newAllocatorDump; - var addChildDump = tr.model.MemoryDumpTestUtils.addChildDump; - - test('memoryAllocatorDumps_undefined', function() { - var md = new ContainerMemoryDump(42); - - assert.isUndefined(md.memoryAllocatorDumps); - assert.isUndefined(md.getMemoryAllocatorDumpByFullName('malloc')); - }); - - test('memoryAllocatorDumps_zero', function() { - var md = new ContainerMemoryDump(42); - md.memoryAllocatorDumps = []; - - assert.lengthOf(md.memoryAllocatorDumps, 0); - assert.isUndefined(md.getMemoryAllocatorDumpByFullName('malloc')); - }); - - test('memoryAllocatorDumps_flat', function() { - var md = new ContainerMemoryDump(42); - - var oilpanDump = newAllocatorDump(md, 'oilpan', { - size: 1024, - objects_count: new ScalarNumeric(unitlessNumber_smallerIsBetter, 7), - inner_size: 768 - }); - var v8Dump = newAllocatorDump(md, 'v8', { - size: 2048, - objects_count: new ScalarNumeric(unitlessNumber_smallerIsBetter, 15), - inner_size: 1999 - }); - md.memoryAllocatorDumps = [oilpanDump, v8Dump]; - - assert.lengthOf(md.memoryAllocatorDumps, 2); - assert.equal(md.memoryAllocatorDumps[0], oilpanDump); - assert.equal(md.memoryAllocatorDumps[1], v8Dump); - - assert.equal(md.getMemoryAllocatorDumpByFullName('oilpan'), oilpanDump); - assert.equal(md.getMemoryAllocatorDumpByFullName('v8'), v8Dump); - assert.isUndefined(md.getMemoryAllocatorDumpByFullName('malloc')); - }); - - test('memoryAllocatorDumps_nested', function() { - var md = new ContainerMemoryDump(42); - - var oilpanDump = newAllocatorDump(md, 'oilpan', { - size: 1024, - objects_count: new ScalarNumeric(unitlessNumber_smallerIsBetter, 7), - inner_size: 768 - }); - - var oilpanBucket1Dump = addChildDump(oilpanDump, 'bucket1', { - size: 512, - objects_count: new ScalarNumeric(unitlessNumber_smallerIsBetter, 3), - inner_size: 256 - }); - - var oilpanBucket2Dump = addChildDump(oilpanDump, 'bucket2', { - size: 512, - objects_count: new ScalarNumeric(unitlessNumber_smallerIsBetter, 4), - inner_size: 512 - }); - - var oilpanBucket2StringsDump = addChildDump(oilpanBucket2Dump, 'strings', { - size: 512, - objects_count: new ScalarNumeric(unitlessNumber_smallerIsBetter, 4), - inner_size: 512 - }); - - var v8Dump = newAllocatorDump(md, 'v8', { - size: 2048, - objects_count: new ScalarNumeric(unitlessNumber_smallerIsBetter, 15), - inner_size: 1999 - }); - - md.memoryAllocatorDumps = [oilpanDump, v8Dump]; - - assert.lengthOf(md.memoryAllocatorDumps, 2); - assert.equal(md.memoryAllocatorDumps[0], oilpanDump); - assert.equal(md.memoryAllocatorDumps[1], v8Dump); - - assert.equal(md.getMemoryAllocatorDumpByFullName('oilpan'), oilpanDump); - assert.equal(md.getMemoryAllocatorDumpByFullName('oilpan/bucket1'), - oilpanBucket1Dump); - assert.equal(md.getMemoryAllocatorDumpByFullName('oilpan/bucket2'), - oilpanBucket2Dump); - assert.equal(md.getMemoryAllocatorDumpByFullName('oilpan/bucket2/strings'), - oilpanBucket2StringsDump); - assert.equal(md.getMemoryAllocatorDumpByFullName('v8'), v8Dump); - assert.isUndefined(md.getMemoryAllocatorDumpByFullName('malloc')); - }); - - test('iterateRootAllocatorDumps', function() { - var containerDump = new ContainerMemoryDump(42); - - var oilpanDump = new MemoryAllocatorDump(containerDump, 'oilpan'); - var v8Dump = new MemoryAllocatorDump(containerDump, 'v8'); - addChildDump(v8Dump, 'heaps'); - - containerDump.memoryAllocatorDumps = [oilpanDump, v8Dump]; - - var visitedAllocatorDumps = []; - containerDump.iterateRootAllocatorDumps( - function(dump) { this.visitedAllocatorDumps.push(dump); }, - { visitedAllocatorDumps: visitedAllocatorDumps }); - assert.sameMembers(visitedAllocatorDumps, [oilpanDump, v8Dump]); - }); - - test('forceRebuildingMemoryAllocatorDumpByFullNameIndex', function() { - var containerDump = new ContainerMemoryDump(42); - - var v8Dump = new MemoryAllocatorDump(containerDump, 'v8'); - var v8HeapsDump = addChildDump(v8Dump, 'heaps'); - var v8HeapSmallDump = addChildDump(v8HeapsDump, 'S'); - - // Setting the memory allocator dumps should update the index properly. - containerDump.memoryAllocatorDumps = [v8Dump]; - assert.strictEqual( - containerDump.getMemoryAllocatorDumpByFullName('v8'), v8Dump); - assert.strictEqual(containerDump.getMemoryAllocatorDumpByFullName( - 'v8/heaps'), v8HeapsDump); - assert.strictEqual(containerDump.getMemoryAllocatorDumpByFullName( - 'v8/heaps/S'), v8HeapSmallDump); - - // Add a second grandchild (v8/heaps/L). - var v8HeapLargeDump = addChildDump(v8HeapsDump, 'L'); - - // Setting the memory allocator dumps again should update the index - // properly again. - containerDump.memoryAllocatorDumps = [v8Dump]; - assert.strictEqual( - containerDump.getMemoryAllocatorDumpByFullName('v8'), v8Dump); - assert.strictEqual(containerDump.getMemoryAllocatorDumpByFullName( - 'v8/heaps'), v8HeapsDump); - assert.strictEqual(containerDump.getMemoryAllocatorDumpByFullName( - 'v8/heaps/S'), v8HeapSmallDump); - assert.strictEqual(containerDump.getMemoryAllocatorDumpByFullName( - 'v8/heaps/L'), v8HeapLargeDump); - - // Remove the first grandchild (v8/heaps/S). - v8HeapsDump.children.splice(0, 1); - - // Force rebuilding the index and check that it was updated properly. - containerDump.forceRebuildingMemoryAllocatorDumpByFullNameIndex(); - assert.strictEqual( - containerDump.getMemoryAllocatorDumpByFullName('v8'), v8Dump); - assert.strictEqual(containerDump.getMemoryAllocatorDumpByFullName( - 'v8/heaps'), v8HeapsDump); - assert.isUndefined(containerDump.getMemoryAllocatorDumpByFullName( - 'v8/heaps/S')); - assert.strictEqual(containerDump.getMemoryAllocatorDumpByFullName( - 'v8/heaps/L'), v8HeapLargeDump); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/counter.html b/chromium/third_party/catapult/tracing/tracing/model/counter.html deleted file mode 100644 index 74c0991c91f..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/counter.html +++ /dev/null @@ -1,195 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/guid.html"> -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/model/counter_series.html"> -<link rel="import" href="/tracing/model/event_container.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - - /** - * A container holding all series of a given type of measurement. - * - * As an example, if we're measuring the throughput of data sent over several - * USB connections, the throughput of each cable might be added as a separate - * series to a single counter. - * - * @constructor - * @extends {EventContainer} - */ - function Counter(parent, id, category, name) { - tr.model.EventContainer.call(this); - - this.parent_ = parent; - this.id_ = id; - this.category_ = category || ''; - this.name_ = name; - - this.series_ = []; - this.totals = []; - } - - Counter.prototype = { - __proto__: tr.model.EventContainer.prototype, - - get parent() { - return this.parent_; - }, - - get id() { - return this.id_; - }, - - get category() { - return this.category_; - }, - - get name() { - return this.name_; - }, - - childEvents: function*() { - }, - - childEventContainers: function*() { - yield * this.series; - }, - - set timestamps(arg) { - throw new Error('Bad counter API. No cookie.'); - }, - - set seriesNames(arg) { - throw new Error('Bad counter API. No cookie.'); - }, - - set seriesColors(arg) { - throw new Error('Bad counter API. No cookie.'); - }, - - set samples(arg) { - throw new Error('Bad counter API. No cookie.'); - }, - - addSeries: function(series) { - series.counter = this; - series.seriesIndex = this.series_.length; - this.series_.push(series); - return series; - }, - - getSeries: function(idx) { - return this.series_[idx]; - }, - - get series() { - return this.series_; - }, - - get numSeries() { - return this.series_.length; - }, - - get numSamples() { - if (this.series_.length === 0) - return 0; - return this.series_[0].length; - }, - - get timestamps() { - if (this.series_.length === 0) - return []; - return this.series_[0].timestamps; - }, - - /** - * Obtains min, max, avg, values, start, and end for different series for - * a given counter - * getSampleStatistics([0,1]) - * The statistics objects that this returns are an array of objects, one - * object for each series for the counter in the form: - * {min: minVal, max: maxVal, avg: avgVal, start: startVal, end: endVal} - * - * @param {Array.<Number>} Indices to summarize. - * @return {Object} An array of statistics. Each element in the array - * has data for one of the series in the selected counter. - */ - getSampleStatistics: function(sampleIndices) { - sampleIndices.sort(); - - var ret = []; - this.series_.forEach(function(series) { - ret.push(series.getStatistics(sampleIndices)); - }); - return ret; - }, - - /** - * Shifts all the timestamps inside this counter forward by the amount - * specified. - */ - shiftTimestampsForward: function(amount) { - for (var i = 0; i < this.series_.length; ++i) - this.series_[i].shiftTimestampsForward(amount); - }, - - /** - * Updates the bounds for this counter based on the samples it contains. - */ - updateBounds: function() { - this.totals = []; - this.maxTotal = 0; - this.bounds.reset(); - - if (this.series_.length === 0) - return; - - var firstSeries = this.series_[0]; - var lastSeries = this.series_[this.series_.length - 1]; - - this.bounds.addValue(firstSeries.getTimestamp(0)); - this.bounds.addValue(lastSeries.getTimestamp(lastSeries.length - 1)); - - var numSeries = this.numSeries; - this.maxTotal = -Infinity; - - // Sum the samples at each timestamp. - // Note, this assumes that all series have all timestamps. - for (var i = 0; i < firstSeries.length; ++i) { - var total = 0; - this.series_.forEach(function(series) { - total += series.getSample(i).value; - this.totals.push(total); - }.bind(this)); - - this.maxTotal = Math.max(total, this.maxTotal); - } - } - }; - - /** - * Comparison between counters that orders by parent.compareTo, then name. - */ - Counter.compare = function(x, y) { - var tmp = x.parent.compareTo(y); - if (tmp != 0) - return tmp; - var tmp = x.name.localeCompare(y.name); - if (tmp == 0) - return x.tid - y.tid; - return tmp; - }; - - return { - Counter: Counter - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/counter_sample.html b/chromium/third_party/catapult/tracing/tracing/model/counter_sample.html deleted file mode 100644 index f188afcc845..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/counter_sample.html +++ /dev/null @@ -1,105 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/base/sorted_array_utils.html"> -<link rel="import" href="/tracing/model/event.html"> -<link rel="import" href="/tracing/model/event_registry.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - - /** - * The value of a given measurement at a given time. - * - * As an example, if we're measuring the throughput of data sent over a USB - * connection, each counter sample might represent the instantaneous - * throughput of the connection at a given time. - * - * @constructor - * @extends {Event} - */ - function CounterSample(series, timestamp, value) { - tr.model.Event.call(this); - this.series_ = series; - this.timestamp_ = timestamp; - this.value_ = value; - } - - CounterSample.groupByTimestamp = function(samples) { - var samplesByTimestamp = tr.b.group(samples, function(sample) { - return sample.timestamp; - }); - - var timestamps = tr.b.dictionaryKeys(samplesByTimestamp); - timestamps.sort(); - var groups = []; - for (var i = 0; i < timestamps.length; i++) { - var ts = timestamps[i]; - var group = samplesByTimestamp[ts]; - group.sort(function(x, y) { - return x.series.seriesIndex - y.series.seriesIndex; - }); - groups.push(group); - } - return groups; - }; - - CounterSample.prototype = { - __proto__: tr.model.Event.prototype, - - get series() { - return this.series_; - }, - - get timestamp() { - return this.timestamp_; - }, - - get value() { - return this.value_; - }, - - set timestamp(timestamp) { - this.timestamp_ = timestamp; - }, - - addBoundsToRange: function(range) { - range.addValue(this.timestamp); - }, - - getSampleIndex: function() { - return tr.b.findLowIndexInSortedArray( - this.series.timestamps, - function(x) { return x; }, - this.timestamp_); - }, - - get userFriendlyName() { - return 'Counter sample from ' + this.series_.title + ' at ' + - tr.v.Unit.byName.timeStampInMs.format(this.timestamp); - } - }; - - - tr.model.EventRegistry.register( - CounterSample, - { - name: 'counterSample', - pluralName: 'counterSamples', - singleViewElementName: 'tr-ui-a-counter-sample-sub-view', - multiViewElementName: 'tr-ui-a-counter-sample-sub-view' - }); - - return { - CounterSample: CounterSample - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/counter_sample_test.html b/chromium/third_party/catapult/tracing/tracing/model/counter_sample_test.html deleted file mode 100644 index 09322c2d8ea..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/counter_sample_test.html +++ /dev/null @@ -1,47 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/counter.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Counter = tr.model.Counter; - var CounterSeries = tr.model.CounterSeries; - var CounterSample = tr.model.CounterSample; - - test('groupByTimestamp', function() { - var counter = new Counter(); - var s0 = counter.addSeries(new CounterSeries('x', 0)); - var s1 = counter.addSeries(new CounterSeries('y', 1)); - - var s0_0 = s0.addCounterSample(0, 100); - var s0_1 = s1.addCounterSample(0, 200); - var s1_0 = s0.addCounterSample(1, 100); - var s1_1 = s1.addCounterSample(1, 200); - - var groups = CounterSample.groupByTimestamp([s0_1, s0_0, - s1_1, s1_0]); - assert.equal(groups.length, 2); - assert.deepEqual(groups[0], [s0_0, s0_1]); - assert.deepEqual(groups[1], [s1_0, s1_1]); - }); - - test('getSampleIndex', function() { - var ctr = new Counter(null, 0, '', 'myCounter'); - var s0 = new CounterSeries('a', 0); - ctr.addSeries(s0); - - var s0_0 = s0.addCounterSample(0, 0); - var s0_1 = s0.addCounterSample(1, 100); - assert.equal(s0_0.getSampleIndex(), 0); - assert.equal(s0_1.getSampleIndex(), 1); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/counter_series.html b/chromium/third_party/catapult/tracing/tracing/model/counter_series.html deleted file mode 100644 index ac1463c381a..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/counter_series.html +++ /dev/null @@ -1,125 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/counter_sample.html"> -<link rel="import" href="/tracing/model/event_container.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - var CounterSample = tr.model.CounterSample; - - /** - * A container holding all samples of a given measurement over time. - * - * As an example, a counter series might measure the throughput of data sent - * over a USB connection, with each sample representing the instantaneous - * throughput of the connection. - * - * @constructor - * @extends {EventContainer} - */ - function CounterSeries(name, color) { - tr.model.EventContainer.call(this); - - this.name_ = name; - this.color_ = color; - - this.timestamps_ = []; - this.samples_ = []; - - // Set by counter.addSeries - this.counter = undefined; - this.seriesIndex = undefined; - } - - CounterSeries.prototype = { - __proto__: tr.model.EventContainer.prototype, - - get length() { - return this.timestamps_.length; - }, - - get name() { - return this.name_; - }, - - get color() { - return this.color_; - }, - - get samples() { - return this.samples_; - }, - - get timestamps() { - return this.timestamps_; - }, - - getSample: function(idx) { - return this.samples_[idx]; - }, - - getTimestamp: function(idx) { - return this.timestamps_[idx]; - }, - - addCounterSample: function(ts, val) { - var sample = new CounterSample(this, ts, val); - this.addSample(sample); - return sample; - }, - - addSample: function(sample) { - this.timestamps_.push(sample.timestamp); - this.samples_.push(sample); - }, - - getStatistics: function(sampleIndices) { - var sum = 0; - var min = Number.MAX_VALUE; - var max = -Number.MAX_VALUE; - - for (var i = 0; i < sampleIndices.length; ++i) { - var sample = this.getSample(sampleIndices[i]).value; - - sum += sample; - min = Math.min(sample, min); - max = Math.max(sample, max); - } - - return { - min: min, - max: max, - avg: (sum / sampleIndices.length), - start: this.getSample(sampleIndices[0]).value, - end: this.getSample(sampleIndices.length - 1).value - }; - }, - - shiftTimestampsForward: function(amount) { - for (var i = 0; i < this.timestamps_.length; ++i) { - this.timestamps_[i] += amount; - this.samples_[i].timestamp = this.timestamps_[i]; - } - }, - - childEvents: function*() { - yield * this.samples_; - }, - - childEventContainers: function*() { - } - }; - - return { - CounterSeries: CounterSeries - }; -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/counter_test.html b/chromium/third_party/catapult/tracing/tracing/model/counter_test.html deleted file mode 100644 index fef6fa76efe..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/counter_test.html +++ /dev/null @@ -1,109 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/counter.html"> -<link rel="import" href="/tracing/model/counter_series.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Counter = tr.model.Counter; - var CounterSeries = tr.model.CounterSeries; - var CounterSample = tr.model.CounterSample; - - var createCounterWithTwoSeries = function() { - var ctr = new Counter(null, 0, '', 'myCounter'); - var aSeries = new CounterSeries('a', 0); - var bSeries = new CounterSeries('b', 0); - ctr.addSeries(aSeries); - ctr.addSeries(bSeries); - - aSeries.addCounterSample(0, 5); - aSeries.addCounterSample(1, 6); - aSeries.addCounterSample(2, 5); - aSeries.addCounterSample(3, 7); - - bSeries.addCounterSample(0, 10); - bSeries.addCounterSample(1, 15); - bSeries.addCounterSample(2, 12); - bSeries.addCounterSample(3, 16); - - return ctr; - }; - - test('getSampleStatisticsWithSingleSelection', function() { - var ctr = createCounterWithTwoSeries(); - var ret = ctr.getSampleStatistics([0]); - - assert.equal(ret[0].min, 5); - assert.equal(ret[0].max, 5); - assert.equal(ret[0].avg, 5); - assert.equal(ret[0].start, 5); - assert.equal(ret[0].end, 5); - - assert.equal(ret[1].min, 10); - assert.equal(ret[1].max, 10); - assert.equal(ret[1].avg, 10); - assert.equal(ret[1].start, 10); - assert.equal(ret[1].end, 10); - }); - - test('getSampleStatisticsWithMultipleSelections', function() { - var ctr = createCounterWithTwoSeries(); - var ret = ctr.getSampleStatistics([0, 1]); - - assert.equal(ret[0].min, 5); - assert.equal(ret[0].max, 6); - assert.equal(ret[0].avg, (5 + 6) / 2); - assert.equal(ret[0].start, 5); - assert.equal(ret[0].end, 6); - - assert.equal(ret[1].min, 10); - assert.equal(ret[1].max, 15); - assert.equal(ret[1].avg, (10 + 15) / 2); - assert.equal(ret[1].start, 10); - assert.equal(ret[1].end, 15); - }); - - test('getSampleStatisticsWithOutofOrderIndices', function() { - var ctr = createCounterWithTwoSeries(); - var ret = ctr.getSampleStatistics([1, 0]); - - assert.equal(ret[0].min, 5); - assert.equal(ret[0].max, 6); - assert.equal(ret[0].avg, (5 + 6) / 2); - assert.equal(ret[0].start, 5); - assert.equal(ret[0].end, 6); - - assert.equal(ret[1].min, 10); - assert.equal(ret[1].max, 15); - assert.equal(ret[1].avg, (10 + 15) / 2); - assert.equal(ret[1].start, 10); - assert.equal(ret[1].end, 15); - }); - - test('getSampleStatisticsWithAllSelections', function() { - var ctr = createCounterWithTwoSeries(); - var ret = ctr.getSampleStatistics([1, 0, 2, 3]); - - assert.equal(ret[0].min, 5); - assert.equal(ret[0].max, 7); - assert.equal(ret[0].avg, (5 + 6 + 5 + 7) / 4); - assert.equal(ret[0].start, 5); - assert.equal(ret[0].end, 7); - - assert.equal(ret[1].min, 10); - assert.equal(ret[1].max, 16); - assert.equal(ret[1].avg, (10 + 15 + 12 + 16) / 4); - assert.equal(ret[1].start, 10); - assert.equal(ret[1].end, 16); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/cpu.html b/chromium/third_party/catapult/tracing/tracing/model/cpu.html deleted file mode 100644 index 2194e462185..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/cpu.html +++ /dev/null @@ -1,273 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/model/counter.html"> -<link rel="import" href="/tracing/model/cpu_slice.html"> -<link rel="import" href="/tracing/model/process_base.html"> -<link rel="import" href="/tracing/model/thread_time_slice.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the Cpu class. - */ -tr.exportTo('tr.model', function() { - - var ColorScheme = tr.b.ColorScheme; - var Counter = tr.model.Counter; - var CpuSlice = tr.model.CpuSlice; - var Slice = tr.model.Slice; - - /** - * The Cpu represents a Cpu from the kernel's point of view. - * @constructor - */ - function Cpu(kernel, number) { - if (kernel === undefined || number === undefined) - throw new Error('Missing arguments'); - this.kernel = kernel; - this.cpuNumber = number; - this.slices = []; - this.counters = {}; - this.bounds_ = new tr.b.Range(); - this.samples_ = undefined; // Set during createSubSlices - - // Start timestamp of the last active thread. - this.lastActiveTimestamp_ = undefined; - - // Identifier of the last active thread. On Linux, it's a pid while on - // Windows it's a thread id. - this.lastActiveThread_ = undefined; - - // Name and arguments of the last active thread. - this.lastActiveName_ = undefined; - this.lastActiveArgs_ = undefined; - }; - - Cpu.prototype = { - __proto__: tr.model.EventContainer.prototype, - - get samples() { - return this.samples_; - }, - - get userFriendlyName() { - return 'CPU ' + this.cpuNumber; - }, - - findTopmostSlicesInThisContainer: function*(eventPredicate, opt_this) { - // All CpuSlices are toplevel since CpuSlices do not nest. - for (var s of slices) { - yield * s.findTopmostSlicesRelativeToThisSlice( - eventPredicate, opt_this); - } - }, - - childEvents: function*() { - yield * this.slices; - - if (this.samples_) - yield * this.samples_; - }, - - childEventContainers: function*() { - yield * tr.b.dictionaryValues(this.counters); - }, - - /** - * @return {Counter} The counter on this CPU with the given category/name - * combination, creating it if it doesn't exist. - */ - getOrCreateCounter: function(cat, name) { - var id = cat + '.' + name; - if (!this.counters[id]) - this.counters[id] = new Counter(this, id, cat, name); - return this.counters[id]; - }, - - /** - * @return {Counter} the counter on this CPU with the given category/name - * combination, or undefined if it doesn't exist. - */ - getCounter: function(cat, name) { - var id = cat + '.' + name; - if (!this.counters[id]) - return undefined; - return this.counters[id]; - }, - - /** - * Shifts all the timestamps inside this CPU forward by the amount - * specified. - */ - shiftTimestampsForward: function(amount) { - for (var sI = 0; sI < this.slices.length; sI++) - this.slices[sI].start = (this.slices[sI].start + amount); - for (var id in this.counters) - this.counters[id].shiftTimestampsForward(amount); - }, - - /** - * Updates the range based on the current slices attached to the cpu. - */ - updateBounds: function() { - this.bounds_.reset(); - if (this.slices.length) { - this.bounds_.addValue(this.slices[0].start); - this.bounds_.addValue(this.slices[this.slices.length - 1].end); - } - for (var id in this.counters) { - this.counters[id].updateBounds(); - this.bounds_.addRange(this.counters[id].bounds); - } - if (this.samples_ && this.samples_.length) { - this.bounds_.addValue(this.samples_[0].start); - this.bounds_.addValue( - this.samples_[this.samples_.length - 1].end); - } - }, - - createSubSlices: function() { - this.samples_ = this.kernel.model.samples.filter(function(sample) { - return sample.cpu == this; - }, this); - }, - - addCategoriesToDict: function(categoriesDict) { - for (var i = 0; i < this.slices.length; i++) - categoriesDict[this.slices[i].category] = true; - for (var id in this.counters) - categoriesDict[this.counters[id].category] = true; - for (var i = 0; i < this.samples_.length; i++) - categoriesDict[this.samples_[i].category] = true; - }, - - - - /* - * Returns the index of the slice in the CPU's slices, or undefined. - */ - indexOf: function(cpuSlice) { - var i = tr.b.findLowIndexInSortedArray( - this.slices, - function(slice) { return slice.start; }, - cpuSlice.start); - if (this.slices[i] !== cpuSlice) - return undefined; - return i; - }, - - /** - * Closes the thread running on the CPU. |end_timestamp| is the timestamp - * at which the thread was unscheduled. |args| is merged with the arguments - * specified when the thread was initially scheduled. - */ - closeActiveThread: function(end_timestamp, args) { - // Don't generate a slice if the last active thread is the idle task. - if (this.lastActiveThread_ == undefined || this.lastActiveThread_ == 0) - return; - - if (end_timestamp < this.lastActiveTimestamp_) { - throw new Error('The end timestamp of a thread running on CPU ' + - this.cpuNumber + ' is before its start timestamp.'); - } - - // Merge |args| with |this.lastActiveArgs_|. If a key is in both - // dictionaries, the value from |args| is used. - for (var key in args) { - this.lastActiveArgs_[key] = args[key]; - } - - var duration = end_timestamp - this.lastActiveTimestamp_; - var slice = new tr.model.CpuSlice( - '', this.lastActiveName_, - ColorScheme.getColorIdForGeneralPurposeString(this.lastActiveName_), - this.lastActiveTimestamp_, - this.lastActiveArgs_, - duration); - slice.cpu = this; - this.slices.push(slice); - - // Clear the last state. - this.lastActiveTimestamp_ = undefined; - this.lastActiveThread_ = undefined; - this.lastActiveName_ = undefined; - this.lastActiveArgs_ = undefined; - }, - - switchActiveThread: function(timestamp, old_thread_args, new_thread_id, - new_thread_name, new_thread_args) { - // Close the previous active thread and generate a slice. - this.closeActiveThread(timestamp, old_thread_args); - - // Keep track of the new thread. - this.lastActiveTimestamp_ = timestamp; - this.lastActiveThread_ = new_thread_id; - this.lastActiveName_ = new_thread_name; - this.lastActiveArgs_ = new_thread_args; - }, - - /** - * Returns the frequency statistics for this CPU; - * the returned object contains the frequencies as keys, - * and the duration at this frequency in milliseconds as the value, - * for the range that was specified. - */ - getFreqStatsForRange: function(range) { - var stats = {}; - - function addStatsForFreq(freqSample, index) { - // Counters don't have an explicit end or duration; - // calculate the end by looking at the starting point - // of the next value in the series, or if that doesn't - // exist, assume this frequency is held until the end. - var freqEnd = (index < freqSample.series_.length - 1) ? - freqSample.series_.samples_[index + 1].timestamp : range.max; - - var freqRange = tr.b.Range.fromExplicitRange(freqSample.timestamp, - freqEnd); - var intersection = freqRange.findIntersection(range); - if (!(freqSample.value in stats)) - stats[freqSample.value] = 0; - stats[freqSample.value] += intersection.duration; - } - - var freqCounter = this.getCounter('', 'Clock Frequency'); - if (freqCounter !== undefined) { - var freqSeries = freqCounter.getSeries(0); - if (!freqSeries) - return; - - tr.b.iterateOverIntersectingIntervals(freqSeries.samples_, - function(x) { return x.timestamp; }, - function(x, index) { return index < freqSeries.length - 1 ? - freqSeries.samples_[index + 1].timestamp : - range.max; }, - range.min, - range.max, - addStatsForFreq); - } - - return stats; - } - }; - - /** - * Comparison between processes that orders by cpuNumber. - */ - Cpu.compare = function(x, y) { - return x.cpuNumber - y.cpuNumber; - }; - - - return { - Cpu: Cpu - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/cpu_slice.html b/chromium/third_party/catapult/tracing/tracing/model/cpu_slice.html deleted file mode 100644 index b646a3db0f9..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/cpu_slice.html +++ /dev/null @@ -1,68 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/model/thread_time_slice.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the CpuSlice class. - */ -tr.exportTo('tr.model', function() { - - var Slice = tr.model.Slice; - - /** - * A CpuSlice represents a slice of time on a CPU. - * - * @constructor - */ - function CpuSlice(cat, title, colorId, start, args, opt_duration) { - Slice.apply(this, arguments); - this.threadThatWasRunning = undefined; - this.cpu = undefined; - } - - CpuSlice.prototype = { - __proto__: Slice.prototype, - - get analysisTypeName() { - return 'tr.ui.analysis.CpuSlice'; - }, - - getAssociatedTimeslice: function() { - if (!this.threadThatWasRunning) - return undefined; - var timeSlices = this.threadThatWasRunning.timeSlices; - for (var i = 0; i < timeSlices.length; i++) { - var timeSlice = timeSlices[i]; - if (timeSlice.start !== this.start) - continue; - if (timeSlice.duration !== this.duration) - continue; - return timeSlice; - } - return undefined; - } - }; - - tr.model.EventRegistry.register( - CpuSlice, - { - name: 'cpuSlice', - pluralName: 'cpuSlices', - singleViewElementName: 'tr-ui-a-single-cpu-slice-sub-view', - multiViewElementName: 'tr-ui-a-multi-cpu-slice-sub-view' - }); - - return { - CpuSlice: CpuSlice - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/cpu_test.html b/chromium/third_party/catapult/tracing/tracing/model/cpu_test.html deleted file mode 100644 index 2ac7338e089..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/cpu_test.html +++ /dev/null @@ -1,202 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/model.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var ColorScheme = tr.b.ColorScheme; - var Cpu = tr.model.Cpu; - var newThreadSlice = tr.c.TestUtils.newThreadSlice; - - test('cpuBounds_Empty', function() { - var cpu = new Cpu({}, 1); - cpu.updateBounds(); - assert.isUndefined(cpu.bounds.min); - assert.isUndefined(cpu.bounds.max); - }); - - test('cpuBounds_OneSlice', function() { - var cpu = new Cpu({}, 1); - cpu.slices.push(tr.c.TestUtils.newSliceEx({start: 1, duration: 3})); - cpu.updateBounds(); - assert.equal(cpu.bounds.min, 1); - assert.equal(cpu.bounds.max, 4); - }); - - test('getOrCreateCounter', function() { - var cpu = new Cpu({}, 1); - var ctrBar = cpu.getOrCreateCounter('foo', 'bar'); - var ctrBar2 = cpu.getOrCreateCounter('foo', 'bar'); - assert.equal(ctrBar, ctrBar2); - }); - - test('shiftTimestampsForward', function() { - var cpu = new Cpu({}, 1); - var ctr = cpu.getOrCreateCounter('foo', 'bar'); - cpu.slices.push(tr.c.TestUtils.newSliceEx({start: 1, duration: 3})); - var shiftCount = 0; - ctr.shiftTimestampsForward = function(ts) { - if (ts == 0.32) - shiftCount++; - }; - cpu.slices.push(tr.c.TestUtils.newSliceEx({start: 1, duration: 3})); - cpu.shiftTimestampsForward(0.32); - assert.equal(1, shiftCount); - assert.equal(cpu.slices[0].start, 1.32); - }); - - - function newCpuSliceNamed(cpu, name, start, duration, opt_thread) { - var s = new tr.model.CpuSlice( - 'cat', name, 0, start, {}, duration); - s.cpu = cpu; - if (opt_thread) - s.threadThatWasRunning = opt_thread; - return s; - } - - test('getTimesliceForCpuSlice', function() { - var m = new tr.Model(); - var SCHEDULING_STATE = tr.model.SCHEDULING_STATE; - var cpu = m.kernel.getOrCreateCpu(1); - var t2 = m.getOrCreateProcess(1).getOrCreateThread(2); - t2.timeSlices = [newThreadSlice(t2, SCHEDULING_STATE.RUNNING, 0, 10, cpu), - newThreadSlice(t2, SCHEDULING_STATE.SLEEPING, 10, 10), - newThreadSlice(t2, SCHEDULING_STATE.RUNNING, 20, 10, cpu)]; - cpu.slices = [newCpuSliceNamed(cpu, 'x', 0, 10, t2), - newCpuSliceNamed(cpu, 'x', 20, 10, t2)]; - assert.equal(cpu.slices[0].getAssociatedTimeslice(), t2.timeSlices[0]); - assert.equal(cpu.slices[1].getAssociatedTimeslice(), t2.timeSlices[2]); - - assert.equal(t2.timeSlices[0].getAssociatedCpuSlice(), cpu.slices[0]); - assert.isUndefined(t2.timeSlices[1].getAssociatedCpuSlice()); - assert.equal(t2.timeSlices[2].getAssociatedCpuSlice(), cpu.slices[1]); - - assert.equal(cpu.indexOf(cpu.slices[0]), 0); - assert.equal(cpu.indexOf(cpu.slices[1]), 1); - - assert.equal(t2.indexOfTimeSlice(t2.timeSlices[0]), 0); - assert.equal(t2.indexOfTimeSlice(t2.timeSlices[1]), 1); - assert.equal(t2.indexOfTimeSlice(t2.timeSlices[2]), 2); - }); - - test('putToSleepFor', function() { - var m = new tr.Model(); - var SCHEDULING_STATE = tr.model.SCHEDULING_STATE; - var cpu = m.kernel.getOrCreateCpu(1); - - var t2 = m.getOrCreateProcess(1).getOrCreateThread(2); - var t3 = m.getOrCreateProcess(1).getOrCreateThread(3); - t2.timeSlices = [newThreadSlice(t2, SCHEDULING_STATE.RUNNING, 0, 10, cpu), - newThreadSlice(t2, SCHEDULING_STATE.SLEEPING, 10, 10), - newThreadSlice(t2, SCHEDULING_STATE.RUNNING, 20, 10, cpu)]; - t3.timeSlices = [newThreadSlice(t3, SCHEDULING_STATE.RUNNING, 10, 5, cpu)]; - cpu.slices = [newCpuSliceNamed(cpu, 'x', 0, 10, t2), - newCpuSliceNamed(cpu, 'x', 10, 5, t3), - newCpuSliceNamed(cpu, 'x', 20, 10, t2)]; - - // At timeslice 0, the thread is running. - assert.isUndefined(t2.timeSlices[0].getCpuSliceThatTookCpu()); - - // t2 lost the cpu to t3 at t=10 - assert.equal( - cpu.slices[1], - t2.timeSlices[1].getCpuSliceThatTookCpu()); - }); - - test('putToSleepForNothing', function() { - var m = new tr.Model(); - var SCHEDULING_STATE = tr.model.SCHEDULING_STATE; - var cpu = m.kernel.getOrCreateCpu(1); - - var t2 = m.getOrCreateProcess(1).getOrCreateThread(2); - var t3 = m.getOrCreateProcess(1).getOrCreateThread(3); - t2.timeSlices = [newThreadSlice(t2, SCHEDULING_STATE.RUNNING, 0, 10, cpu), - newThreadSlice(t2, SCHEDULING_STATE.SLEEPING, 10, 10), - newThreadSlice(t2, SCHEDULING_STATE.RUNNING, 20, 10, cpu)]; - t3.timeSlices = [newThreadSlice(t3, SCHEDULING_STATE.RUNNING, 15, 5, cpu)]; - cpu.slices = [newCpuSliceNamed(cpu, 'x', 0, 10, t2), - newCpuSliceNamed(cpu, 'x', 15, 5, t3), - newCpuSliceNamed(cpu, 'x', 20, 10, t2)]; - assert.isUndefined(t2.timeSlices[1].getCpuSliceThatTookCpu()); - }); - - test('switchActiveThread', function() { - var m = new tr.Model(); - var cpu = m.kernel.getOrCreateCpu(1); - - cpu.switchActiveThread(5, {}, 0, 'idle thread', {}); - cpu.switchActiveThread(10, {}, 1, 'thread one', {a: 1}); - cpu.switchActiveThread(15, {b: 2}, 2, 'thread two', {c: 3}); - cpu.switchActiveThread(30, {c: 4, d: 5}, 3, 'thread three', {e: 6}); - cpu.closeActiveThread(40, {f: 7}); - cpu.switchActiveThread(50, {}, 4, 'thread four', {g: 8}); - cpu.switchActiveThread(60, {}, 1, 'thread one', {}); - cpu.closeActiveThread(70, {}); - - assert.equal(cpu.slices.length, 5); - - assert.equal(cpu.slices[0].title, 'thread one'); - assert.equal(cpu.slices[0].start, 10); - assert.equal(cpu.slices[0].duration, 5); - assert.equal(Object.keys(cpu.slices[0].args).length, 2); - assert.equal(cpu.slices[0].args.a, 1); - assert.equal(cpu.slices[0].args.b, 2); - - assert.equal(cpu.slices[1].title, 'thread two'); - assert.equal(cpu.slices[1].start, 15); - assert.equal(cpu.slices[1].duration, 15); - assert.equal(Object.keys(cpu.slices[1].args).length, 2); - assert.equal(cpu.slices[1].args.c, 4); - assert.equal(cpu.slices[1].args.d, 5); - - assert.equal(cpu.slices[2].title, 'thread three'); - assert.equal(cpu.slices[2].start, 30); - assert.equal(cpu.slices[2].duration, 10); - assert.equal(Object.keys(cpu.slices[2].args).length, 2); - assert.equal(cpu.slices[2].args.e, 6); - assert.equal(cpu.slices[2].args.f, 7); - - assert.equal(cpu.slices[3].title, 'thread four'); - assert.equal(cpu.slices[3].start, 50); - assert.equal(cpu.slices[3].duration, 10); - assert.equal(Object.keys(cpu.slices[3].args).length, 1); - assert.equal(cpu.slices[3].args.g, 8); - - assert.equal(cpu.slices[4].title, 'thread one'); - assert.equal(cpu.slices[4].start, 60); - assert.equal(cpu.slices[4].duration, 10); - assert.equal(Object.keys(cpu.slices[4].args).length, 0); - }); - - test('getFrequencyStats', function() { - var m = new tr.Model(); - var cpu = m.kernel.getOrCreateCpu(1); - var powerCounter = cpu.getOrCreateCounter('', 'Clock Frequency'); - var series = powerCounter.addSeries(new tr.model.CounterSeries('state', - ColorScheme.getColorIdForGeneralPurposeString('test'))); - - series.addCounterSample(0, 100000); - series.addCounterSample(20, 300000); - series.addCounterSample(30, 100000); - series.addCounterSample(80, 500000); - series.addCounterSample(100, 300000); - - var range = tr.b.Range.fromExplicitRange(10, 90); - var stats = cpu.getFreqStatsForRange(range); - assert.equal(stats[100000], 60); - assert.equal(stats[300000], 10); - assert.equal(stats[500000], 10); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/device.html b/chromium/third_party/catapult/tracing/tracing/model/device.html deleted file mode 100644 index cbb1b2aa91a..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/device.html +++ /dev/null @@ -1,109 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/guid.html"> -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/model/event_container.html"> -<link rel="import" href="/tracing/model/power_series.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the Device class. - */ -tr.exportTo('tr.model', function() { - - /** - * Device represents the device-level objects in the model. - * @constructor - * @extends {tr.model.EventContainer} - */ - function Device(model) { - if (!model) - throw new Error('Must provide a model.'); - - tr.model.EventContainer.call(this); - - this.powerSeries_ = undefined; - this.vSyncTimestamps_ = []; - }; - - Device.compare = function(x, y) { - return x.guid - y.guid; - }; - - Device.prototype = { - __proto__: tr.model.EventContainer.prototype, - - compareTo: function(that) { - return Device.compare(this, that); - }, - - get userFriendlyName() { - return 'Device'; - }, - - get userFriendlyDetails() { - return 'Device'; - }, - - get stableId() { - return 'Device'; - }, - - getSettingsKey: function() { - return 'device'; - }, - - get powerSeries() { - return this.powerSeries_; - }, - - set powerSeries(powerSeries) { - this.powerSeries_ = powerSeries; - }, - - get vSyncTimestamps() { - return this.vSyncTimestamps_; - }, - - set vSyncTimestamps(value) { - this.vSyncTimestamps_ = value; - }, - - updateBounds: function() { - this.bounds.reset(); - for (var child of this.childEventContainers()) { - child.updateBounds(); - this.bounds.addRange(child.bounds); - } - }, - - shiftTimestampsForward: function(amount) { - for (var child of this.childEventContainers()) { - child.shiftTimestampsForward(amount); - } - - for (var i = 0; i < this.vSyncTimestamps_.length; i++) - this.vSyncTimestamps_[i] += amount; - }, - - addCategoriesToDict: function(categoriesDict) { - }, - - childEventContainers: function*() { - if (this.powerSeries_) - yield this.powerSeries_; - } - }; - - return { - Device: Device - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/device_test.html b/chromium/third_party/catapult/tracing/tracing/model/device_test.html deleted file mode 100644 index 5457e65a1ff..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/device_test.html +++ /dev/null @@ -1,71 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/device.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/power_series.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - - var Device = tr.model.Device; - var Model = tr.Model; - var PowerSeries = tr.model.PowerSeries; - - test('updateBounds', function() { - var device = new Device(new Model()); - device.powerSeries = new PowerSeries(device); - - // Verify that the bounds match the lowest and highest timestamps. - device.powerSeries.addPowerSample(100, 5); - device.powerSeries.addPowerSample(200, 5); - device.updateBounds(); - - assert.equal(device.bounds.min, 100); - assert.equal(device.bounds.max, 200); - - // Add a new sample and verify that the bounds change. - device.powerSeries.addPowerSample(700, 5); - device.updateBounds(); - - assert.equal(device.bounds.min, 100); - assert.equal(device.bounds.max, 700); - }); - - test('shiftTimestampsForward', function() { - var device = new Device(new Model()); - device.powerSeries = new PowerSeries(device); - - device.powerSeries.addPowerSample(100, 2); - device.powerSeries.addPowerSample(200, 2); - device.shiftTimestampsForward(2); - - assert.equal(device.powerSeries.samples[0].start, 102); - assert.equal(device.powerSeries.samples[1].start, 202); - }); - - test('childEventContainers_noPowerSeries', function() { - var device = new Device(new Model()); - var childEventContainers = []; - for (var container of device.childEventContainers()) - childEventContainers.push(container); - assert.deepEqual(childEventContainers, []); - }); - - test('childEventContainers_powerSeries', function() { - var device = new Device(new Model()); - device.powerSeries = new PowerSeries(device); - var childEventContainers = []; - for (var container of device.childEventContainers()) - childEventContainers.push(container); - assert.deepEqual(childEventContainers, [device.powerSeries]); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/event.html b/chromium/third_party/catapult/tracing/tracing/model/event.html deleted file mode 100644 index 10ab2f3c22b..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/event.html +++ /dev/null @@ -1,69 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/guid.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/selectable_item.html"> -<link rel="import" href="/tracing/model/selection_state.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the Event class. - */ -tr.exportTo('tr.model', function() { - var SelectableItem = tr.model.SelectableItem; - var SelectionState = tr.model.SelectionState; - var IMMUTABLE_EMPTY_SET = tr.model.EventSet.IMMUTABLE_EMPTY_SET; - - /** - * An Event is the base type for any non-container, selectable piece - * of data in the trace model. - * - * @constructor - * @extends {SelectableItem} - */ - function Event() { - SelectableItem.call(this, this /* modelItem */); - this.guid_ = tr.b.GUID.allocateSimple(); - this.selectionState = SelectionState.NONE; - this.info = undefined; - } - - Event.prototype = { - __proto__: SelectableItem.prototype, - - get guid() { - return this.guid_; - }, - - get stableId() { - return undefined; - }, - - // Empty by default. Lazily initialized on an instance in - // addAssociatedAlert(). See #1930. - associatedAlerts: IMMUTABLE_EMPTY_SET, - - addAssociatedAlert: function(alert) { - if (this.associatedAlerts === IMMUTABLE_EMPTY_SET) - this.associatedAlerts = new tr.model.EventSet(); - this.associatedAlerts.push(alert); - }, - - /** Adds the range of timestamps for this event to the specified range. */ - addBoundsToRange: function(range) { - throw new Error('Not implemented'); - } - }; - - return { - Event: Event - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/event_container.html b/chromium/third_party/catapult/tracing/tracing/model/event_container.html deleted file mode 100644 index 48b5d943d37..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/event_container.html +++ /dev/null @@ -1,141 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> -<link rel="import" href="/tracing/base/guid.html"> -<link rel="import" href="/tracing/base/range.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - - /** - * EventContainer is a base class for any class in the trace model that - * contains child events or child EventContainers. - * - * For all EventContainers, updateBounds() must be called after modifying the - * container's events if an up-to-date bounds is expected. - * - * @constructor - */ - function EventContainer() { - this.guid_ = tr.b.GUID.allocateSimple(); - this.important = true; - this.bounds_ = new tr.b.Range(); - } - - EventContainer.prototype = { - get guid() { - return this.guid_; - }, - - /** - * @return {String} A stable and unique identifier that describes this - * container's position in the event tree relative to the root. If an event - * container 'B' is a child to another event container 'A', then container - * B's stable ID would be 'A.B'. - */ - get stableId() { - throw new Error('Not implemented'); - }, - - /** - * Returns the bounds of the event container, which describe the range - * of timestamps for all ancestor events. - */ - get bounds() { - return this.bounds_; - }, - - // TODO(charliea): A default implementation of this method could likely be - // provided that iterates throuch getDescendantEvents. - /** - * Updates the bounds of the event container. After updating, this.bounds - * will describe the range of timestamps of all ancestor events. - */ - updateBounds: function() { - throw new Error('Not implemented'); - }, - - // TODO(charliea): A default implementation of this method could likely be - // provided that iterates through getDescendantEvents. - /** - * Shifts the timestamps for ancestor events by 'amount' milliseconds. - */ - shiftTimestampsForward: function(amount) { - throw new Error('Not implemented'); - }, - - - /** - * Returns an iterable of all child events. - */ - childEvents: function*() { - }, - - /** - * Returns an iterable of all events in this and descendant - * event containers. - */ - getDescendantEvents: function*() { - yield * this.childEvents(); - for (var container of this.childEventContainers()) - yield * container.getDescendantEvents(); - }, - - /** - * Returns an iterable of all child event containers. - */ - childEventContainers: function*() { - }, - - /** - * Returns an iterable containing this and all descendant event containers. - */ - getDescendantEventContainers: function*() { - yield this; - for (var container of this.childEventContainers()) - yield * container.getDescendantEventContainers(); - }, - - /** - * Finds topmost slices in this container (see docstring for - * findTopmostSlices). - */ - findTopmostSlicesInThisContainer: function*(eventPredicate, opt_this) { - }, - - /** - * The findTopmostSlices* series of helpers find all topmost slices - * satisfying the given predicates. - * - * As an example, suppose we are trying to find slices named 'C', with the - * following thread: - * - * -> |---C---| |-----D-----| - * |-C-| |---C---| <- - * - * findTopmostSlices would locate the pointed-to Cs, because the bottom C on - * the left is not the topmost C, and the right one is, even though it is - * not itself a top-level slice. - */ - findTopmostSlices: function*(eventPredicate) { - for (var ec of this.getDescendantEventContainers()) - yield * ec.findTopmostSlicesInThisContainer(eventPredicate); - }, - - findTopmostSlicesNamed: function*(name) { - yield * this.findTopmostSlices(e => e.title === name); - } - }; - - return { - EventContainer: EventContainer - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/event_info.html b/chromium/third_party/catapult/tracing/tracing/model/event_info.html deleted file mode 100644 index 5c3ff53c813..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/event_info.html +++ /dev/null @@ -1,39 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/color_scheme.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - var ColorScheme = tr.b.ColorScheme; - - /** - * EventInfo is an annotation added to Events in order to document - * what they represent, and override their title/colorId values. - * - * TODO(ccraik): eventually support more complex structure/paragraphs. - * - * @param {string} title A user-visible title for the event. - * @param {string} description A user-visible description of the event. - * @param {Array} docLinks A list of Objects, each of the form - * {label: str, textContent: str, href: str} - * - * @constructor - */ - function EventInfo(title, description, docLinks) { - this.title = title; - this.description = description; - this.docLinks = docLinks; - this.colorId = ColorScheme.getColorIdForGeneralPurposeString(title); - } - - return { - EventInfo: EventInfo - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/event_registry.html b/chromium/third_party/catapult/tracing/tracing/model/event_registry.html deleted file mode 100644 index ec2c1ebe3a8..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/event_registry.html +++ /dev/null @@ -1,87 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/extension_registry.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the EventRegistry class. - */ -tr.exportTo('tr.model', function() { - // Create the type registry. - function EventRegistry() { - } - - var options = new tr.b.ExtensionRegistryOptions(tr.b.BASIC_REGISTRY_MODE); - tr.b.decorateExtensionRegistry(EventRegistry, options); - - // Enforce all options objects have the right fields. - EventRegistry.addEventListener('will-register', function(e) { - var metadata = e.typeInfo.metadata; - - if (metadata.name === undefined) - throw new Error('Registered events must provide name metadata'); - var i = tr.b.findFirstInArray( - EventRegistry.getAllRegisteredTypeInfos(), - function(x) { return x.metadata.name === metadata.name; }); - if (i !== undefined) - throw new Error('Event type with that name already registered'); - - if (metadata.pluralName === undefined) - throw new Error('Registered events must provide pluralName metadata'); - if (metadata.singleViewElementName === undefined) { - throw new Error('Registered events must provide ' + - 'singleViewElementName metadata'); - } - if (metadata.multiViewElementName === undefined) { - throw new Error('Registered events must provide ' + - 'multiViewElementName metadata'); - } - }); - - // Helper: lookup Events indexed by type name. - var eventsByTypeName = undefined; - EventRegistry.getEventTypeInfoByTypeName = function(typeName) { - if (eventsByTypeName === undefined) { - eventsByTypeName = {}; - EventRegistry.getAllRegisteredTypeInfos().forEach(function(typeInfo) { - eventsByTypeName[typeInfo.metadata.name] = typeInfo; - }); - } - return eventsByTypeName[typeName]; - } - - // Ensure eventsByTypeName stays current. - EventRegistry.addEventListener('registry-changed', function() { - eventsByTypeName = undefined; - }); - - function convertCamelCaseToTitleCase(name) { - var result = name.replace(/[A-Z]/g, ' $&'); - result = result.charAt(0).toUpperCase() + result.slice(1); - return result; - } - - EventRegistry.getUserFriendlySingularName = function(typeName) { - var typeInfo = EventRegistry.getEventTypeInfoByTypeName(typeName); - var str = typeInfo.metadata.name; - return convertCamelCaseToTitleCase(str); - }; - - EventRegistry.getUserFriendlyPluralName = function(typeName) { - var typeInfo = EventRegistry.getEventTypeInfoByTypeName(typeName); - var str = typeInfo.metadata.pluralName; - return convertCamelCaseToTitleCase(str); - }; - - return { - EventRegistry: EventRegistry - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/event_set.html b/chromium/third_party/catapult/tracing/tracing/model/event_set.html deleted file mode 100644 index c79ddc85302..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/event_set.html +++ /dev/null @@ -1,309 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2012 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/event.html"> -<link rel="import" href="/tracing/base/guid.html"> -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/model/event_registry.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - - var EventRegistry = tr.model.EventRegistry; - - var RequestSelectionChangeEvent = tr.b.Event.bind( - undefined, 'requestSelectionChange', true, false); - - /** - * Represents a event set within a and its associated set of tracks. - * @constructor - */ - function EventSet(opt_events) { - this.bounds_dirty_ = true; - this.bounds_ = new tr.b.Range(); - this.length_ = 0; - this.guid_ = tr.b.GUID.allocateSimple(); - this.pushed_guids_ = {}; - - if (opt_events) { - if (opt_events instanceof Array) { - for (var i = 0; i < opt_events.length; i++) - this.push(opt_events[i]); - } else if (opt_events instanceof EventSet) { - this.addEventSet(opt_events); - } else { - this.push(opt_events); - } - } - } - EventSet.prototype = { - __proto__: Object.prototype, - - get bounds() { - if (this.bounds_dirty_) - this.resolveBounds_(); - return this.bounds_; - }, - - get duration() { - if (this.bounds_.isEmpty) - return 0; - return this.bounds_.max - this.bounds_.min; - }, - - get length() { - return this.length_; - }, - - get guid() { - return this.guid_; - }, - - *[Symbol.iterator]() { - for (var i = 0; i < this.length_; ++i) - yield this[i]; - }, - - clear: function() { - for (var i = 0; i < this.length_; ++i) - delete this[i]; - this.length_ = 0; - this.bounds_dirty_ = true; - }, - - resolveBounds_: function() { - this.bounds_.reset(); - for (var i = 0; i < this.length_; i++) - this[i].addBoundsToRange(this.bounds_); - this.bounds_dirty_ = false; - }, - - // push pushes only unique events. - // If an event has been already pushed, do nothing. - push: function(event) { - if (event.guid == undefined) - throw new Error('Event must have a GUID'); - - if (this.contains(event)) - return event; - - this.pushed_guids_[event.guid] = true; - this[this.length_++] = event; - this.bounds_dirty_ = true; - return event; - }, - - contains: function(event) { - return this.pushed_guids_[event.guid]; - }, - - indexOf: function(event) { - for (var i = 0; i < this.length; i++) { - if (this[i].guid === event.guid) - return i; - } - return -1; - }, - - addEventSet: function(eventSet) { - for (var i = 0; i < eventSet.length; i++) - this.push(eventSet[i]); - }, - - subEventSet: function(index, count) { - count = count || 1; - - var eventSet = new EventSet(); - eventSet.bounds_dirty_ = true; - if (index < 0 || index + count > this.length_) - throw new Error('Index out of bounds'); - - for (var i = index; i < index + count; i++) - eventSet.push(this[i]); - - return eventSet; - }, - - intersectionIsEmpty: function(otherEventSet) { - return !this.some(function(event) { - return otherEventSet.contains(event); - }); - }, - - equals: function(that) { - if (this.length !== that.length) - return false; - for (var i = 0; i < this.length; i++) { - var event = this[i]; - if (that.pushed_guids_[event.guid] === undefined) - return false; - } - return true; - }, - - getEventsOrganizedByBaseType: function(opt_pruneEmpty) { - var allTypeInfos = EventRegistry.getAllRegisteredTypeInfos(); - - var events = this.getEventsOrganizedByCallback(function(event) { - var maxEventIndex = -1; - var maxEventTypeInfo = undefined; - - allTypeInfos.forEach(function(eventTypeInfo, eventIndex) { - if (!(event instanceof eventTypeInfo.constructor)) - return; - if (eventIndex > maxEventIndex) { - maxEventIndex = eventIndex; - maxEventTypeInfo = eventTypeInfo; - } - }); - - if (maxEventIndex == -1) { - console.log(event); - throw new Error('Unrecognized event type'); - } - - return maxEventTypeInfo.metadata.name; - }); - - if (!opt_pruneEmpty) { - allTypeInfos.forEach(function(eventTypeInfo) { - if (events[eventTypeInfo.metadata.name] === undefined) - events[eventTypeInfo.metadata.name] = new EventSet(); - }); - } - - return events; - }, - - getEventsOrganizedByTitle: function() { - return this.getEventsOrganizedByCallback(function(event) { - if (event.title === undefined) - throw new Error('An event didn\'t have a title!'); - return event.title; - }); - }, - - getEventsOrganizedByCallback: function(cb) { - var eventsByCallback = {}; - for (var i = 0; i < this.length; i++) { - var event = this[i]; - var key = cb(event); - - if (key === undefined) - throw new Error('An event could not be organized'); - - if (eventsByCallback[key] === undefined) - eventsByCallback[key] = new EventSet(); - - eventsByCallback[key].push(event); - } - return eventsByCallback; - }, - - enumEventsOfType: function(type, func) { - for (var i = 0; i < this.length_; i++) - if (this[i] instanceof type) - func(this[i]); - }, - - get userFriendlyName() { - if (this.length === 0) { - throw new Error('Empty event set'); - } - - var eventsByBaseType = this.getEventsOrganizedByBaseType(true); - var eventTypeName = tr.b.dictionaryKeys(eventsByBaseType)[0]; - - if (this.length === 1) { - var tmp = EventRegistry.getUserFriendlySingularName(eventTypeName); - return this[0].userFriendlyName; - } - - var numEventTypes = tr.b.dictionaryLength(eventsByBaseType); - if (numEventTypes !== 1) { - return this.length + ' events of various types'; - } - - var tmp = EventRegistry.getUserFriendlyPluralName(eventTypeName); - return this.length + ' ' + tmp; - }, - - filter: function(fn, opt_this) { - var res = new EventSet(); - - this.forEach(function(slice) { - if (fn.call(this, slice)) - res.push(slice); - }, opt_this); - - return res; - }, - - toArray: function() { - var ary = []; - for (var i = 0; i < this.length; i++) - ary.push(this[i]); - return ary; - }, - - forEach: function(fn, opt_this) { - for (var i = 0; i < this.length; i++) - fn.call(opt_this, this[i], i); - }, - - map: function(fn, opt_this) { - var res = []; - for (var i = 0; i < this.length; i++) - res.push(fn.call(opt_this, this[i], i)); - return res; - }, - - every: function(fn, opt_this) { - for (var i = 0; i < this.length; i++) - if (!fn.call(opt_this, this[i], i)) - return false; - return true; - }, - - some: function(fn, opt_this) { - for (var i = 0; i < this.length; i++) - if (fn.call(opt_this, this[i], i)) - return true; - return false; - }, - - asDict: function() { - var stable_ids = []; - this.forEach(function(event) { - stable_ids.push(event.stableId); - }); - return {'events': stable_ids}; - } - }; - - EventSet.IMMUTABLE_EMPTY_SET = (function() { - var s = new EventSet(); - s.resolveBounds_(); - s.push = function() { - throw new Error('Cannot push to an immutable event set'); - }; - s.addEventSet = function() { - throw new Error('Cannot add to an immutable event set'); - }; - Object.freeze(s); - return s; - })(); - - return { - EventSet: EventSet, - RequestSelectionChangeEvent: RequestSelectionChangeEvent - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/event_set_test.html b/chromium/third_party/catapult/tracing/tracing/model/event_set_test.html deleted file mode 100644 index 9fbfd995059..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/event_set_test.html +++ /dev/null @@ -1,326 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/model.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var newModel = tr.c.TestUtils.newModel; - var newSliceEx = tr.c.TestUtils.newSliceEx; - - test('eventSetObject', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var t1 = p1.getOrCreateThread(1); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'a', 0, 1, {}, 3)); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'a', 0, 5, {}, 1)); - - var eventSet = new tr.model.EventSet(); - eventSet.push(t1.sliceGroup.slices[0]); - - assert.equal(eventSet.bounds.min, 1); - assert.equal(eventSet.bounds.max, 4); - assert.equal(eventSet[0], t1.sliceGroup.slices[0]); - - eventSet.push(t1.sliceGroup.slices[1]); - assert.equal(eventSet.bounds.min, 1); - assert.equal(eventSet.bounds.max, 6); - assert.equal(eventSet[1], t1.sliceGroup.slices[1]); - - eventSet.clear(); - assert.equal(eventSet.length, 0); - }); - - test('iteration', function() { - var eventSet = new tr.model.EventSet([{guid: 1}, {guid: 2}, {guid: 3}]); - - var expectedId = 1; - for (var event of eventSet) - assert.equal(event.guid, expectedId++); - }); - - test('uniqueContents', function() { - var sample1 = {guid: 1}; - var sample2 = {guid: 2}; - - var eventSet = new tr.model.EventSet(); - - eventSet.push(sample1); - eventSet.push(sample2); - assert.equal(eventSet.length, 2); - - eventSet.push(sample1); - assert.equal(eventSet.length, 2); - }); - - test('userFriendlyNameSingular', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var t1 = p1.getOrCreateThread(1); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'a', 0, 1, {}, 3)); - var selection = new tr.model.EventSet(t1.sliceGroup.slices[0]); - assert.isDefined(selection.userFriendlyName); - }); - - test('userFriendlyNamePlural', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var t1 = p1.getOrCreateThread(1); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'a', 0, 1, {}, 3)); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'a', 0, 2, {}, 3)); - var eventSet = new tr.model.EventSet([ - t1.sliceGroup.slices[0], - t1.sliceGroup.slices[1] - ]); - assert.isDefined(eventSet.userFriendlyName); - }); - - test('userFriendlyNameMixedPlural', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var t1 = p1.getOrCreateThread(1); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'a', 0, 1, {}, 3)); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'a', 0, 2, {}, 3)); - - var i10 = new tr.model.ObjectInstance( - {}, '0x1000', 'cat', 'name', 10); - var s10 = i10.addSnapshot(10, {foo: 1}); - - var eventSet = new tr.model.EventSet([ - t1.sliceGroup.slices[0], - s10 - ]); - assert.isDefined(eventSet.userFriendlyName); - }); - - test('groupEventsByTitle', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var t1 = p1.getOrCreateThread(1); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'a', 0, 1, {}, 3)); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'a', 0, 2, {}, 3)); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'b', 0, 3, {}, 3)); - var eventSet = new tr.model.EventSet([ - t1.sliceGroup.slices[0], - t1.sliceGroup.slices[1], - t1.sliceGroup.slices[2] - ]); - - var eventsByTitle = eventSet.getEventsOrganizedByTitle(); - assert.equal(2, tr.b.dictionaryLength(eventsByTitle)); - assert.sameMembers(eventsByTitle['a'].toArray(), - [t1.sliceGroup.slices[0], t1.sliceGroup.slices[1]]); - assert.sameMembers(eventsByTitle['b'].toArray(), - [t1.sliceGroup.slices[2]]); - }); - - test('groupEventsByCallback', function() { - var a1 = new tr.model.ThreadSlice('', 'a', 0, 1, {}, 3); - var a2 = new tr.model.ThreadSlice('', 'a', 0, 2, {}, 3); - var b1 = new tr.model.ThreadSlice('', 'b', 0, 1, {}, 3); - var eventSet = new tr.model.EventSet([a1, a2, b1]); - function getEventKey(event) { - return 's' + event.start; - } - var eventsByCallback = eventSet.getEventsOrganizedByCallback(getEventKey); - assert.equal(2, tr.b.dictionaryLength(eventsByCallback)); - assert.sameMembers(eventsByCallback.s1.toArray(), [a1, b1]); - assert.sameMembers(eventsByCallback.s2.toArray(), [a2]); - }); - - test('groupEventsByBaseType', function() { - var a = new tr.model.ThreadSlice('', 'a', 0, 1, {}, 3); - var b = new tr.model.ThreadSlice('', 'b', 0, 1, {}, 3); - var c = new tr.model.AsyncSlice('', 'c', 0, 1, {}, 3); - var eventSet = new tr.model.EventSet([a, b, c]); - var eventsByBaseType = eventSet.getEventsOrganizedByBaseType(true); - assert.equal(2, tr.b.dictionaryLength(eventsByBaseType)); - assert.sameMembers(eventsByBaseType.slice.toArray(), [a, b]); - assert.sameMembers(eventsByBaseType.asyncSlice.toArray(), [c]); - - var eventsByBaseType = eventSet.getEventsOrganizedByBaseType(false); - assert.isTrue(2 < tr.b.dictionaryLength(eventsByBaseType)); - assert.sameMembers(eventsByBaseType.slice.toArray(), [a, b]); - assert.sameMembers(eventsByBaseType.asyncSlice.toArray(), [c]); - for (var baseType in eventsByBaseType) { - if (baseType !== 'slice' && baseType !== 'asyncSlice') - assert.equal(0, eventsByBaseType[baseType].length); - } - }); - - test('intersectionIsEmpty1', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var t1 = p1.getOrCreateThread(1); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'a', 0, 1, {}, 3)); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'a', 0, 2, {}, 3)); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'b', 0, 3, {}, 3)); - - var set1 = new tr.model.EventSet([ - t1.sliceGroup.slices[0], - t1.sliceGroup.slices[1], - t1.sliceGroup.slices[2] - ]); - var set2 = new tr.model.EventSet([ - t1.sliceGroup.slices[2] - ]); - assert.isFalse(set1.intersectionIsEmpty(set2)); - }); - - test('intersectionIsNonEmpty2', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var t1 = p1.getOrCreateThread(1); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'a', 0, 1, {}, 3)); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'a', 0, 2, {}, 3)); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'b', 0, 3, {}, 3)); - - var set1 = new tr.model.EventSet([ - t1.sliceGroup.slices[0], - t1.sliceGroup.slices[1] - ]); - var set2 = new tr.model.EventSet([ - t1.sliceGroup.slices[2] - ]); - assert.isTrue(set1.intersectionIsEmpty(set2)); - }); - - test('equals', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var t1 = p1.getOrCreateThread(1); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'a', 0, 1, {}, 3)); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'b', 0, 2, {}, 3)); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'c', 0, 3, {}, 3)); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'd', 0, 4, {}, 5)); - - var eventSet1 = new tr.model.EventSet([ - t1.sliceGroup.slices[0], - t1.sliceGroup.slices[1], - t1.sliceGroup.slices[2] - ]); - var eventSet2 = new tr.model.EventSet([ - t1.sliceGroup.slices[1], - t1.sliceGroup.slices[0], - t1.sliceGroup.slices[2] - ]); - var eventSet3 = new tr.model.EventSet([ - t1.sliceGroup.slices[1], - t1.sliceGroup.slices[0], - t1.sliceGroup.slices[3] - ]); - var eventSet4 = new tr.model.EventSet([ - t1.sliceGroup.slices[1], - t1.sliceGroup.slices[0] - ]); - assert.isTrue(eventSet1.equals(eventSet2)); - assert.isFalse(eventSet1.equals(eventSet3)); - assert.isFalse(eventSet1.equals(eventSet4)); - }); - - test('filter', function() { - var m = newModel(function(m) { - - var p = m.getOrCreateProcess(1); - var t = p.getOrCreateThread(1); - - m.s0 = t.sliceGroup.pushSlice(newSliceEx( - { title: 's0', start: 0.0, duration: 1.0 })); - m.s1 = t.sliceGroup.pushSlice(newSliceEx( - { title: 's1', start: 0.0, duration: 1.0 })); - m.s2 = t.sliceGroup.pushSlice(newSliceEx( - { title: 's2', start: 0.0, duration: 1.0 })); - - m.eventSet = new tr.model.EventSet([m.s0, m.s1, m.s2]); - }); - - var res = m.eventSet.filter(function(slice) { - return slice.title === 's0'; - }); - - assert.isTrue(res.equals(new tr.model.EventSet([m.s0]))); - }); - - test('toArray', function() { - var samples = [ - {guid: 1}, - {guid: 2} - ]; - var eventSet = new tr.model.EventSet(samples); - - assert.deepEqual(eventSet.toArray(), samples); - }); - - test('asDict', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var t1 = p1.getOrCreateThread(1); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'a', 0, 1, {}, 3)); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'b', 0, 2, {}, 3)); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'c', 0, 3, {}, 3)); - t1.sliceGroup.pushSlice( - new tr.model.ThreadSlice('', 'd', 0, 4, {}, 5)); - - var eventSet = new tr.model.EventSet([ - t1.sliceGroup.slices[0], - t1.sliceGroup.slices[1], - t1.sliceGroup.slices[2] - ]); - - assert.deepEqual( - {'events': - ['1.1.SliceGroup.0', '1.1.SliceGroup.1', '1.1.SliceGroup.2']}, - eventSet.asDict()); - }); - - test('immutableEmptySet', function() { - var s = tr.model.EventSet.IMMUTABLE_EMPTY_SET; - assert.lengthOf(s, 0); - assert.isTrue(s.bounds.isEmpty); - - // Check that the iteration methods still work correctly. - function throwOnCall() { - throw new Error('This function should never be called!!!'); - } - assert.deepEqual(s.map(throwOnCall), []); - s.forEach(throwOnCall); - - // Check that the set is indeed immutable. - assert.throws(function() { s[0] = b; }); - assert.throws(function() { s.push(b); }); - assert.throws(function() { s.addEventSet(new tr.model.EventSet()); }); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/event_test.html b/chromium/third_party/catapult/tracing/tracing/model/event_test.html deleted file mode 100644 index 0d0deca55af..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/event_test.html +++ /dev/null @@ -1,46 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/alert.html"> -<link rel="import" href="/tracing/model/event.html"> -<link rel="import" href="/tracing/model/event_info.html"> -<link rel="import" href="/tracing/model/event_set.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Alert = tr.model.Alert; - var Event = tr.model.Event; - var EventInfo = tr.model.EventInfo; - var EventSet = tr.model.EventSet; - var ImmutableEventSet = tr.model.ImmutableEventSet; - - test('checkModelItem', function() { - var event = new Event; - assert.equal(event.modelItem, event); - }); - - test('checkAssociatedAlerts', function() { - var event = new Event(); - assert.strictEqual(event.associatedAlerts, EventSet.IMMUTABLE_EMPTY_SET); - assert.sameMembers(event.associatedAlerts.toArray(), []); - - var info1 = new EventInfo('Critical', 'Critical alert!!!', []); - var alert1 = new Alert(info1, 7); - event.addAssociatedAlert(alert1); - assert.instanceOf(event.associatedAlerts, EventSet); - assert.sameMembers(event.associatedAlerts.toArray(), [alert1]); - - var info2 = new EventInfo('Warning', 'Warning alert???', []); - var alert2 = new Alert(info2, 42); - event.addAssociatedAlert(alert2); - assert.instanceOf(event.associatedAlerts, EventSet); - assert.sameMembers(event.associatedAlerts.toArray(), [alert1, alert2]); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/flow_event.html b/chromium/third_party/catapult/tracing/tracing/model/flow_event.html deleted file mode 100644 index bffb8661a7d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/flow_event.html +++ /dev/null @@ -1,68 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/timed_event.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the Flow class. - */ -tr.exportTo('tr.model', function() { - /** - * A Flow represents an interval of time plus parameters associated - * with that interval. - * - * @constructor - */ - function FlowEvent(category, id, title, colorId, start, args, opt_duration) { - tr.model.TimedEvent.call(this, start); - - this.category = category || ''; - this.title = title; - this.colorId = colorId; - this.start = start; - this.args = args; - - this.id = id; - - this.startSlice = undefined; - this.endSlice = undefined; - - this.startStackFrame = undefined; - this.endStackFrame = undefined; - - if (opt_duration !== undefined) - this.duration = opt_duration; - } - - FlowEvent.prototype = { - __proto__: tr.model.TimedEvent.prototype, - - get userFriendlyName() { - return 'Flow event named ' + this.title + ' at ' + - tr.v.Unit.byName.timeStampInMs.format(this.timestamp); - } - }; - - tr.model.EventRegistry.register( - FlowEvent, - { - name: 'flowEvent', - pluralName: 'flowEvents', - singleViewElementName: 'tr-ui-a-single-flow-event-sub-view', - multiViewElementName: 'tr-ui-a-multi-flow-event-sub-view' - }); - - return { - FlowEvent: FlowEvent - }; -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/frame.html b/chromium/third_party/catapult/tracing/tracing/model/frame.html deleted file mode 100644 index d6bc6195bf2..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/frame.html +++ /dev/null @@ -1,98 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/color_scheme.html"> -<link rel="import" href="/tracing/base/statistics.html"> -<link rel="import" href="/tracing/model/event.html"> -<link rel="import" href="/tracing/model/event_set.html"> - -<script> -'use strict'; - -/** - * @fileoverview Class describing rendered frames. - * - * Because a frame is produced by multiple threads, it does not inherit from - * TimedEvent, and has no duration. - */ -tr.exportTo('tr.model', function() { - var ColorScheme = tr.b.ColorScheme; - var Statistics = tr.b.Statistics; - - var FRAME_PERF_CLASS = { - GOOD: 'good', - BAD: 'bad', - TERRIBLE: 'terrible', - NEUTRAL: 'generic_work' - }; - - /** - * @constructor - * @param {Array} associatedEvents Selection of events composing the frame. - * @param {Array} threadTimeRanges Array of {thread, start, end} - * for each thread, describing the critical path of the frame. - */ - function Frame(associatedEvents, threadTimeRanges, opt_args) { - tr.model.Event.call(this); - - this.threadTimeRanges = threadTimeRanges; - this.associatedEvents = new tr.model.EventSet(associatedEvents); - this.args = opt_args || {}; - - this.title = 'Frame'; - this.start = Statistics.min( - threadTimeRanges, function(x) { return x.start; }); - this.end = Statistics.max( - threadTimeRanges, function(x) { return x.end; }); - this.totalDuration = Statistics.sum( - threadTimeRanges, function(x) { return x.end - x.start; }); - - this.perfClass = FRAME_PERF_CLASS.NEUTRAL; - }; - - Frame.prototype = { - __proto__: tr.model.Event.prototype, - - set perfClass(perfClass) { - this.colorId = ColorScheme.getColorIdForReservedName(perfClass); - this.perfClass_ = perfClass; - }, - - get perfClass() { - return this.perfClass_; - }, - - shiftTimestampsForward: function(amount) { - this.start += amount; - this.end += amount; - - for (var i = 0; i < this.threadTimeRanges.length; i++) { - this.threadTimeRanges[i].start += amount; - this.threadTimeRanges[i].end += amount; - } - }, - - addBoundsToRange: function(range) { - range.addValue(this.start); - range.addValue(this.end); - } - }; - - tr.model.EventRegistry.register( - Frame, - { - name: 'frame', - pluralName: 'frames', - singleViewElementName: 'tr-ui-a-single-frame-sub-view', - multiViewElementName: 'tr-ui-a-multi-frame-sub-view' - }); - - return { - Frame: Frame, - FRAME_PERF_CLASS: FRAME_PERF_CLASS - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/global_memory_dump.html b/chromium/third_party/catapult/tracing/tracing/model/global_memory_dump.html deleted file mode 100644 index 80bb03ff361..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/global_memory_dump.html +++ /dev/null @@ -1,870 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/model/container_memory_dump.html"> -<link rel="import" href="/tracing/model/event_registry.html"> -<link rel="import" href="/tracing/model/memory_allocator_dump.html"> -<link rel="import" href="/tracing/value/numeric.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the GlobalMemoryDump class. - */ -tr.exportTo('tr.model', function() { - /** - * The GlobalMemoryDump represents a simultaneous memory dump of all - * processes. - * @constructor - */ - function GlobalMemoryDump(model, start) { - tr.model.ContainerMemoryDump.call(this, start); - this.model = model; - this.processMemoryDumps = {}; - } - - // Size numeric names. - var SIZE_NUMERIC_NAME = tr.model.MemoryAllocatorDump.SIZE_NUMERIC_NAME; - var EFFECTIVE_SIZE_NUMERIC_NAME = - tr.model.MemoryAllocatorDump.EFFECTIVE_SIZE_NUMERIC_NAME; - - // Size numeric info types. - var MemoryAllocatorDumpInfoType = tr.model.MemoryAllocatorDumpInfoType; - var PROVIDED_SIZE_LESS_THAN_AGGREGATED_CHILDREN = - MemoryAllocatorDumpInfoType.PROVIDED_SIZE_LESS_THAN_AGGREGATED_CHILDREN; - var PROVIDED_SIZE_LESS_THAN_LARGEST_OWNER = - MemoryAllocatorDumpInfoType.PROVIDED_SIZE_LESS_THAN_LARGEST_OWNER; - - // TODO(petrcermak): Move this to tracing/base/iteration_helpers.html. - function inPlaceFilter(array, predicate, opt_this) { - opt_this = opt_this || this; - var nextPosition = 0; - for (var i = 0; i < array.length; i++) { - if (!predicate.call(opt_this, array[i], i)) - continue; - if (nextPosition < i) - array[nextPosition] = array[i]; // Move elements only if necessary. - nextPosition++; - } - - if (nextPosition < array.length) - array.length = nextPosition; // Truncate the array only if necessary. - } - - function getSize(dump) { - var numeric = dump.numerics[SIZE_NUMERIC_NAME]; - if (numeric === undefined) - return 0; - return numeric.value; - } - - function hasSize(dump) { - return dump.numerics[SIZE_NUMERIC_NAME] !== undefined; - } - - function optional(value, defaultValue) { - if (value === undefined) - return defaultValue; - return value; - } - - GlobalMemoryDump.prototype = { - __proto__: tr.model.ContainerMemoryDump.prototype, - - get userFriendlyName() { - return 'Global memory dump at ' + - tr.v.Unit.byName.timeStampInMs.format(this.start); - }, - - get containerName() { - return 'global space'; - }, - - finalizeGraph: function() { - // 1. Transitively remove weak memory allocator dumps and all their - // owners and descendants from the model. This must be performed before - // any other steps. - this.removeWeakDumps(); - - // 2. Add ownership links from tracing MADs to descendants of malloc or - // winheap MADs so that tracing would be automatically discounted from - // them later (step 3). - this.setUpTracingOverheadOwnership(); - - // 3. Aggregate all other numerics of all MADs (*excluding* sizes and - // effective sizes) and propagate numerics from global MADs to their - // owners (*including* sizes and effective sizes). This step must be - // carried out before the sizes of all MADs are calculated (step 3). - // Otherwise, the propagated sizes of all MADs would not be aggregated. - this.aggregateNumerics(); - - // 4. Calculate the sizes of all memory allocator dumps (MADs). This step - // requires that the memory allocator dump graph has been finalized (step - // 1) and numerics were propagated from global MADs (step 2). Subsequent - // modifications of the graph will most likely break the calculation - // invariants. - this.calculateSizes(); - - // 5. Calculate the effective sizes of all MADs. This step requires that - // the sizes of all MADs have already been calculated (step 3). - this.calculateEffectiveSizes(); - - // 6. Discount tracing from VM regions stats. This steps requires that - // resident sizes (step 2) and sizes (step 3) of the tracing MADs have - // already been calculated. - this.discountTracingOverheadFromVmRegions(); - - // 7. The above steps (especially steps 1 and 3) can create new memory - // allocator dumps, so we force rebuilding the memory allocator dump - // indices of all container memory dumps. - this.forceRebuildingMemoryAllocatorDumpByFullNameIndices(); - }, - - removeWeakDumps: function() { - // Mark all transitive owners and children of weak memory allocator dumps - // as weak. - this.traverseAllocatorDumpsInDepthFirstPreOrder(function(dump) { - if (dump.weak) - return; - if ((dump.owns !== undefined && dump.owns.target.weak) || - (dump.parent !== undefined && dump.parent.weak)) { - dump.weak = true; - } - }); - - function removeWeakDumpsFromListRecursively(dumps) { - inPlaceFilter(dumps, function(dump) { - if (dump.weak) { - // The dump is weak, so remove it. This will implicitly remove all - // its descendants, which are also weak due to the initial marking - // step. - return false; - } - - // This dump is non-weak, so keep it. Recursively remove its weak - // descendants and ownership links from weak dumps instead. - removeWeakDumpsFromListRecursively(dump.children); - inPlaceFilter(dump.ownedBy, function(ownershipLink) { - return !ownershipLink.source.weak; - }); - - return true; - }); - } - - this.iterateContainerDumps(function(containerDump) { - var memoryAllocatorDumps = containerDump.memoryAllocatorDumps; - if (memoryAllocatorDumps !== undefined) - removeWeakDumpsFromListRecursively(memoryAllocatorDumps); - }); - }, - - /** - * Calculate the size of all memory allocator dumps in the dump graph. - * - * The size refers to the allocated size of a (sub)component. It is a - * natural extension of the optional size numeric provided by - * MemoryAllocatorDump(s): - * - * - If a MAD provides a size numeric, then its size is assumed to be - * equal to it. - * - If a MAD does not provide a size numeric, then its size is assumed - * to be the maximum of (1) the size of the largest owner of the MAD - * and (2) the aggregated size of the MAD's children. - * - * Metric motivation: "How big is a (sub)system?" - * - * Please refer to the Memory Dump Graph Metric Calculation design document - * for more details (https://goo.gl/fKg0dt). - */ - calculateSizes: function() { - this.traverseAllocatorDumpsInDepthFirstPostOrder( - this.calculateMemoryAllocatorDumpSize_.bind(this)); - }, - - /** - * Calculate the size of the given MemoryAllocatorDump. This method assumes - * that the size of both the children and owners of the dump has already - * been calculated. - */ - calculateMemoryAllocatorDumpSize_: function(dump) { - // This flag becomes true if the size numeric of the current dump should - // be defined, i.e. if (1) the current dump's size numeric is defined, - // (2) the size of at least one of its children is defined or (3) the - // size of at least one of its owners is defined. - var shouldDefineSize = false; - - // This helper function returns the value of the size numeric of the - // given dependent memory allocator dump. If the numeric is defined, the - // shouldDefineSize flag above is also set to true (because condition - // (2) or (3) is satisfied). Otherwise, zero is returned (and the flag is - // left unchanged). - function getDependencySize(dependencyDump) { - var numeric = dependencyDump.numerics[SIZE_NUMERIC_NAME]; - if (numeric === undefined) - return 0; - shouldDefineSize = true; - return numeric.value; - } - - // 1. Get the size provided by the dump. If present, define a function - // for checking dependent size consistency (a dump must always be bigger - // than all its children aggregated together and/or its largest owner). - var sizeNumeric = dump.numerics[SIZE_NUMERIC_NAME]; - var size = 0; - var checkDependencySizeIsConsistent = function() { /* no-op */ }; - if (sizeNumeric !== undefined) { - size = sizeNumeric.value; - shouldDefineSize = true; - if (sizeNumeric.unit !== tr.v.Unit.byName.sizeInBytes_smallerIsBetter) { - this.model.importWarning({ - type: 'memory_dump_parse_error', - message: 'Invalid unit of \'size\' numeric of memory allocator ' + - 'dump ' + dump.quantifiedName + ': ' + - sizeNumeric.unit.unitName + '.' - }); - } - checkDependencySizeIsConsistent = function( - dependencySize, dependencyInfoType, dependencyName) { - if (size >= dependencySize) - return; - this.model.importWarning({ - type: 'memory_dump_parse_error', - message: 'Size provided by memory allocator dump \'' + - dump.fullName + '\'' + - tr.v.Unit.byName.sizeInBytes.format(size) + - ') is less than ' + dependencyName + ' (' + - tr.v.Unit.byName.sizeInBytes.format(dependencySize) + ').' - }); - dump.infos.push({ - type: dependencyInfoType, - providedSize: size, - dependencySize: dependencySize - }); - }.bind(this); - } - - // 2. Aggregate size of children. The recursive function traverses all - // descendants and ensures that double-counting due to ownership within a - // subsystem is avoided. - var aggregatedChildrenSize = 0; - // Owned child dump name -> (Owner child dump name -> overlapping size). - var allOverlaps = {}; - dump.children.forEach(function(childDump) { - function aggregateDescendantDump(descendantDump) { - // Don't count this descendant dump if it owns another descendant of - // the current dump (would cause double-counting). - var ownedDumpLink = descendantDump.owns; - if (ownedDumpLink !== undefined && - ownedDumpLink.target.isDescendantOf(dump)) { - // If the target owned dump is a descendant of a *different* child - // of the the current dump (i.e. not childDump), then we remember - // the ownership so that we could explain why the size of the - // current dump is not equal to the sum of its children. - var ownedChildDump = ownedDumpLink.target; - while (ownedChildDump.parent !== dump) - ownedChildDump = ownedChildDump.parent; - if (childDump !== ownedChildDump) { - var ownedBySiblingSize = getDependencySize(descendantDump); - if (ownedBySiblingSize > 0) { - var previousTotalOwnedBySiblingSize = - ownedChildDump.ownedBySiblingSizes.get(childDump) || 0; - var updatedTotalOwnedBySiblingSize = - previousTotalOwnedBySiblingSize + ownedBySiblingSize; - ownedChildDump.ownedBySiblingSizes.set( - childDump, updatedTotalOwnedBySiblingSize); - } - } - return; - } - - // If this descendant dump is a leaf node, add its size to the - // aggregated size. - if (descendantDump.children.length === 0) { - aggregatedChildrenSize += getDependencySize(descendantDump); - return; - } - - // If this descendant dump is an intermediate node, recurse down into - // its children. Note that the dump's size is NOT added because it is - // an aggregate of its children (would cause double-counting). - descendantDump.children.forEach(aggregateDescendantDump); - } - aggregateDescendantDump(childDump); - }); - checkDependencySizeIsConsistent( - aggregatedChildrenSize, - PROVIDED_SIZE_LESS_THAN_AGGREGATED_CHILDREN, - 'the aggregated size of its children'); - - // 3. Calculate the largest owner size. - var largestOwnerSize = 0; - dump.ownedBy.forEach(function(ownershipLink) { - var owner = ownershipLink.source; - var ownerSize = getDependencySize(owner); - largestOwnerSize = Math.max(largestOwnerSize, ownerSize); - }); - checkDependencySizeIsConsistent( - largestOwnerSize, - PROVIDED_SIZE_LESS_THAN_LARGEST_OWNER, - 'the size of its largest owner'); - - // If neither the dump nor any of its dependencies (children and owners) - // provide a size, do NOT add a zero size numeric. - if (!shouldDefineSize) { - // The rest of the pipeline relies on size being either a valid - // ScalarNumeric, or undefined. - delete dump.numerics[SIZE_NUMERIC_NAME]; - return; - } - - // A dump must always be bigger than all its children aggregated - // together and/or its largest owner. - size = Math.max(size, aggregatedChildrenSize, largestOwnerSize); - - dump.numerics[SIZE_NUMERIC_NAME] = new tr.v.ScalarNumeric( - tr.v.Unit.byName.sizeInBytes_smallerIsBetter, size); - - // Add a virtual child to make up for extra size of the dump with - // respect to its children (if applicable). - if (aggregatedChildrenSize < size && - dump.children !== undefined && dump.children.length > 0) { - var virtualChild = new tr.model.MemoryAllocatorDump( - dump.containerMemoryDump, dump.fullName + '/<unspecified>'); - virtualChild.parent = dump; - dump.children.unshift(virtualChild); - virtualChild.numerics[SIZE_NUMERIC_NAME] = new tr.v.ScalarNumeric( - tr.v.Unit.byName.sizeInBytes_smallerIsBetter, - size - aggregatedChildrenSize); - } - }, - - /** - * Calculate the effective size of all memory allocator dumps in the dump - * graph. - * - * The effective size refers to the amount of memory a particular component - * is using/consuming. In other words, every (reported) byte of used memory - * is uniquely attributed to exactly one component. Consequently, unlike - * size, effective size is cumulative, i.e. the sum of the effective sizes - * of (top-level) components is equal to the total amount of (reported) - * used memory. - * - * Metric motivation: "How much memory does a (sub)system use?" or "For how - * much memory should a (sub)system be 'charged'?" - * - * Please refer to the Memory Dump Graph Metric Calculation design document - * for more details (https://goo.gl/fKg0dt). - * - * This method assumes that the size of all contained memory allocator - * dumps has already been calculated [see calculateSizes()]. - */ - calculateEffectiveSizes: function() { - // 1. Calculate not-owned and not-owning sub-sizes of all MADs - // (depth-first post-order traversal). - this.traverseAllocatorDumpsInDepthFirstPostOrder( - this.calculateDumpSubSizes_.bind(this)); - - // 2. Calculate owned and owning coefficients of owned and owner MADs - // respectively (arbitrary traversal). - this.traverseAllocatorDumpsInDepthFirstPostOrder( - this.calculateDumpOwnershipCoefficient_.bind(this)); - - // 3. Calculate cumulative owned and owning coefficients of all MADs - // (depth-first pre-order traversal). - this.traverseAllocatorDumpsInDepthFirstPreOrder( - this.calculateDumpCumulativeOwnershipCoefficient_.bind(this)); - - // 4. Calculate the effective sizes of all MADs (depth-first post-order - // traversal). - this.traverseAllocatorDumpsInDepthFirstPostOrder( - this.calculateDumpEffectiveSize_.bind(this)); - }, - - /** - * Calculate not-owned and not-owning sub-sizes of a memory allocator dump - * from its children's (sub-)sizes. - * - * Not-owned sub-size refers to the aggregated memory of all children which - * is not owned by other MADs. Conversely, not-owning sub-size is the - * aggregated memory of all children which do not own another MAD. The - * diagram below illustrates these two concepts: - * - * ROOT 1 ROOT 2 - * size: 4 size: 5 - * not-owned sub-size: 4 not-owned sub-size: 1 (!) - * not-owning sub-size: 0 (!) not-owning sub-size: 5 - * - * ^ ^ - * | | - * - * PARENT 1 ===== owns =====> PARENT 2 - * size: 4 size: 5 - * not-owned sub-size: 4 not-owned sub-size: 5 - * not-owning sub-size: 4 not-owning sub-size: 5 - * - * ^ ^ - * | | - * - * CHILD 1 CHILD 2 - * size [given]: 4 size [given]: 5 - * not-owned sub-size: 4 not-owned sub-size: 5 - * not-owning sub-size: 4 not-owning sub-size: 5 - * - * This method assumes that (1) the size of the dump, its children, and its - * owners [see calculateSizes()] and (2) the not-owned and not-owning - * sub-sizes of both the children and owners of the dump have already been - * calculated [depth-first post-order traversal]. - */ - calculateDumpSubSizes_: function(dump) { - // Completely skip dumps with undefined size. - if (!hasSize(dump)) - return; - - // If the dump is a leaf node, then both sub-sizes are equal to the size. - if (dump.children === undefined || dump.children.length === 0) { - var size = getSize(dump); - dump.notOwningSubSize_ = size; - dump.notOwnedSubSize_ = size; - return; - } - - // Calculate this dump's not-owning sub-size by summing up the not-owning - // sub-sizes of children MADs which do not own another MAD. - var notOwningSubSize = 0; - dump.children.forEach(function(childDump) { - if (childDump.owns !== undefined) - return; - notOwningSubSize += optional(childDump.notOwningSubSize_, 0); - }); - dump.notOwningSubSize_ = notOwningSubSize; - - // Calculate this dump's not-owned sub-size. - var notOwnedSubSize = 0; - dump.children.forEach(function(childDump) { - // If the child dump is not owned, then add its not-owned sub-size. - if (childDump.ownedBy.length === 0) { - notOwnedSubSize += optional(childDump.notOwnedSubSize_, 0); - return; - } - // If the child dump is owned, then add the difference between its size - // and the largest owner. - var largestChildOwnerSize = 0; - childDump.ownedBy.forEach(function(ownershipLink) { - largestChildOwnerSize = Math.max( - largestChildOwnerSize, getSize(ownershipLink.source)); - }); - notOwnedSubSize += getSize(childDump) - largestChildOwnerSize; - }); - dump.notOwnedSubSize_ = notOwnedSubSize; - }, - - /** - * Calculate owned and owning coefficients of a memory allocator dump and - * its owners. - * - * The owning coefficient refers to the proportion of a dump's not-owning - * sub-size which is attributed to the dump (only relevant to owning MADs). - * Conversely, the owned coefficient is the proportion of a dump's - * not-owned sub-size, which is attributed to it (only relevant to owned - * MADs). - * - * The not-owned size of the owned dump is split among its owners in the - * order of the ownership importance as demonstrated by the following - * example: - * - * memory allocator dumps - * OWNED OWNER1 OWNER2 OWNER3 OWNER4 - * not-owned sub-size [given] 10 - - - - - * not-owning sub-size [given] - 6 7 5 8 - * importance [given] - 2 2 1 0 - * attributed not-owned sub-size 2 - - - - - * attributed not-owning sub-size - 3 4 0 1 - * owned coefficient 2/10 - - - - - * owning coefficient - 3/6 4/7 0/5 1/8 - * - * Explanation: Firstly, 6 bytes are split equally among OWNER1 and OWNER2 - * (highest importance). OWNER2 owns one more byte, so its attributed - * not-owning sub-size is 6/2 + 1 = 4 bytes. OWNER3 is attributed no size - * because it is smaller than the owners with higher priority. However, - * OWNER4 is larger, so it's attributed the difference 8 - 7 = 1 byte. - * Finally, 2 bytes remain unattributed and are hence kept in the OWNED - * dump as attributed not-owned sub-size. The coefficients are then - * directly calculated as fractions of the sub-sizes and corresponding - * attributed sub-sizes. - * - * Note that we always assume that all ownerships of a dump overlap (e.g. - * OWNER3 is subsumed by both OWNER1 and OWNER2). Hence, the table could - * be alternatively represented as follows: - * - * owned memory range - * 0 1 2 3 4 5 6 7 8 9 10 - * Priority 2 | OWNER1 + OWNER2 (split) | OWNER2 | - * Priority 1 | (already attributed) | - * Priority 0 | - - - (already attributed) - - - | OWNER4 | - * Remainder | - - - - - (already attributed) - - - - - - | OWNED | - * - * This method assumes that (1) the size of the dump [see calculateSizes()] - * and (2) the not-owned size of the dump and not-owning sub-sizes of its - * owners [see the first step of calculateEffectiveSizes()] have already - * been calculated. Note that the method doesn't make any assumptions about - * the order in which dumps are visited. - */ - calculateDumpOwnershipCoefficient_: function(dump) { - // Completely skip dumps with undefined size. - if (!hasSize(dump)) - return; - - // We only need to consider owned dumps. - if (dump.ownedBy.length === 0) - return; - - // Sort the owners in decreasing order of ownership importance and - // increasing order of not-owning sub-size (in case of equal importance). - var owners = dump.ownedBy.map(function(ownershipLink) { - return { - dump: ownershipLink.source, - importance: optional(ownershipLink.importance, 0), - notOwningSubSize: optional(ownershipLink.source.notOwningSubSize_, 0) - }; - }); - owners.sort(function(a, b) { - if (a.importance === b.importance) - return a.notOwningSubSize - b.notOwningSubSize; - return b.importance - a.importance; - }); - - // Loop over the list of owners and distribute the owned dump's not-owned - // sub-size among them according to their ownership importance and - // not-owning sub-size. - var currentImportanceStartPos = 0; - var alreadyAttributedSubSize = 0; - while (currentImportanceStartPos < owners.length) { - var currentImportance = owners[currentImportanceStartPos].importance; - - // Find the position of the first owner with lower priority. - var nextImportanceStartPos = currentImportanceStartPos + 1; - while (nextImportanceStartPos < owners.length && - owners[nextImportanceStartPos].importance === - currentImportance) { - nextImportanceStartPos++; - } - - // Visit the owners with the same importance in increasing order of - // not-owned sub-size, split the owned memory among them appropriately, - // and calculate their owning coefficients. - var attributedNotOwningSubSize = 0; - for (var pos = currentImportanceStartPos; pos < nextImportanceStartPos; - pos++) { - var owner = owners[pos]; - var notOwningSubSize = owner.notOwningSubSize; - if (notOwningSubSize > alreadyAttributedSubSize) { - attributedNotOwningSubSize += - (notOwningSubSize - alreadyAttributedSubSize) / - (nextImportanceStartPos - pos); - alreadyAttributedSubSize = notOwningSubSize; - } - - var owningCoefficient = 0; - if (notOwningSubSize !== 0) - owningCoefficient = attributedNotOwningSubSize / notOwningSubSize; - owner.dump.owningCoefficient_ = owningCoefficient; - } - - currentImportanceStartPos = nextImportanceStartPos; - } - - // Attribute the remainder of the owned dump's not-owned sub-size to - // the dump itself and calculate its owned coefficient. - var notOwnedSubSize = optional(dump.notOwnedSubSize_, 0); - var remainderSubSize = notOwnedSubSize - alreadyAttributedSubSize; - var ownedCoefficient = 0; - if (notOwnedSubSize !== 0) - ownedCoefficient = remainderSubSize / notOwnedSubSize; - dump.ownedCoefficient_ = ownedCoefficient; - }, - - /** - * Calculate cumulative owned and owning coefficients of a memory allocator - * dump from its (non-cumulative) owned and owning coefficients and the - * cumulative coefficients of its parent and/or owned dump. - * - * The cumulative coefficients represent the total effect of all - * (non-strict) ancestor ownerships on a memory allocator dump. The - * cumulative owned coefficient of a MAD can be calculated simply as: - * - * cumulativeOwnedC(M) = ownedC(M) * cumulativeOwnedC(parent(M)) - * - * This reflects the assumption that if a parent of a child MAD is - * (partially) owned, then the parent's owner also indirectly owns (a part - * of) the child MAD. - * - * The cumulative owning coefficient of a MAD depends on whether the MAD - * owns another dump: - * - * [if M doesn't own another MAD] - * / cumulativeOwningC(parent(M)) - * cumulativeOwningC(M) = - * \ [if M owns another MAD] - * owningC(M) * cumulativeOwningC(owned(M)) - * - * The reasoning behind the first case is similar to the one for cumulative - * owned coefficient above. The only difference is that we don't need to - * include the dump's (non-cumulative) owning coefficient because it is - * implicitly 1. - * - * The formula for the second case is derived as follows: Since the MAD - * owns another dump, its memory is not included in its parent's not-owning - * sub-size and hence shouldn't be affected by the parent's corresponding - * cumulative coefficient. Instead, the MAD indirectly owns everything - * owned by its owned dump (and so it should be affected by the - * corresponding coefficient). - * - * Note that undefined coefficients (and coefficients of non-existent - * dumps) are implicitly assumed to be 1. - * - * This method assumes that (1) the size of the dump [see calculateSizes()], - * (2) the (non-cumulative) owned and owning coefficients of the dump [see - * the second step of calculateEffectiveSizes()], and (3) the cumulative - * coefficients of the dump's parent and owned MADs (if present) - * [depth-first pre-order traversal] have already been calculated. - */ - calculateDumpCumulativeOwnershipCoefficient_: function(dump) { - // Completely skip dumps with undefined size. - if (!hasSize(dump)) - return; - - var cumulativeOwnedCoefficient = optional(dump.ownedCoefficient_, 1); - var parent = dump.parent; - if (dump.parent !== undefined) - cumulativeOwnedCoefficient *= dump.parent.cumulativeOwnedCoefficient_; - dump.cumulativeOwnedCoefficient_ = cumulativeOwnedCoefficient; - - var cumulativeOwningCoefficient; - if (dump.owns !== undefined) { - cumulativeOwningCoefficient = dump.owningCoefficient_ * - dump.owns.target.cumulativeOwningCoefficient_; - } else if (dump.parent !== undefined) { - cumulativeOwningCoefficient = dump.parent.cumulativeOwningCoefficient_; - } else { - cumulativeOwningCoefficient = 1; - } - dump.cumulativeOwningCoefficient_ = cumulativeOwningCoefficient; - }, - - /** - * Calculate the effective size of a memory allocator dump. - * - * In order to simplify the (already complex) calculation, we use the fact - * that effective size is cumulative (unlike regular size), i.e. the - * effective size of a non-leaf node is equal to the sum of effective sizes - * of its children. The effective size of a leaf MAD is calculated as: - * - * effectiveSize(M) = size(M) * cumulativeOwningC(M) * cumulativeOwnedC(M) - * - * This method assumes that (1) the size of the dump and its children [see - * calculateSizes()] and (2) the cumulative owning and owned coefficients - * of the dump (if it's a leaf node) [see the third step of - * calculateEffectiveSizes()] or the effective sizes of its children (if - * it's a non-leaf node) [depth-first post-order traversal] have already - * been calculated. - */ - calculateDumpEffectiveSize_: function(dump) { - // Completely skip dumps with undefined size. As a result, each dump will - // have defined effective size if and only if it has defined size. - if (!hasSize(dump)) { - // The rest of the pipeline relies on effective size being either a - // valid ScalarNumeric, or undefined. - delete dump.numerics[EFFECTIVE_SIZE_NUMERIC_NAME]; - return; - } - - var effectiveSize; - if (dump.children === undefined || dump.children.length === 0) { - // Leaf dump. - effectiveSize = getSize(dump) * dump.cumulativeOwningCoefficient_ * - dump.cumulativeOwnedCoefficient_; - } else { - // Non-leaf dump. - effectiveSize = 0; - dump.children.forEach(function(childDump) { - if (!hasSize(childDump)) - return; - effectiveSize += - childDump.numerics[EFFECTIVE_SIZE_NUMERIC_NAME].value; - }); - } - dump.numerics[EFFECTIVE_SIZE_NUMERIC_NAME] = new tr.v.ScalarNumeric( - tr.v.Unit.byName.sizeInBytes_smallerIsBetter, effectiveSize); - }, - - aggregateNumerics: function() { - // 1. Aggregate numerics in this global memory dump. - this.iterateRootAllocatorDumps(function(dump) { - dump.aggregateNumericsRecursively(this.model); - }); - - // 2. Propagate numerics and diagnostics from global memory allocator - // dumps to their owners. - this.iterateRootAllocatorDumps( - this.propagateNumericsAndDiagnosticsRecursively); - - // 3. Aggregate numerics in the associated process memory dumps. - tr.b.iterItems(this.processMemoryDumps, function(pid, processMemoryDump) { - processMemoryDump.iterateRootAllocatorDumps(function(dump) { - dump.aggregateNumericsRecursively(this.model); - }, this); - }, this); - }, - - propagateNumericsAndDiagnosticsRecursively: function(globalAllocatorDump) { - ['numerics', 'diagnostics'].forEach(function(field) { - tr.b.iterItems(globalAllocatorDump[field], function(name, value) { - globalAllocatorDump.ownedBy.forEach(function(ownershipLink) { - var processAllocatorDump = ownershipLink.source; - if (processAllocatorDump[field][name] !== undefined) { - // Numerics and diagnostics provided by process memory allocator - // dumps themselves have precedence over numerics and diagnostics - // propagated from global memory allocator dumps. - return; - } - processAllocatorDump[field][name] = value; - }); - }); - }); - - // Recursively propagate numerics from all child memory allocator dumps. - globalAllocatorDump.children.forEach( - this.propagateNumericsAndDiagnosticsRecursively, this); - }, - - setUpTracingOverheadOwnership: function() { - tr.b.iterItems(this.processMemoryDumps, function(pid, dump) { - dump.setUpTracingOverheadOwnership(this.model); - }, this); - }, - - discountTracingOverheadFromVmRegions: function() { - // TODO(petrcermak): Consider factoring out all the finalization code and - // constants to a single file. - tr.b.iterItems(this.processMemoryDumps, function(pid, dump) { - dump.discountTracingOverheadFromVmRegions(this.model); - }, this); - }, - - forceRebuildingMemoryAllocatorDumpByFullNameIndices: function() { - this.iterateContainerDumps(function(containerDump) { - containerDump.forceRebuildingMemoryAllocatorDumpByFullNameIndex(); - }); - }, - - iterateContainerDumps: function(fn) { - fn.call(this, this); - tr.b.iterItems(this.processMemoryDumps, function(pid, processDump) { - fn.call(this, processDump); - }, this); - }, - - iterateAllRootAllocatorDumps: function(fn) { - this.iterateContainerDumps(function(containerDump) { - containerDump.iterateRootAllocatorDumps(fn, this); - }); - }, - - /** - * Traverse the memory dump graph in a depth first post-order, i.e. - * children and owners of a memory allocator dump are visited before the - * dump itself. This method will throw an exception if the graph contains - * a cycle. - */ - traverseAllocatorDumpsInDepthFirstPostOrder: function(fn) { - var visitedDumps = new WeakSet(); - var openDumps = new WeakSet(); - - function visit(dump) { - if (visitedDumps.has(dump)) - return; - - if (openDumps.has(dump)) - throw new Error(dump.userFriendlyName + ' contains a cycle'); - openDumps.add(dump); - - // Visit owners before the dumps they own. - dump.ownedBy.forEach(function(ownershipLink) { - visit.call(this, ownershipLink.source); - }, this); - - // Visit children before parents. - dump.children.forEach(visit, this); - - // Actually visit the current memory allocator dump. - fn.call(this, dump); - visitedDumps.add(dump); - - openDumps.delete(dump); - } - - this.iterateAllRootAllocatorDumps(visit); - }, - - /** - * Traverse the memory dump graph in a depth first pre-order, i.e. - * children and owners of a memory allocator dump are visited after the - * dump itself. This method will not visit some dumps if the graph contains - * a cycle. - */ - traverseAllocatorDumpsInDepthFirstPreOrder: function(fn) { - var visitedDumps = new WeakSet(); - - function visit(dump) { - if (visitedDumps.has(dump)) - return; - - // If this dumps owns another dump which hasn't been visited yet, then - // wait for this dump to be visited later. - if (dump.owns !== undefined && !visitedDumps.has(dump.owns.target)) - return; - - // If this dump's parent hasn't been visited yet, then wait for this - // dump to be visited later. - if (dump.parent !== undefined && !visitedDumps.has(dump.parent)) - return; - - // Actually visit the current memory allocator dump. - fn.call(this, dump); - visitedDumps.add(dump); - - // Visit owners after the dumps they own. - dump.ownedBy.forEach(function(ownershipLink) { - visit.call(this, ownershipLink.source); - }, this); - - // Visit children after parents. - dump.children.forEach(visit, this); - } - - this.iterateAllRootAllocatorDumps(visit); - } - }; - - tr.model.EventRegistry.register( - GlobalMemoryDump, - { - name: 'globalMemoryDump', - pluralName: 'globalMemoryDumps', - singleViewElementName: 'tr-ui-a-container-memory-dump-sub-view', - multiViewElementName: 'tr-ui-a-container-memory-dump-sub-view' - }); - - return { - GlobalMemoryDump: GlobalMemoryDump - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/global_memory_dump_test.html b/chromium/third_party/catapult/tracing/tracing/model/global_memory_dump_test.html deleted file mode 100644 index dbc472209d9..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/global_memory_dump_test.html +++ /dev/null @@ -1,3944 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/importer/import.html"> -<link rel="import" href="/tracing/model/global_memory_dump.html"> -<link rel="import" href="/tracing/model/memory_allocator_dump.html"> -<link rel="import" href="/tracing/model/memory_dump_test_utils.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/process_memory_dump.html"> -<link rel="import" href="/tracing/value/numeric.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Model = tr.Model; - var GlobalMemoryDump = tr.model.GlobalMemoryDump; - var ProcessMemoryDump = tr.model.ProcessMemoryDump; - var MemoryAllocatorDump = tr.model.MemoryAllocatorDump; - var MemoryAllocatorDumpLink = tr.model.MemoryAllocatorDumpLink; - var ScalarNumeric = tr.v.ScalarNumeric; - var sizeInBytes_smallerIsBetter = - tr.v.Unit.byName.sizeInBytes_smallerIsBetter; - var newAllocatorDump = tr.model.MemoryDumpTestUtils.newAllocatorDump; - var addChildDump = tr.model.MemoryDumpTestUtils.addChildDump; - var addOwnershipLink = tr.model.MemoryDumpTestUtils.addOwnershipLink; - var checkDumpNumericsAndDiagnostics = - tr.model.MemoryDumpTestUtils.checkDumpNumericsAndDiagnostics; - var SIZE_DELTA = tr.model.MemoryDumpTestUtils.SIZE_DELTA; - var MemoryAllocatorDumpInfoType = tr.model.MemoryAllocatorDumpInfoType; - var PROVIDED_SIZE_LESS_THAN_AGGREGATED_CHILDREN = - MemoryAllocatorDumpInfoType.PROVIDED_SIZE_LESS_THAN_AGGREGATED_CHILDREN; - var PROVIDED_SIZE_LESS_THAN_LARGEST_OWNER = - MemoryAllocatorDumpInfoType.PROVIDED_SIZE_LESS_THAN_LARGEST_OWNER; - - function buildArgPusher(array) { - return function(arg) { array.push(arg); }; - } - - function assertEqualUniqueMembers(actualArray, expectedArray) { - assert.lengthOf(actualArray, expectedArray.length); - assert.sameMembers(actualArray, expectedArray); - } - - function assertUndefinedNumeric(dump, numericName) { - var numeric = dump.numerics[numericName]; - assert.isUndefined(numeric, 'expected numeric \'' + numericName + - '\' of memory allocator dump \'' + dump.fullName + '\' in ' + - dump.containerMemoryDump.userFriendlyName + ' to be undefined'); - } - - function assertDefinedNumeric(dump, numericName, expectedUnit, expectedValue, - opt_delta) { - var numeric = dump.numerics[numericName]; - var errorMessagePrefix = 'expected numeric \'' + numericName + - '\' of memory allocator dump \'' + dump.fullName + '\' in ' + - dump.containerMemoryDump.userFriendlyName + ' to '; - - assert.instanceOf(numeric, ScalarNumeric, - errorMessagePrefix + 'be an instance of ScalarNumeric'); - assert.equal(numeric.unit, expectedUnit, - errorMessagePrefix + 'have unit \'' + expectedUnit.unitName + - '\' but got \'' + numeric.unit.unitName + '\' instead'); - - var valueErrorMessage = errorMessagePrefix + 'have value \'' + - expectedValue + '\' but got \'' + numeric.value + '\''; - if (opt_delta !== undefined) { - assert.closeTo( - numeric.value, expectedValue, opt_delta, valueErrorMessage); - } else { - assert.equal(numeric.value, expectedValue, valueErrorMessage); - } - } - - function assertSizeNumeric(dump, sizeName, expectedValue) { - if (expectedValue === undefined) { - assertUndefinedNumeric(dump, sizeName); - } else { - assertDefinedNumeric(dump, sizeName, sizeInBytes_smallerIsBetter, - expectedValue, SIZE_DELTA); - } - } - - function assertDumpSizes(dump, expectedSize, expectedEffectiveSize, - opt_expectedInfos, opt_expectedOwnedBySiblingSizes) { - // Check the 'size' numeric. - assertSizeNumeric(dump, 'size', expectedSize); - - // Check the 'effective_size' numeric. - assertSizeNumeric(dump, 'effective_size', expectedEffectiveSize); - - // Check the 'infos' list. - var expectedInfos = opt_expectedInfos || []; - var actualInfos = dump.infos; - assert.lengthOf(actualInfos, expectedInfos.length, - 'expected memory allocator dump \'' + dump.fullName + '\' in ' + - dump.containerMemoryDump.userFriendlyName + ' to have ' + - expectedInfos.length + ' infos but got ' + actualInfos.length); - for (var k = 0; k < actualInfos.length; k++) { - assert.deepEqual(actualInfos[k], expectedInfos[k], - 'info ' + k + ' of memory allocator dump \'' + dump.fullName + - '\' in ' + dump.containerMemoryDump.userFriendlyName + - ' doesn\'t match the expected info'); - } - - // Checked the 'ownedBySiblingSizes' map. - var expectedOwnedBySiblingSizes = opt_expectedOwnedBySiblingSizes || {}; - var actualOwnedBySiblingSizes = {}; - for (var siblingDump of dump.ownedBySiblingSizes.keys()) { - assert.strictEqual(siblingDump.parent, dump.parent); - actualOwnedBySiblingSizes[siblingDump.name] = - dump.ownedBySiblingSizes.get(siblingDump); - } - assert.deepEqual(actualOwnedBySiblingSizes, expectedOwnedBySiblingSizes, - 'ownedBySiblingSizes of memory allocator dump \'' + dump.fullName + - '\' in ' + dump.containerMemoryDump.userFriendlyName + - ' doesn\'t contain the expected values'); - } - - function createContainerDumps(processMemoryDumpCount, opt_model) { - var model = opt_model; - if (model === undefined) - model = new Model(); - - var gmd = new GlobalMemoryDump(model, 0); - model.globalMemoryDumps.push(gmd); - - var pmds = []; - for (var i = 0; i < processMemoryDumpCount; i++) { - var process = model.getOrCreateProcess(i); - var pmd = new ProcessMemoryDump(gmd, process, 0); - gmd.processMemoryDumps[i] = pmd; - process.memoryDumps.push(pmd); - pmds.push(pmd); - } - - return [gmd].concat(pmds); - } - - /** - * Build container memory dumps from tree recipes. This function returns - * a list containing a global memory dump and zero or more process memory - * dumps constructed from the provided function argument as follows: - * - * allTreeRecipes (argument): - * - * [ - * [tree recipe GA, tree recipe GB, ...], - * [tree recipe P1A, tree recipe P1B, ...], - * [tree recipe P2A, tree recipe P2B ...], - * ... - * ] - * - * return value: - * - * [ - * GlobalMemoryDump with root MemoryAllocatorDump(s) [GA, GB, ...], - * ProcessMemoryDump with root MemoryAllocatorDump(s) [P1A, P1B, ...], - * ProcessMemoryDump with root MemoryAllocatorDump(s) [P2A, P2B, ...], - * ... - * ] - * - * where a tree recipe is an object (a recursive data structure) with the - * following fields: - * - * name: Name of the resulting MAD. - * guid: GUID of the resulting MAD (can be undefined). - * owns: GUID of another MAD owned by the resulting MAD (no owned MAD if - * undefined). - * importance: Importance of the above ownership (can be undefined). - * size: Value of the 'size' numeric of the resulting MAD (no 'size' - * numeric if undefined). - * numerics: Extra numerics of the resulting MAD (dictionary). - * diagnostics: Extra diagnostics of the resulting MAD (dictionary). - * weak: Whether the resulting MAD should be weak (undefined implies - * non-weak). - * children: List of tree recipes for child MADs (no children if undefined). - * skip_build: If this optional property is set to true, this function will - * skip the corresponding tree recipe node and will not create a MAD - * for it (not allowed in root recipes). - * - * Other fields (most importantly 'expected_size') of a tree recipe are - * ignored by this function. - */ - function buildDumpTrees(allTreeRecipes, opt_model) { - assert.isAbove(allTreeRecipes.length, 0); - - var ownerDumps = {}; // owned GUID -> {dump: owner, importance: optional}. - var ownableDumps = {}; // ownable GUID -> ownable dump. - - function buildAndAddDumpTrees(containerDump, treeRecipes) { - if (treeRecipes === undefined) - return; - - function buildDumpTreeRecursively(treeRecipe, namePrefix) { - var skipBuild = treeRecipe['skip_build']; - var name = treeRecipe['name']; - var guid = treeRecipe['guid']; - var owns = treeRecipe['owns']; - var size = treeRecipe['size']; - var numerics = treeRecipe['numerics']; - var diagnostics = treeRecipe['diagnostics']; - var importance = treeRecipe['importance']; - var weak = treeRecipe['weak']; - - assert.notStrictEqual(skipBuild, true); - assert.isDefined(name); - - var fullName = namePrefix + name; - var dump = new MemoryAllocatorDump(containerDump, fullName, guid); - - if (size !== undefined) { - dump.addNumeric( - 'size', new ScalarNumeric(sizeInBytes_smallerIsBetter, size)); - } - if (guid !== undefined) { - assert.notProperty(guid, ownableDumps); - ownableDumps[guid] = dump; - } - if (owns !== undefined) { - if (!(owns in ownerDumps)) - ownerDumps[owns] = []; - ownerDumps[owns].push({dump: dump, importance: importance}); - } else { - assert.isUndefined(importance); // Test sanity check. - } - - if (treeRecipe.children !== undefined) { - treeRecipe.children.forEach(function(childTreeRecipe) { - // Virtual children are added during size calculation. - if (childTreeRecipe['skip_build'] === true) - return; - var childDump = - buildDumpTreeRecursively(childTreeRecipe, fullName + '/'); - childDump.parent = dump; - dump.children.push(childDump); - }); - } - - if (numerics !== undefined) - tr.b.iterItems(numerics, dump.addNumeric, dump); - if (diagnostics !== undefined) - tr.b.iterItems(diagnostics, dump.addDiagnostic, dump); - - if (weak) - dump.weak = true; - - return dump; - } - - var memoryAllocatorDumps = treeRecipes.map(function(treeRecipe) { - return buildDumpTreeRecursively(treeRecipe, ''); - }); - containerDump.memoryAllocatorDumps = memoryAllocatorDumps; - } - - // Recursively build memory allocator dump trees for all container dumps. - var containerDumps = createContainerDumps( - allTreeRecipes.length - 1, opt_model); - for (var i = 0; i < allTreeRecipes.length; i++) - buildAndAddDumpTrees(containerDumps[i], allTreeRecipes[i]); - - // Hook up ownership links. - tr.b.iterItems(ownerDumps, function(ownedGuid, ownershipInfos) { - var ownedDump = ownableDumps[ownedGuid]; - assert.isDefined(ownedDump, 'Tree recipes don\'t contain a memory ' + - 'allocator dump with guid \'' + ownedGuid + '\''); - - ownershipInfos.forEach(function(ownershipInfo) { - addOwnershipLink( - ownershipInfo.dump, ownedDump, ownershipInfo.importance); - }); - }); - - return containerDumps; - } - - // Check that the buildDumpTrees testing helper method above builds a - // hierarchy of container and memory allocator dumps from tree recipes - // correctly. - test('testSanityCheck_buildDumpTrees', function() { - var containerDumps = buildDumpTrees([ - [ // GMD. - { - 'name': 'globalSharedDump1', - 'size': 123 - }, - { - 'name': 'globalSharedDump2', - 'subsystem_size': 999, - 'owns': 7, - 'importance': -1 - } - ], - undefined, // PMD1. - [ // PMD2. - { - 'name': 'v8', - 'children': [ - { - 'name': 'isolate1', - 'guid': 7, - 'weak': true - }, - { - 'name': 'isolate2', - 'skip_build': true - }, - { - 'name': 'isolate3', - 'size': 54, - 'guid': 60, - 'children': [ - { - 'name': 'obj1', - 'size': 89, - 'guid': 3 - }, - { - 'name': 'obj2', - 'owns': 3, - 'weak': true - }, - { - 'name': 'obj3', - 'owns': 3, - 'importance': 2 - } - ] - } - ] - } - ] - ]); - assert.lengthOf(containerDumps, 3); - var gmd = containerDumps[0]; - var pmd1 = containerDumps[1]; - var pmd2 = containerDumps[2]; - - function checkDump(dump, expectedGuid, expectedFullName, expectedParent, - expectedChildrenCount, expectedSize, expectedIsOwner, - expectedOwnersCount, expectedContainerDump, opt_expectedWeak) { - assert.isDefined(dump); - assert.instanceOf(dump, MemoryAllocatorDump); - assert.strictEqual(dump.guid, expectedGuid); - assert.strictEqual(dump.fullName, expectedFullName); - assert.strictEqual(dump.parent, expectedParent); - assert.lengthOf(dump.children, expectedChildrenCount); - - assertSizeNumeric(dump, 'size', expectedSize); - assertSizeNumeric(dump, 'subsystem_size', undefined); - - if (expectedIsOwner) - assert.isDefined(dump.owns); - else - assert.isUndefined(dump.owns); - assert.lengthOf(dump.ownedBy, expectedOwnersCount); - - assert.strictEqual(dump.containerMemoryDump, expectedContainerDump); - assert.strictEqual(expectedContainerDump.getMemoryAllocatorDumpByFullName( - expectedFullName), dump); - assert.strictEqual(dump.weak, !!opt_expectedWeak); - } - - function checkOwnershipLink(expectedSourceDump, expectedTargetDump, - expectedImportance) { - var link = expectedSourceDump.owns; - assert.isDefined(link); - assert.instanceOf(link, MemoryAllocatorDumpLink); - assert.strictEqual(link.source, expectedSourceDump); - assert.strictEqual(link.target, expectedTargetDump); - assert.strictEqual(link.importance, expectedImportance); - assert.include(expectedTargetDump.ownedBy, link); - } - - // GMD memory allocator dumps. - assert.lengthOf(gmd.memoryAllocatorDumps, 2); - var globalSharedDump1 = gmd.memoryAllocatorDumps[0]; - checkDump(globalSharedDump1, undefined, 'globalSharedDump1', undefined, 0, - 123, false, 0, gmd); - var globalSharedDump2 = gmd.memoryAllocatorDumps[1]; - checkDump(globalSharedDump2, undefined, 'globalSharedDump2', undefined, 0, - undefined, true, 0, gmd); - - // PMD1 memory allocator dumps. - assert.isUndefined(pmd1.memoryAllocatorDumps); - - // PMD2 memory allocator dumps. - assert.lengthOf(pmd2.memoryAllocatorDumps, 1); - var v8Dump = pmd2.memoryAllocatorDumps[0]; - checkDump(v8Dump, undefined, 'v8', undefined, 2, undefined, false, 0, - pmd2); - var isolate1Dump = v8Dump.children[0]; - checkDump(isolate1Dump, 7, 'v8/isolate1', v8Dump, 0, undefined, false, 1, - pmd2, true /* weak dump */); - var isolate3Dump = v8Dump.children[1]; - checkDump(isolate3Dump, 60, 'v8/isolate3', v8Dump, 3, 54, false, 0, pmd2); - var obj1Dump = isolate3Dump.children[0]; - checkDump(obj1Dump, 3, 'v8/isolate3/obj1', isolate3Dump, 0, 89, false, 2, - pmd2); - var obj2Dump = isolate3Dump.children[1]; - checkDump(obj2Dump, undefined, 'v8/isolate3/obj2', isolate3Dump, 0, - undefined, true, 0, pmd2, true /* weak dump */); - var obj3Dump = isolate3Dump.children[2]; - checkDump(obj3Dump, undefined, 'v8/isolate3/obj3', isolate3Dump, 0, - undefined, true, 0, pmd2); - - // Ownership links. - checkOwnershipLink(globalSharedDump2, isolate1Dump, -1); - checkOwnershipLink(obj2Dump, obj1Dump, undefined); - checkOwnershipLink(obj3Dump, obj1Dump, 2); - }); - - /** - * Check that container memory dumps have the expected structure with sizes - * as described by tree recipes. The fields of a tree recipe are used by this - * function to check the properties of a MemoryAllocatorDump as follows (see - * the buildDumpTrees documentation for more details about the structure of - * tree recipes): - * - * name: Expected name of the MAD. - * expected_removed: If provided and true, it is expected that there is no - * dump for the recipe. - * expected_size: Expected value of the 'size' numeric of the MAD (no - * 'size' numeric expected if undefined). - * expected_effective_size: Expected value of the 'effective_size' - * numeric of the MAD (no 'effective_size' numeric expected if - * undefined). - * expected_infos: List of expected MAD infos (zero infos expected if - * undefined). - * weak: Whether the MAD is expected to be weak (non-weak if undefined). - * owns: Expected GUID of the dump owned by the MAD. - * importance: Expected importance of the owhership from this MAD. - * expected_owned_by_links_count: Expected number of 'ownedBy' links of the - * MAD. - * children: List of tree recipes for child MADs (no children expected if - * undefined). - * - * Other fields of a tree recipe (including 'skip_build') are ignored by this - * function. - */ - function checkDumpTrees(containerDumps, allTreeRecipes) { - assert.lengthOf(containerDumps, allTreeRecipes.length); - - for (var i = 0; i < containerDumps.length; i++) { - var containerDump = containerDumps[i]; - var treeRecipes = allTreeRecipes[i]; - - var memoryAllocatorDumps = containerDump.memoryAllocatorDumps; - if (treeRecipes === undefined) { - assert.isUndefined(memoryAllocatorDumps, - 'expected undefined memory allocator dumps in ' + - containerDump.userFriendlyName); - continue; - } - - var expectedTreeRecipes = treeRecipes.filter(function(treeRecipe) { - return !treeRecipe['expected_removed']; - }); - - assert.isDefined(memoryAllocatorDumps, - 'expected defined memory allocator dumps in ' + - containerDump.userFriendlyName); - assert.lengthOf(memoryAllocatorDumps, expectedTreeRecipes.length, - 'expected ' + expectedTreeRecipes.length + ' root memory allocator ' + - 'dumps but got ' + memoryAllocatorDumps.length + ' in ' + - containerDump.userFriendlyName); - - function checkDumpTree(dump, treeRecipe, expectedParent, namePrefix) { - // Test sanity check. - assert.isFalse(!!treeRecipe['expected_removed']); - - // Check full name, parent, and container dump. - var expectedFullName = namePrefix + treeRecipe['name']; - var quantifiedName = dump.quantifiedName; - assert.equal(dump.fullName, expectedFullName, - quantifiedName + ' has invalid full name'); - assert.strictEqual(dump.parent, expectedParent, - quantifiedName + ' has invalid parent'); - assert.strictEqual(dump.containerMemoryDump, containerDump, - quantifiedName + ' has invalid container memory dump'); - assert.strictEqual(containerDump.getMemoryAllocatorDumpByFullName( - expectedFullName), dump, quantifiedName + - 'is not indexed in its container memory dump'); - - // Check the guid of the dump. - assert.strictEqual(dump.guid, treeRecipe['guid'], - quantifiedName + ' has invalid guid'); - - // Check that the 'weak' flag is correct. - assert.strictEqual(dump.weak, !!treeRecipe['weak'], - quantifiedName + ' has invalid weak flag'); - - // Check that sizes were calculated correctly. - assertDumpSizes(dump, - treeRecipe['expected_size'], - treeRecipe['expected_effective_size'], - treeRecipe['expected_infos'], - treeRecipe['expected_owned_by_sibling_sizes']); - - // Check that the 'owns' link is correct. - if (treeRecipe['owns'] === undefined) { - assert.isUndefined(dump.owns, - quantifiedName + ' was expected not to own another dump'); - } else { - var ownershipLink = dump.owns; - assert.isDefined(dump.owns, quantifiedName + - ' was expected to have an \'owns\' link'); - assert.strictEqual(ownershipLink.source, dump, - 'the \'owns\' link of ' + quantifiedName + ' has invalid source'); - var expectedImportance = treeRecipe['importance']; - assert.strictEqual(ownershipLink.importance, expectedImportance, - 'expected the importance of the \'owns\' link of ' + - quantifiedName + ' to be ' + expectedImportance + - ' but got ' + ownershipLink.importance); - var ownedDump = ownershipLink.target; - assert.strictEqual(ownedDump.guid, treeRecipe['owns'], - 'the \'owns\' link of ' + quantifiedName + - ' has an invalid target'); - assert.include(ownedDump.ownedBy, ownershipLink, - 'the target of the \'owns\' link of ' + quantifiedName + - ' doesn\'t have the link in its \'ownedBy\' list'); - } - - // Check that the number of 'ownedBy' links is correct. - var expectedOwnedByLinksCount = - treeRecipe['expected_owned_by_links_count']; - if (expectedOwnedByLinksCount !== undefined) { - assert.lengthOf(dump.ownedBy, expectedOwnedByLinksCount, - 'expected ' + quantifiedName + ' to have ' + - expectedOwnedByLinksCount + ' \'ownedBy\' links but got ' + - dump.ownedBy.length); - } - - // Check children recursively. - var actualChildren = dump.children; - var expectedChildren = (treeRecipe.children || []).filter( - function(childRecipe) { - return !childRecipe['expected_removed']; - }); - assert.lengthOf(actualChildren, expectedChildren.length, - 'expected ' + quantifiedName + ' to have ' + - expectedChildren.length + ' children but got ' + - actualChildren.length); - for (var k = 0; k < actualChildren.length; k++) { - checkDumpTree(actualChildren[k], expectedChildren[k], dump, - expectedFullName + '/'); - } - } - - for (var j = 0; j < memoryAllocatorDumps.length; j++) { - checkDumpTree( - memoryAllocatorDumps[j], expectedTreeRecipes[j], undefined, ''); - } - } - } - - // Check that the checkDumpTrees testing helper method above actually - // performs the expected checks. Since it will be used heavily throughout - // this file (where it is expected to pass), we only need to verify that it - // does indeed fail in several cases where it should. - test('testSanityCheck_checkDumpTrees_invalidName', function() { - var containerDumps = createContainerDumps(0); - var gmd = containerDumps[0]; - var v8Dump = new MemoryAllocatorDump(gmd, 'v8'); - var heapsDump = - new MemoryAllocatorDump(gmd, 'heaps'); // Should be 'v8/heaps'. - v8Dump.children.push(heapsDump); - heapsDump.parent = v8Dump; - gmd.memoryAllocatorDumps = [v8Dump]; - - assert.throws(function() { - checkDumpTrees(containerDumps, [ - [ - { - 'name': 'v8', - 'children': [ - { - 'name': 'heaps' - } - ] - } - ] - ]); - }, /'heaps'.*invalid full name/); - }); - - test('testSanityCheck_checkDumpTrees_invalidGuid', function() { - var containerDumps = createContainerDumps(0); - var gmd = containerDumps[0]; - gmd.memoryAllocatorDumps = [new MemoryAllocatorDump(gmd, 'v8', 42)]; - - assert.throws(function() { - checkDumpTrees(containerDumps, [ - [ - { - 'name': 'v8', - 'guid': 43 // This should be 42. - } - ] - ]); - }, /'v8'.*\binvalid guid\b/); - }); - - test('testSanityCheck_checkDumpTrees_invalidStructure', function() { - var containerDumps = createContainerDumps(0); - var gmd = containerDumps[0]; - var rootDump = new MemoryAllocatorDump(gmd, 'root'); - addChildDump(rootDump, 'child1'); - gmd.memoryAllocatorDumps = [rootDump]; - - assert.throws(function() { - checkDumpTrees(containerDumps, [ - [ - { - 'name': 'root', - 'children': [ - { - 'name': 'child1' - }, - { - // This child is not present in the dump. - 'name': 'child2', - 'skip_build': true - } - ] - } - ] - ]); - }, /expected.*\b2\b.*children.*got.*\b1\b/); - }); - - test('testSanityCheck_checkDumpTrees_invalidParentLink', function() { - var containerDumps = createContainerDumps(0); - var gmd = containerDumps[0]; - var rootDump = new MemoryAllocatorDump(gmd, 'root'); - var parentDump = addChildDump(rootDump, 'parent'); - var childDump = addChildDump(parentDump, 'child'); - childDump.parent = rootDump; // This should correctly be parentDump. - gmd.memoryAllocatorDumps = [rootDump]; - - assert.throws(function() { - checkDumpTrees(containerDumps, [ - [ - { - 'name': 'root', - 'children': [ - { - 'name': 'parent', - 'children': [ - { - 'name': 'child' - } - ] - } - ] - } - ] - ]); - }, 'invalid parent'); - }); - - test('testSanityCheck_checkDumpTrees_invalidSize', function() { - var containerDumps = createContainerDumps(1); - var gmd = containerDumps[0]; - var pmd = containerDumps[1]; - var rootDump = newAllocatorDump(pmd, 'root', { size: 100 }); - addChildDump(rootDump, 'parent', { size: 49 }); - pmd.memoryAllocatorDumps = [rootDump]; - - assert.throws(function() { - checkDumpTrees(containerDumps, [ - undefined, - [ - { - 'name': 'root', - 'expected_size': 100, - 'children': [ - { - 'name': 'parent', - 'expected_size': 50 // This should be 49. - } - ] - } - ] - ]); - }, /expected.*'size'.*value.*\b50\b.*got.*\b49\b/); - }); - - test('testSanityCheck_checkDumpTrees_invalidEffectiveSize', function() { - var containerDumps = createContainerDumps(1); - var gmd = containerDumps[0]; - var pmd = containerDumps[1]; - var rootDump = newAllocatorDump(pmd, 'root', { effective_size: 99 }); - addChildDump(rootDump, 'parent', { effective_size: 50 }); - pmd.memoryAllocatorDumps = [rootDump]; - - assert.throws(function() { - checkDumpTrees(containerDumps, [ - undefined, - [ - { - 'name': 'root', - 'expected_effective_size': 100, // This should be 99. - 'children': [ - { - 'name': 'parent', - 'expected_effective_size': 50 - } - ] - } - ] - ]); - }, /expected.*'effective_size'.*value.*\b100\b.*got.*\b99\b/); - }); - - test('testSanityCheck_checkDumpTrees_invalidInfoCount', function() { - var containerDumps = createContainerDumps(0); - var gmd = containerDumps[0]; - gmd.memoryAllocatorDumps = [ - newAllocatorDump(gmd, 'v8', { - size: 50 - }) - ]; - - assert.throws(function() { - checkDumpTrees(containerDumps, [ - [ - { - 'name': 'v8', - 'expected_size': 50, - 'expected_infos': [ - { - type: PROVIDED_SIZE_LESS_THAN_AGGREGATED_CHILDREN, - providedSize: 50, - dependencySize: 60 - } - ] - } - ] - ]); - }, /expected.*'v8'.*\b1 infos\b.*\bgot\b.*\b0\b/); - }); - - test('testSanityCheck_checkDumpTrees_invalidInfo', function() { - var containerDumps = createContainerDumps(0); - var gmd = containerDumps[0]; - var v8Dump = newAllocatorDump(gmd, 'v8', { size: 50 }); - v8Dump.infos.push({ - type: PROVIDED_SIZE_LESS_THAN_AGGREGATED_CHILDREN, - providedSize: 40, - dependencySize: 50 - }); - gmd.memoryAllocatorDumps = [v8Dump]; - - assert.throws(function() { - checkDumpTrees(containerDumps, [ - [ - { - 'name': 'v8', - 'expected_size': 50, - 'expected_infos': [ - { - // Should be PROVIDED_SIZE_LESS_THAN_AGGREGATED_CHILDREN below. - type: PROVIDED_SIZE_LESS_THAN_LARGEST_OWNER, - providedSize: 40, - dependencySize: 50 - } - ] - } - ] - ]); - }, /\binfo 0\b.*'v8'.*\bexpected\b/); - }); - - test('testSanityCheck_checkDumpTrees_invalidOwnedBySiblingSizes', function() { - var containerDumps = createContainerDumps(0); - var gmd = containerDumps[0]; - var v8Dump = new MemoryAllocatorDump(gmd, 'v8'); - addChildDump(v8Dump, 'child1', {}, 42 /* guid */); - addChildDump(v8Dump, 'child2'); - gmd.memoryAllocatorDumps = [v8Dump]; - - assert.throws(function() { - checkDumpTrees(containerDumps, [ - [ - { - 'name': 'v8', - 'children': [ - { - 'name': 'child1', - 'guid': 42 - }, - { - 'name': 'child2', - 'expected_owned_by_sibling_sizes': { - 'child1': 40 // This should be 30. - } - } - ] - } - ] - ]); - }, /\bownedBySiblingSizes\b.*'v8\/child2'.*\bexpected\b/); - }); - - test('testSanityCheck_checkDumpTrees_invalidWeakFlag', - function() { - var containerDumps = createContainerDumps(0); - var gmd = containerDumps[0]; - var parentDump = new MemoryAllocatorDump(gmd, 'parent'); - var childDump = addChildDump(parentDump, 'child'); - childDump.weak = true; - gmd.memoryAllocatorDumps = [parentDump]; - - assert.throws(function() { - checkDumpTrees(containerDumps, [ - [ - { - 'name': 'parent', - 'children': [ - { - 'name': 'child', - // Missing "'weak': true". - } - ] - } - ] - ]); - }, /'parent\/child'.*\binvalid weak flag\b/); - - assert.throws(function() { - checkDumpTrees(containerDumps, [ - [ - { - 'name': 'parent', - 'weak': true, // This should be false (or not provided). - 'children': [ - { - 'name': 'child', - 'weak': true - } - ] - } - ] - ]); - }, /'parent'.*\binvalid weak flag\b/); - }); - - test('testSanityCheck_checkDumpTrees_dumpNotRemoved', function() { - var containerDumps = createContainerDumps(0); - var gmd = containerDumps[0]; - var parentDump = new MemoryAllocatorDump(gmd, 'parent'); - for (var i = 1; i <= 3; i++) - addChildDump(parentDump, 'child' + i); - var otherDump = new MemoryAllocatorDump(gmd, 'other'); - gmd.memoryAllocatorDumps = [parentDump, otherDump]; - - // Child MAD not removed. - assert.throws(function() { - checkDumpTrees(containerDumps, [ - [ - { - 'name': 'parent', - 'children': [ - { - 'name': 'child1', - }, - { - 'name': 'child2', - 'expected_removed': true - }, - { - 'name': 'child3', - } - ] - }, - { - 'name': 'other' - } - ] - ]); - }, /\bexpected\b.*'parent'.*\b2 children\b.*\bgot 3\b/); - - // Root MAD not removed. - assert.throws(function() { - checkDumpTrees(containerDumps, [ - [ - { - 'name': 'parent', - 'children': [ - { - 'name': 'child1', - }, - { - 'name': 'child2' - }, - { - 'name': 'child3', - } - ] - }, - { - 'name': 'other', - 'expected_removed': true - } - ] - ]); - }, /\bexpected\b.*\b1 root memory allocator dumps\b.*\bgot 2\b/); - }); - - test('testSanityCheck_checkDumpTrees_invalidOwnership', function() { - var containerDumps = createContainerDumps(1); - var gmd = containerDumps[0]; - var pmd1 = containerDumps[1]; - var ownedDump = new MemoryAllocatorDump(gmd, 'owned', 42); - var ownerDump1 = new MemoryAllocatorDump(pmd1, 'owner1'); - var link1 = addOwnershipLink(ownerDump1, ownedDump); - var ownerDump2 = new MemoryAllocatorDump(pmd1, 'owner2'); - var link2 = addOwnershipLink(ownerDump2, ownedDump, 3); - var nonOwnerDump = new MemoryAllocatorDump(pmd1, 'non-owner', 90); - gmd.memoryAllocatorDumps = [ownedDump]; - pmd1.memoryAllocatorDumps = [ownerDump1, ownerDump2, nonOwnerDump]; - - // Missing 'owns' link. - assert.throws(function() { - checkDumpTrees(containerDumps, [ - [ - { - 'name': 'owned', - 'guid': 42 - } - ], - [ - { - 'name': 'owner1', - 'owns': 42 - }, - { - 'name': 'owner2', - 'importance': 3, - 'owns': 42 - }, - { - 'name': 'non-owner', - 'guid': 90, - 'owns': 42 // This should not be here. - } - ] - ]); - }, /'non-owner'.*\bwas expected to have\b.*'owns' link\b/); - - // Extra 'owns' link. - assert.throws(function() { - checkDumpTrees(containerDumps, [ - [ - { - 'name': 'owned', - 'guid': 42 - } - ], - [ - { - 'name': 'owner1' - // Missing: "'owns': 42". - }, - { - 'name': 'owner2', - 'importance': 3, - 'owns': 42 - }, - { - 'name': 'non-owner', - 'guid': 90 - } - ] - ]); - }, /'owner1'.*\bwas expected not to own\b/); - - // Invalid ownership importance. - assert.throws(function() { - checkDumpTrees(containerDumps, [ - [ - { - 'name': 'owned', - 'guid': 42 - } - ], - [ - { - 'name': 'owner1', - 'owns': 42 - }, - { - 'name': 'owner2', - 'importance': 2, // This should be 3. - 'owns': 42 - }, - { - 'name': 'non-owner', - 'guid': 90 - } - ] - ]); - }, /\bexpected\b.*\bimportance\b.*'owner2'.*\b2 but got 3\b/); - - // Invalid ownership target. - assert.throws(function() { - checkDumpTrees(containerDumps, [ - [ - { - 'name': 'owned', - 'guid': 42 - } - ], - [ - { - 'name': 'owner1', - 'owns': 90 // This should be 42. - }, - { - 'name': 'owner2', - 'importance': 3, - 'owns': 42 - }, - { - 'name': 'non-owner', - 'guid': 90 - } - ] - ]); - }, /'owner1'.*\binvalid target\b/); - - // Invalid 'ownedBy' ownership links count. - assert.throws(function() { - checkDumpTrees(containerDumps, [ - [ - { - 'name': 'owned', - 'guid': 42, - 'expected_owned_by_links_count': 3 // This should be 2. - } - ], - [ - { - 'name': 'owner1', - 'owns': 42 - }, - { - 'name': 'owner2', - 'importance': 3, - 'owns': 42 - }, - { - 'name': 'non-owner', - 'guid': 90 - } - ] - ]); - }, /'owned'.*\bhave 3 'ownedBy' links\b.*\bgot 2\b/); - - // Invalid ownership source. - link1.source = ownerDump2; - assert.throws(function() { - checkDumpTrees(containerDumps, [ - [ - { - 'name': 'owned', - 'guid': 42 - } - ], - [ - { - 'name': 'owner1', - 'owns': 42 - }, - { - 'name': 'owner2', - 'importance': 3, - 'owns': 42 - }, - { - 'name': 'non-owner', - 'guid': 90 - } - ] - ]); - }, /'owns' link\b.*'owner1'.*\binvalid source\b/); - link1.source = ownerDump1; - - // Ownership link not in target's 'ownedBy' list. - ownedDump.ownedBy.pop(); - assert.throws(function() { - checkDumpTrees(containerDumps, [ - [ - { - 'name': 'owned', - 'guid': 42 - } - ], - [ - { - 'name': 'owner1', - 'owns': 42 - }, - { - 'name': 'owner2', - 'importance': 3, - 'owns': 42 - }, - { - 'name': 'non-owner', - 'guid': 90 - } - ] - ]); - }, /\btarget of\b.*'owner2'.*'ownedBy' list\b/); - ownedDump.ownedBy.push(link2); - }); - - /** - * Build container memory dumps from tree recipes, let the resulting - * GlobalMemoryDump calculate sizes and effective sizes, and then check that - * the augmented container memory dumps have the expected structure with - * correct sizes and effective sizes (as described by the same tree recipes). - * - * See the documentation for buildDumpTrees and checkDumpTrees for more - * details about the structure of tree recipes. - */ - function testSizesCalculation(allTreeRecipes) { - var m = new Model(); - var io = new tr.importer.ImportOptions(); - io.showImportWarnings = false; - m.importOptions = io; - - var containerDumps = buildDumpTrees(allTreeRecipes, m); - var gmd = containerDumps[0]; - gmd.calculateSizes(); - gmd.calculateEffectiveSizes(); - gmd.forceRebuildingMemoryAllocatorDumpByFullNameIndices(); - checkDumpTrees(containerDumps, allTreeRecipes); - } - - // Check that the testSizesCalculation testing helper method above - // actually performs the expected checks. Since it will be used heavily - // throughout this file (where it is expected to pass), we only need to - // verify that it does indeed fail when it should. - test('testSanityCheck_testSizesCalculation', function() { - assert.throws(function() { - testSizesCalculation([ - [], - undefined, - [ - { - 'name': 'winheap' - }, - { - 'name': 'malloc', - 'expected_size': 100, - 'children': [ - { - 'name': 'allocated_objects', - 'size': 100, - 'expected_size': 100 - }, - { - 'name': 'extra', - 'size': 20, - 'expected_size': 20 - } - ] - } - ] - ]); - }, /expected.*'size'.*value.*\b100\b.*got.*\b120\b/); - }); - - function calculationTest(caseName, treeRecipes) { - test('calculateSizes_' + caseName, function() { - testSizesCalculation(treeRecipes); - }); - } - - /** - * Build container memory dumps from tree recipes, let the resulting - * GlobalMemoryDump remove weak memory dumps, and then check that the updated - * container memory dumps have the expected structure (as described by the - * same tree recipes). - * - * See the documentation for buildDumpTrees and checkDumpTrees for more - * details about the structure of tree recipes. - */ - function testWeakDumpRemoval(allTreeRecipes) { - var m = new tr.Model(); - var io = new tr.importer.ImportOptions(); - io.showImportWarnings = false; - m.importOptions = io; - - var containerDumps = buildDumpTrees(allTreeRecipes, m); - var gmd = containerDumps[0]; - gmd.removeWeakDumps(); - gmd.forceRebuildingMemoryAllocatorDumpByFullNameIndices(); - checkDumpTrees(containerDumps, allTreeRecipes); - } - - // Similarly to testSanityCheck_testSizesCalculation, check that the - // testWeakDumpRemoval testing helper method above actually performs the - // expected checks. - test('testSanityCheck_testWeakDumpRemoval', function() { - assert.throws(function() { - testWeakDumpRemoval([ - [], - undefined, - [ - { - 'name': 'winheap' - }, - { - 'name': 'malloc', - 'children': [ - { - 'name': 'allocated_objects' - }, - { - 'name': 'directly_weak', - 'guid': 42, - 'weak': true, - 'expected_removed': true - }, - { - 'name': 'indirectly_weak', - 'owns': 42 - // Missing: "'expected_removed': true". - } - ] - } - ] - ]); - }, /expected.*'malloc'.*\b2 children\b.*\bgot 1\b/); - }); - - function weakDumpRemovalTest(caseName, treeRecipes) { - test('removeWeakDumps_' + caseName, function() { - testWeakDumpRemoval(treeRecipes); - }); - } - - ///////////////////////////////////////////////////////////////////////////// - // Actual tests begin here. - ///////////////////////////////////////////////////////////////////////////// - - test('iterateContainerDumps_withoutProcessMemoryDumps', function() { - var containerDumps = createContainerDumps(0); - var gmd = containerDumps[0]; - - var visitedContainerDumps = []; - gmd.iterateContainerDumps(buildArgPusher(visitedContainerDumps)); - assertEqualUniqueMembers(visitedContainerDumps, containerDumps); - }); - - test('iterateContainerDumps_withProcessMemoryDumps', function() { - var containerDumps = createContainerDumps(2); - var gmd = containerDumps[0]; - - var visitedContainerDumps = []; - gmd.iterateContainerDumps(buildArgPusher(visitedContainerDumps)); - assertEqualUniqueMembers(visitedContainerDumps, containerDumps); - }); - - test('iterateAllRootAllocatorDumps', function() { - var containerDumps = buildDumpTrees([ - [ // GMD. - { - 'name': 'globalSharedDump1' - }, - { - 'name': 'globalSharedDump2' - } - ], - [ // PMD. - { - 'name': 'v8', - 'children': [ - { - 'name': 'isolate' - } - ] - } - ] - ]); - var gmd = containerDumps[0]; - var pmd = containerDumps[1]; - - var visitedAllocatorDumps = []; - gmd.iterateAllRootAllocatorDumps(buildArgPusher(visitedAllocatorDumps)); - assertEqualUniqueMembers(visitedAllocatorDumps, [ - gmd.getMemoryAllocatorDumpByFullName('globalSharedDump1'), - gmd.getMemoryAllocatorDumpByFullName('globalSharedDump2'), - pmd.getMemoryAllocatorDumpByFullName('v8') - ]); - }); - - test('traverseAllocatorDumpsInDepthFirstOrder_oneTreeWithoutOwners', - function() { - var containerDumps = buildDumpTrees([ - [ // GMD. - { - 'name': 'root', - 'children': [ - { - 'name': 'parent', - 'children': [ - { - 'name': 'child1' - }, - { - 'name': 'child2' - } - ] - } - ] - } - ] - ]); - var gmd = containerDumps[0]; - - // Post-order. - var visitedAllocatorDumps = []; - gmd.traverseAllocatorDumpsInDepthFirstPostOrder( - buildArgPusher(visitedAllocatorDumps)); - assert.deepEqual(visitedAllocatorDumps, [ - gmd.getMemoryAllocatorDumpByFullName('root/parent/child1'), - gmd.getMemoryAllocatorDumpByFullName('root/parent/child2'), - gmd.getMemoryAllocatorDumpByFullName('root/parent'), - gmd.getMemoryAllocatorDumpByFullName('root') - ]); - - // Pre-order. - var visitedAllocatorDumps = []; - gmd.traverseAllocatorDumpsInDepthFirstPreOrder( - buildArgPusher(visitedAllocatorDumps)); - assert.deepEqual(visitedAllocatorDumps, [ - gmd.getMemoryAllocatorDumpByFullName('root'), - gmd.getMemoryAllocatorDumpByFullName('root/parent'), - gmd.getMemoryAllocatorDumpByFullName('root/parent/child1'), - gmd.getMemoryAllocatorDumpByFullName('root/parent/child2') - ]); - }); - - test('traverseAllocatorDumpsInDepthFirstOrder_oneTreeWithOwners', - function() { - var containerDumps = buildDumpTrees([ - [], // GMD. - [ // PMD. - { - 'name': 'root', - 'children': [ - { - 'name': 'parent', - 'children': [ - { - 'name': 'child1', - 'owns': 0 - }, - { - 'name': 'child2', - 'guid': 0 - }, - { - 'name': 'child3', - 'owns': 0 - } - ] - } - ] - } - ] - ]); - var gmd = containerDumps[0]; - var pmd = containerDumps[1]; - - // Post-order. - var visitedAllocatorDumps = []; - gmd.traverseAllocatorDumpsInDepthFirstPostOrder( - buildArgPusher(visitedAllocatorDumps)); - assert.deepEqual(visitedAllocatorDumps, [ - pmd.getMemoryAllocatorDumpByFullName('root/parent/child1'), - pmd.getMemoryAllocatorDumpByFullName('root/parent/child3'), - pmd.getMemoryAllocatorDumpByFullName('root/parent/child2'), - pmd.getMemoryAllocatorDumpByFullName('root/parent'), - pmd.getMemoryAllocatorDumpByFullName('root') - ]); - - // Pre-order. - var visitedAllocatorDumps = []; - gmd.traverseAllocatorDumpsInDepthFirstPreOrder( - buildArgPusher(visitedAllocatorDumps)); - assert.deepEqual(visitedAllocatorDumps, [ - pmd.getMemoryAllocatorDumpByFullName('root'), - pmd.getMemoryAllocatorDumpByFullName('root/parent'), - pmd.getMemoryAllocatorDumpByFullName('root/parent/child2'), - pmd.getMemoryAllocatorDumpByFullName('root/parent/child1'), - pmd.getMemoryAllocatorDumpByFullName('root/parent/child3') - ]); - }); - - test('traverseAllocatorDumpsInDepthFirstOrder_multipleTrees', function() { - var containerDumps = buildDumpTrees([ - [ // GMD. - { - 'name': 'shared', - 'children': [ - { - 'name': 'pool1', - 'guid': 1 - }, - { - 'name': 'pool2', - 'owns': 3 - } - ] - } - ], - [ // PMD. - { - 'name': 'oilpan', - 'children': [ - { - 'name': 'objects' - }, - { - 'name': 'heaps', - 'owns': 1, - 'children': [ - { - 'name': 'small', - 'guid': 2 - }, - { - 'name': 'large' - } - ] - } - ] - }, - { - 'name': 'v8', - 'children': [ - { - 'name': 'isolate1', - 'owns': 2 - }, - { - 'name': 'isolate2', - 'guid': 3 - } - ] - } - ] - ]); - var gmd = containerDumps[0]; - var pmd = containerDumps[1]; - - // Post-order. - var visitedAllocatorDumps = []; - gmd.traverseAllocatorDumpsInDepthFirstPostOrder( - buildArgPusher(visitedAllocatorDumps)); - assert.deepEqual(visitedAllocatorDumps, [ - pmd.getMemoryAllocatorDumpByFullName('v8/isolate1'), - pmd.getMemoryAllocatorDumpByFullName('oilpan/heaps/small'), - pmd.getMemoryAllocatorDumpByFullName('oilpan/heaps/large'), - pmd.getMemoryAllocatorDumpByFullName('oilpan/heaps'), - gmd.getMemoryAllocatorDumpByFullName('shared/pool1'), - gmd.getMemoryAllocatorDumpByFullName('shared/pool2'), - gmd.getMemoryAllocatorDumpByFullName('shared'), - pmd.getMemoryAllocatorDumpByFullName('oilpan/objects'), - pmd.getMemoryAllocatorDumpByFullName('oilpan'), - pmd.getMemoryAllocatorDumpByFullName('v8/isolate2'), - pmd.getMemoryAllocatorDumpByFullName('v8') - ]); - - // Pre-order. - var visitedAllocatorDumps = []; - gmd.traverseAllocatorDumpsInDepthFirstPreOrder( - buildArgPusher(visitedAllocatorDumps)); - assert.deepEqual(visitedAllocatorDumps, [ - gmd.getMemoryAllocatorDumpByFullName('shared'), - gmd.getMemoryAllocatorDumpByFullName('shared/pool1'), - pmd.getMemoryAllocatorDumpByFullName('oilpan'), - pmd.getMemoryAllocatorDumpByFullName('oilpan/objects'), - pmd.getMemoryAllocatorDumpByFullName('oilpan/heaps'), - pmd.getMemoryAllocatorDumpByFullName('oilpan/heaps/small'), - pmd.getMemoryAllocatorDumpByFullName('oilpan/heaps/large'), - pmd.getMemoryAllocatorDumpByFullName('v8'), - pmd.getMemoryAllocatorDumpByFullName('v8/isolate1'), - pmd.getMemoryAllocatorDumpByFullName('v8/isolate2'), - gmd.getMemoryAllocatorDumpByFullName('shared/pool2') - ]); - }); - - test('traverseAllocatorDumpsInDepthFirstPostOrder_cycle', function() { - var containerDumps = buildDumpTrees([ - [ // GMD. - { - 'name': 'shared', - 'owns': 2, - 'children': [ - { - 'name': 'pool', - 'guid': 1 - } - ] - } - ], - [ // PMD. - { - 'name': 'oilpan', - 'owns': 1, - 'children': [ - { - 'name': 'objects', - 'guid': 2 - } - ] - } - ] - ]); - var gmd = containerDumps[0]; - - // Post-order. - assert.throws(function() { - gmd.traverseAllocatorDumpsInDepthFirstPostOrder(function() {}); - }, /contains.*cycle/); - - // Pre-order. - var visitedAllocatorDumps = []; - gmd.traverseAllocatorDumpsInDepthFirstPreOrder( - buildArgPusher(visitedAllocatorDumps)); - assert.deepEqual(visitedAllocatorDumps, []); - }); - - // Just check that the method doesn't crash upon encountering empty and/or - // undefined memory allocator dumps. - calculationTest('noDumps', [ - undefined, // GMD. - [], // PMD1. - undefined // PMD2. - ]); - - calculationTest('flatDumps', [ - [ // GMD. - { - 'name': 'shared', - 'size': 1024, - 'expected_size': 1024, - 'expected_effective_size': 1024 - } - ], - [ // PMD. - { - 'name': 'gpu' - } - ] - ]); - - calculationTest('zeroSizes', [ - [ // GMD. - { - 'name': 'shared', - 'size': 0, - 'expected_size': 0, - 'expected_effective_size': 0 - } - ], - [ // PMD1. - { - 'name': 'gpu', - 'expected_size': 0, - 'expected_effective_size': 0, - 'children': [ - { - 'name': 'zero', - 'size': 0, - 'expected_size': 0, - 'expected_effective_size': 0 - } - ] - } - ], - [ // PMD2. - { - 'name': 'gpu', - 'expected_size': 0, - 'expected_effective_size': 0, - 'children': [ - { - 'name': 'zero', - 'size': 0, - 'expected_size': 0, - 'expected_effective_size': 0 - }, - { - 'name': 'undefined' - } - ] - } - ] - ]); - - calculationTest('children_allSizesUndefined', [ - [ - { - 'name': 'parent', - 'children': [ - { - 'name': 'child1' - }, - { - 'name': 'child2' - } - ] - } - ] - ]); - - calculationTest('children_parentSizeUndefined', [ - [ - { - 'name': 'parent', - 'expected_size': 384, - 'expected_effective_size': 384, - 'children': [ - { - 'name': 'child1', - 'size': 128, - 'expected_size': 128, - 'expected_effective_size': 128 - }, - { - 'name': 'child2', - 'size': 256, - 'expected_size': 256, - 'expected_effective_size': 256 - } - ] - } - ] - ]); - - calculationTest('children_parentSizeDefined_childrenAddUp', [ - [ - { - 'name': 'parent', - 'size': 0, - 'expected_size': 0, - 'expected_effective_size': 0, - 'children': [ - { - 'name': 'child1' - }, - { - 'name': 'child2' - } - ] - } - ] - ]); - - calculationTest('children_parentSizeDefined_childrenDontAddUp', [ - [ - { - 'name': 'parent', - 'size': 2048, - 'expected_size': 2048, - 'expected_effective_size': 2048, - 'children': [ - { - 'name': '<unspecified>', - 'skip_build': true, - 'expected_size': 2048, - 'expected_effective_size': 2048 - }, - { - 'name': 'child1' - }, - { - 'name': 'child2' - } - ] - } - ] - ]); - - calculationTest('children_oneChildSizeUndefined_childrenAddUp', [ - [ - { - 'name': 'parent', - 'size': 4096, - 'expected_size': 4096, - 'expected_effective_size': 4096, - 'children': [ - { - 'name': 'child1' - }, - { - 'name': 'child2', - 'size': 4096, - 'expected_size': 4096, - 'expected_effective_size': 4096 - } - ] - } - ] - ]); - - calculationTest('children_oneChildSizeUndefined_childrenDontAddUp', [ - [ - { - 'name': 'parent', - 'size': 6144, - 'expected_size': 6144, - 'expected_effective_size': 6144, - 'children': [ - { - 'name': '<unspecified>', - 'skip_build': true, - 'expected_size': 2048, - 'expected_effective_size': 2048 - }, - { - 'name': 'child1' - }, - { - 'name': 'child2', - 'size': 4096, - 'expected_size': 4096, - 'expected_effective_size': 4096 - } - ] - } - ] - ]); - - calculationTest('children_allSizesDefined_childrenAddUp', [ - [ - { - 'name': 'parent', - 'size': 100, - 'expected_size': 100, - 'expected_effective_size': 100, - 'children': [ - { - 'name': 'child1', - 'size': 70, - 'expected_size': 70, - 'expected_effective_size': 70 - }, - { - 'name': 'child2', - 'size': 30, - 'expected_size': 30, - 'expected_effective_size': 30 - } - ] - } - ] - ]); - - calculationTest('children_allSizesDefined_childrenDontUp', [ - [ - { - 'name': 'parent', - 'size': 150, - 'expected_size': 150, - 'expected_effective_size': 150, - 'children': [ - { - 'name': '<unspecified>', - 'skip_build': true, - 'expected_size': 50, - 'expected_effective_size': 50 - }, - { - 'name': 'child1', - 'size': 70, - 'expected_size': 70, - 'expected_effective_size': 70 - }, - { - 'name': 'child2', - 'size': 30, - 'expected_size': 30, - 'expected_effective_size': 30 - } - ] - } - ] - ]); - - calculationTest('children_oneChildSizeDefined', [ - [ - { - 'name': 'parent', - 'expected_size': 49, - 'expected_effective_size': 49, - 'children': [ - { - 'name': 'child1', - 'size': 49, - 'expected_size': 49, - 'expected_effective_size': 49 - }, - { - 'name': 'child2' - } - ] - } - ] - ]); - - calculationTest('children_multipleLevels', [ - [], // GMD. - [ // PMD. - { - 'name': 'v8', - 'expected_size': 36, - 'expected_effective_size': 36, - 'children': [ - { - 'name': 'isolate1', - 'size': 10, - 'expected_size': 10, - 'expected_effective_size': 10, - 'children': [ - { - 'skip_build': true, - 'name': '<unspecified>', - 'expected_size': 3, - 'expected_effective_size': 3 - }, - { - 'name': 'objects', - 'size': 3, - 'expected_size': 3, - 'expected_effective_size': 3 - }, - { - 'name': 'heaps', - 'size': 4, - 'expected_size': 4, - 'expected_effective_size': 4 - } - ] - }, - { - 'name': 'isolate2', - 'size': 12, - 'expected_size': 12, - 'expected_effective_size': 12, - 'children': [ - { - 'name': 'objects', - 'size': 5, - 'expected_size': 5, - 'expected_effective_size': 5 - }, - { - 'name': 'heaps', - 'size': 7, - 'expected_size': 7, - 'expected_effective_size': 7 - } - ] - }, - { - 'name': 'isolate3', - 'expected_size': 14, - 'expected_effective_size': 14, - 'children': [ - { - 'name': 'objects', - 'size': 14, - 'expected_size': 14, - 'expected_effective_size': 14 - }, - { - 'name': 'heaps' - } - ] - } - ] - } - ] - ]); - - calculationTest('owners_allSizesUndefined', [ - [ // GMD. - { - 'name': 'bitmap', - 'guid': 7 - } - ], - [ // PMD1. - { - 'name': 'tile', - 'owns': 7, - 'importance': 1 - } - ], - [ // PMD2. - { - 'name': 'chunk', - 'owns': 7 - } - ] - ]); - - calculationTest('owners_ownedSizeDefined', [ - [ // GMD. - { - 'name': 'bitmap', - 'size': 15, - 'expected_size': 15, - 'expected_effective_size': 15, - 'guid': 7 - } - ], - [ // PMD1. - { - 'name': 'tile', - 'owns': 7 - } - ], - [ // PMD2. - { - 'name': 'chunk', - 'owns': 7 - } - ] - ]); - - calculationTest('owners_ownedSizeUndefined', [ - [ // GMD. - { - 'name': 'bitmap', - 'expected_size': 9, - 'expected_effective_size': 0, - 'guid': 7 - } - ], - [ // PMD1. - { - 'name': 'tile', - 'size': 5, - 'expected_size': 5, - 'expected_effective_size': 2.5, - 'owns': 7 - } - ], - [ // PMD2. - { - 'name': 'chunk', - 'size': 9, - 'expected_size': 9, - 'expected_effective_size': 6.5, - 'owns': 7 - } - ] - ]); - - calculationTest('owners_oneOwnerSizeDefined', [ - [ // GMD. - { - 'name': 'bitmap', - 'expected_size': 16, - 'expected_effective_size': 0, - 'guid': 7 - } - ], - [ // PMD1. - { - 'name': 'tile', - 'size': 16, - 'expected_size': 16, - 'expected_effective_size': 16, - 'owns': 7 - } - ], - [ // PMD2. - { - 'name': 'chunk', - 'owns': 7 - } - ] - ]); - - calculationTest('owners_oneOwnerSizeUndefined', [ - [ // GMD. - { - 'name': 'bitmap', - 'size': 20, - 'expected_size': 20, - 'expected_effective_size': 2, - 'guid': 7 - } - ], - [ // PMD1. - { - 'name': 'tile', - 'owns': 7 - } - ], - [ // PMD2. - { - 'name': 'chunk', - 'size': 18, - 'expected_size': 18, - 'expected_effective_size': 18, - 'owns': 7 - } - ] - ]); - - calculationTest('owners_allSizesDefined', [ - [ // GMD. - { - 'name': 'bitmap', - 'size': 60, - 'expected_size': 60, - 'expected_effective_size': 31, - 'guid': 7 - } - ], - [ // PMD1. - { - 'name': 'tile', - 'size': 29, - 'expected_size': 29, - 'expected_effective_size': 19.5, - 'owns': 7 - } - ], - [ // PMD2. - { - 'name': 'chunk', - 'size': 19, - 'expected_size': 19, - 'expected_effective_size': 9.5, - 'owns': 7 - } - ] - ]); - - calculationTest('owners_hierarchy', [ - [ // GMD. - { - 'name': 'bitmap', - 'expected_size': 50, - 'expected_effective_size': 0, - 'guid': 7 - } - ], - [ // PMD1. - { - 'name': 'tile', - 'expected_size': 50, - 'expected_effective_size': 0, - 'owns': 7, - 'guid': 0 - }, - { - 'name': 'object1', - 'size': 30, - 'owns': 0, - 'expected_size': 30, - 'expected_effective_size': 9 - }, - { - 'name': 'object2', - 'owns': 0 - }, - { - 'name': 'object3', - 'size': 50, - 'owns': 0, - 'expected_size': 50, - 'expected_effective_size': 21 - } - ], - [ // PMD2. - { - 'name': 'chunk', - 'size': 40, - 'expected_size': 40, - 'expected_effective_size': 20, - 'owns': 7 - } - ] - ]); - - calculationTest('owners_withChildren', [ - [ // GMD. - { - 'name': 'bitmap', - 'guid': 7, - 'expected_size': 48, - 'expected_effective_size': 17, - 'children': [ - { - 'name': 'subbitmap1', - 'size': 32, - 'expected_size': 32, - 'expected_effective_size': 17 * (32 / 48) - }, - { - 'name': 'subbitmap2', - 'size': 16, - 'expected_size': 16, - 'expected_effective_size': 17 * (16 / 48) - } - ] - } - ], - [ // PMD. - { - 'name': 'tile', - 'expected_size': 31, - 'expected_effective_size': 0, - 'guid': 8, - 'owns': 7, - 'children': [ - { - 'name': '<unspecified>', - 'skip_build': true, - 'expected_size': 7, - 'expected_effective_size': 0 - }, - { - 'name': 'subtile', - 'size': 24, - 'expected_size': 24, - 'expected_effective_size': 0 - } - ] - }, - { - 'name': 'cc', - 'owns': 8, - 'size': 31, - 'expected_size': 31, - 'expected_effective_size': 31 - } - ] - ]); - - calculationTest('owners_withParents', [ - [ // GMD. - { - 'name': 'bitmap', - 'size': 96, - 'expected_size': 96, - 'expected_effective_size': 32, - 'children': [ - { - 'name': '<unspecified>', - 'skip_build': true, - 'expected_size': 32, - 'expected_effective_size': 32 - }, - { - 'name': 'subbitmap', - 'guid': 2, - 'expected_size': 64, - 'expected_effective_size': 0 - } - ] - } - ], - [ // PMD. - { - 'name': 'tile', - 'expected_size': 64, - 'expected_effective_size': 0, - 'children': [ - { - 'name': 'subtile', - 'guid': 1, - 'owns': 2, - 'expected_size': 64, - 'expected_effective_size': 0 - } - ] - }, - { - 'name': 'cc', - 'owns': 1, - 'size': 64, - 'expected_size': 64, - 'expected_effective_size': 64 - } - ] - ]); - - calculationTest('owners_multipleLevels', [ - [ // GMD. - { - 'name': 'bitmap', - 'size': 96, - 'expected_size': 96, - 'expected_effective_size': 32, - 'children': [ - { - 'name': '<unspecified>', - 'skip_build': true, - 'expected_size': 32, - 'expected_effective_size': 32 - }, - { - 'name': 'subbitmap', - 'guid': 2, - 'expected_size': 64, - 'expected_effective_size': 0 - } - ] - } - ], - [ // PMD. - { - 'name': 'tile', - 'expected_size': 64, - 'expected_effective_size': 0, - 'owns': 2, - 'children': [ - { - 'name': 'subtile', - 'guid': 1, - 'expected_size': 64, - 'expected_effective_size': 0 - } - ] - }, - { - 'name': 'cc', - 'owns': 1, - 'size': 64, - 'expected_size': 64, - 'expected_effective_size': 64 - } - ] - ]); - - calculationTest('views_allSizesUndefined', [ - [ - { - 'name': 'v8', - 'children': [ - { - 'name': 'v8/heaps', - 'guid': 1 - }, - { - 'name': 'v8/objects', - 'owns': 1 - } - ] - } - ] - ]); - - calculationTest('views_ownedSizeDefined', [ - [ - { - 'name': 'v8', - 'expected_size': 10, - 'expected_effective_size': 10, - 'children': [ - { - 'name': 'heaps', - 'guid': 1, - 'size': 10, - 'expected_size': 10, - 'expected_effective_size': 10 - }, - { - 'name': 'objects', - 'owns': 1 - } - ] - } - ] - ]); - - calculationTest('views_ownerSizeDefined', [ - [ - { - 'name': 'v8', - 'expected_size': 20, - 'expected_effective_size': 20, - 'children': [ - { - 'name': 'heaps', - 'guid': 1, - 'expected_size': 20, - 'expected_effective_size': 0, - 'expected_owned_by_sibling_sizes': { - 'objects': 20 - } - }, - { - 'name': 'objects', - 'owns': 1, - 'size': 20, - 'expected_size': 20, - 'expected_effective_size': 20 - } - ] - } - ] - ]); - - calculationTest('views_parentSizeUndefined', [ - [ - { - 'name': 'v8', - 'expected_size': 30, - 'expected_effective_size': 30, - 'children': [ - { - 'name': 'heaps', - 'guid': 1, - 'size': 30, - 'expected_size': 30, - 'expected_effective_size': 10, - 'expected_owned_by_sibling_sizes': { - 'objects': 20 - } - }, - { - 'name': 'objects', - 'owns': 1, - 'size': 20, - 'expected_size': 20, - 'expected_effective_size': 20 - } - ] - } - ] - ]); - - calculationTest('views_ownerSizeUndefined_childrenAddUp', [ - [ - { - 'name': 'v8', - 'size': 30, - 'expected_size': 30, - 'expected_effective_size': 30, - 'children': [ - { - 'name': 'heaps', - 'guid': 1, - 'size': 30, - 'expected_size': 30, - 'expected_effective_size': 30 - }, - { - 'name': 'objects', - 'owns': 1 - } - ] - } - ] - ]); - - calculationTest('views_ownerSizeUndefined_childrenDontAddUp', [ - [ - { - 'name': 'v8', - 'size': 40, - 'expected_size': 40, - 'expected_effective_size': 40, - 'children': [ - { - 'name': '<unspecified>', - 'skip_build': true, - 'expected_size': 10, - 'expected_effective_size': 10 - }, - { - 'name': 'heaps', - 'guid': 1, - 'size': 30, - 'expected_size': 30, - 'expected_effective_size': 30 - }, - { - 'name': 'objects', - 'owns': 1 - } - ] - } - ] - ]); - - calculationTest('views_ownedSizeUndefined_childrenAddUp', [ - [ - { - 'name': 'v8', - 'size': 30, - 'expected_size': 30, - 'expected_effective_size': 30, - 'children': [ - { - 'name': 'heaps', - 'guid': 1, - 'expected_size': 30, - 'expected_effective_size': 0, - 'expected_owned_by_sibling_sizes': { - 'objects': 30 - } - }, - { - 'name': 'objects', - 'owns': 1, - 'size': 30, - 'expected_size': 30, - 'expected_effective_size': 30 - } - ] - } - ] - ]); - - calculationTest('views_ownedSizeUndefined_childrenDontAddUp', [ - [ - { - 'name': 'v8', - 'size': 40, - 'expected_size': 40, - 'expected_effective_size': 40, - 'children': [ - { - 'name': '<unspecified>', - 'skip_build': true, - 'expected_size': 10, - 'expected_effective_size': 10 - }, - { - 'name': 'heaps', - 'guid': 1, - 'expected_size': 30, - 'expected_effective_size': 0, - 'expected_owned_by_sibling_sizes': { - 'objects': 30 - } - }, - { - 'name': 'objects', - 'owns': 1, - 'size': 30, - 'expected_size': 30, - 'expected_effective_size': 30 - } - ] - } - ] - ]); - - calculationTest('views_allSizesDefined_childrenAddUp', [ - [ - { - 'name': 'v8', - 'size': 30, - 'expected_size': 30, - 'expected_effective_size': 30, - 'children': [ - { - 'name': 'heaps', - 'guid': 1, - 'size': 30, - 'expected_size': 30, - 'expected_effective_size': 16, - 'expected_owned_by_sibling_sizes': { - 'objects': 14 - } - }, - { - 'name': 'objects', - 'owns': 1, - 'size': 14, - 'expected_size': 14, - 'expected_effective_size': 14 - } - ] - } - ] - ]); - - calculationTest('views_allSizesDefined_childrenDontAddUp', [ - [ - { - 'name': 'v8', - 'size': 35, - 'expected_size': 35, - 'expected_effective_size': 35, - 'children': [ - { - 'name': '<unspecified>', - 'skip_build': true, - 'expected_size': 5, - 'expected_effective_size': 5 - }, - { - 'name': 'heaps', - 'guid': 1, - 'size': 30, - 'expected_size': 30, - 'expected_effective_size': 16, - 'expected_owned_by_sibling_sizes': { - 'objects': 14 - } - }, - { - 'name': 'objects', - 'owns': 1, - 'size': 14, - 'expected_size': 14, - 'expected_effective_size': 14 - } - ] - } - ] - ]); - - calculationTest('views_deep', [ - [ - { - 'name': 'root', - 'expected_size': 17, - 'expected_effective_size': 17, - 'children': [ - { - 'name': 'parent1', - 'size': 10, - 'expected_size': 10, - 'expected_effective_size': 5, - 'expected_owned_by_sibling_sizes': { - 'parent2': 5 - }, - 'children': [ - { - 'name': '<unspecified>', - 'skip_build': true, - 'expected_size': 2, - 'expected_effective_size': 2 - }, - { - 'name': 'child', - 'guid': 1, - 'size': 8, - 'expected_size': 8, - 'expected_effective_size': 3 - } - ] - }, - { - 'name': 'parent2', - 'size': 8, - 'expected_size': 8, - 'expected_effective_size': 5, - 'expected_owned_by_sibling_sizes': { - 'parent3': 3 - }, - 'children': [ - { - 'name': '<unspecified>', - 'skip_build': true, - 'expected_size': 3, - 'expected_effective_size': 3 - }, - { - 'name': 'child', - 'guid': 2, - 'owns': 1, - 'size': 5, - 'expected_size': 5, - 'expected_effective_size': 2 - } - ] - }, - { - 'name': 'parent3', - 'size': 7, - 'expected_size': 7, - 'expected_effective_size': 7, - 'children': [ - { - 'name': '<unspecified>', - 'skip_build': true, - 'expected_size': 4, - 'expected_effective_size': 4 - }, - { - 'name': 'child', - 'owns': 2, - 'size': 3, - 'expected_size': 3, - 'expected_effective_size': 3 - } - ] - } - ] - } - ] - ]); - - calculationTest('views_nested', [ - [ - { - 'name': 'system', - 'expected_size': 7, - 'expected_effective_size': 7, - 'children': [ - { - 'name': 'subsystem-A', - 'owns': 15, - 'expected_size': 5, - 'expected_effective_size': 5, - 'children': [ - { - 'name': 'objects', - 'owns': 30, - 'size': 3, - 'expected_size': 3, - 'expected_effective_size': 3 - }, - { - 'name': 'heaps', - 'guid': 30, - 'size': 5, - 'expected_size': 5, - 'expected_effective_size': 2, - 'expected_owned_by_sibling_sizes': { - 'objects': 3 - } - } - ] - }, - { - 'name': 'subsystem-B', - 'guid': 15, - 'expected_size': 7, - 'expected_effective_size': 2, - 'expected_owned_by_sibling_sizes': { - 'subsystem-A': 5 - }, - 'children': [ - { - 'name': 'objects', - 'owns': 40, - 'size': 7, - 'expected_size': 7, - 'expected_effective_size': 2 - }, - { - 'name': 'heaps', - 'guid': 40, - 'expected_size': 7, - 'expected_effective_size': 0, - 'expected_owned_by_sibling_sizes': { - 'objects': 7 - } - } - ] - } - ] - } - ] - ]); - - calculationTest('importance_equal', [ - [ // GMD (both importances undefined and equal sizes). - { - 'name': 'owned', - 'guid': 1, - 'size': 10, - 'expected_size': 10, - 'expected_effective_size': 4 - }, - { - 'name': 'owner1', - 'owns': 1, - 'size': 6, - 'expected_size': 6, - 'expected_effective_size': 3 - }, - { - 'name': 'owner2', - 'owns': 1, - 'size': 6, - 'expected_size': 6, - 'expected_effective_size': 3 - } - ], - [ // PMD1 (only one importance defined and different sizes). - { - 'name': 'owned', - 'guid': 2, - 'size': 20, - 'expected_size': 20, - 'expected_effective_size': 5 - }, - { - 'name': 'owner1', - 'owns': 2, - 'importance': 0, - 'size': 15, - 'expected_size': 15, - 'expected_effective_size': 10 / 2 + 5 - }, - { - 'name': 'owner2', - 'owns': 2, - 'size': 10, - 'expected_size': 10, - 'expected_effective_size': 10 / 2 - } - ], - [ // PMD2 (all importances defined and different sizes). - { - 'name': 'owned', - 'guid': 3, - 'size': 15, - 'expected_size': 15, - 'expected_effective_size': 5 - }, - { - 'name': 'owner1', - 'owns': 3, - 'importance': 3, - 'size': 8, - 'expected_size': 8, - 'expected_effective_size': 8 / 3 - }, - { - 'name': 'owner2', - 'owns': 3, - 'importance': 3, - 'size': 9, - 'expected_size': 9, - 'expected_effective_size': 8 / 3 + 1 / 2 - }, - { - 'name': 'owner3', - 'owns': 3, - 'importance': 3, - 'size': 10, - 'expected_size': 10, - 'expected_effective_size': 8 / 3 + 1 / 2 + 1 - } - ] - ]); - - calculationTest('importance_notEqual', [ - [ // GMD (one importance undefined and equal sizes). - { - 'name': 'owned', - 'guid': 1, - 'size': 10, - 'expected_size': 10, - 'expected_effective_size': 4 - }, - { - 'name': 'owner1', - 'owns': 1, - 'size': 6, - 'expected_size': 6, - 'expected_effective_size': 0 - }, - { - 'name': 'owner2', - 'owns': 1, - 'importance': 1, - 'size': 6, - 'expected_size': 6, - 'expected_effective_size': 6 - } - ], - [ // PMD1 (one importance undefined and different sizes). - { - 'name': 'owned', - 'guid': 2, - 'size': 20, - 'expected_size': 20, - 'expected_effective_size': 4 - }, - { - 'name': 'owner1', - 'owns': 2, - 'importance': -1, - 'size': 16, - 'expected_size': 16, - 'expected_effective_size': 6 - }, - { - 'name': 'owner2', - 'owns': 2, - 'size': 10, - 'expected_size': 10, - 'expected_effective_size': 10 - } - ], - [ // PMD2 (all importances defined and different sizes). - { - 'name': 'owned', - 'guid': 3, - 'size': 15, - 'expected_size': 15, - 'expected_effective_size': 5 - }, - { - 'name': 'owner1', - 'owns': 3, - 'importance': 4, - 'size': 8, - 'expected_size': 8, - 'expected_effective_size': 8 - }, - { - 'name': 'owner2', - 'owns': 3, - 'importance': 3, - 'size': 6, - 'expected_size': 6, - 'expected_effective_size': 0 - }, - { - 'name': 'owner3', - 'owns': 3, - 'importance': 2, - 'size': 10, - 'expected_size': 10, - 'expected_effective_size': 2 - } - ] - ]); - - // Example taken from GlobalMemoryDump.calculateDumpOwnershipCoefficient_() - // documentation. - calculationTest('importance_manyOwners', [ - [ // GMD. - { - 'name': 'owned', - 'guid': 4, - 'size': 10, - 'expected_size': 10, - 'expected_effective_size': 2 - } - ], - [ // PMD1. - { - 'name': 'owner1', - 'owns': 4, - 'importance': 2, - 'size': 6, - 'expected_size': 6, - 'expected_effective_size': 6 / 2 - } - ], - [ // PMD2. - { - 'name': 'some_parent', - 'expected_size': 7, - 'expected_effective_size': 6 / 2 + 1, - 'children': [ - { - 'name': 'owner2', - 'owns': 4, - 'importance': 2, - 'size': 7, - 'expected_size': 7, - 'expected_effective_size': 6 / 2 + 1 - } - ] - } - ], - [ // PMD3. - { - 'name': 'owner3', - 'owns': 4, - 'importance': 1, - 'size': 5, - 'expected_size': 5, - 'expected_effective_size': 0 - }, - { - 'name': 'owner4', - 'owns': 4, - 'importance': 0, - 'size': 8, - 'expected_size': 8, - 'expected_effective_size': 1 - } - ] - ]); - - calculationTest('importance_chainOwnerships', [ - [ // GMD. - { - 'name': 'owned', - 'guid': 5, - 'size': 10, - 'expected_size': 10, - 'expected_effective_size': 2 - } - ], - [ // PMD1. - { - 'name': 'owner1', - 'owns': 5, - 'importance': 2, - 'guid': 6, - 'size': 6, - 'expected_size': 6, - 'expected_effective_size': 2 - }, - { - 'name': 'subowner1', - 'owns': 6, - 'size': 4, - 'expected_size': 4, - 'expected_effective_size': 4 - } - ], - [ // PMD2. - { - 'name': 'owner2', - 'owns': 5, - 'importance': 1, - 'guid': 8, - 'size': 8, - 'expected_size': 8, - 'expected_effective_size': 2 - 2 / 4 - }, - { - 'name': 'subowner2', - 'owns': 8, - 'size': 2, - 'expected_size': 2, - 'expected_effective_size': 2 / 4 - } - ] - ]); - - calculationTest('importance_nested', [ - [ - { - 'name': 'grey', - 'guid': 15, - 'size': 20, - 'expected_size': 20, - 'expected_effective_size': 6 - }, - { - 'name': 'blue', - 'guid': 18, - 'owns': 15, - 'importance': 1, - 'size': 14, - 'expected_size': 14, - 'expected_effective_size': 1 - }, - { - 'name': 'purple', - 'owns': 15, - 'importance': 2, - 'size': 7, - 'expected_size': 7, - 'expected_effective_size': 7 - }, - { - 'name': 'yellow', - 'owns': 21, - 'importance': 3, - 'size': 10, - 'expected_size': 10, - 'expected_effective_size': 3 - }, - { - 'name': 'red', - 'guid': 21, - 'owns': 18, - 'size': 12, - 'expected_size': 12, - 'expected_effective_size': 1 - }, - { - 'name': 'green', - 'owns': 21, - 'importance': 3, - 'size': 8, - 'expected_size': 8, - 'expected_effective_size': 2 - } - ] - ]); - - calculationTest('importance_singleRefinement', [ - [ - { - 'name': 'v8', - 'expected_size': 13, - 'expected_effective_size': 13, - 'children': [ - { - 'name': 'objects', - 'owns': 1, - 'size': 11, - 'expected_size': 11, - 'expected_effective_size': 11, - 'children': [ - { - 'name': '<unspecified>', - 'skip_build': true, - 'expected_size': 4, - 'expected_effective_size': 4 - }, - { - 'name': 'object1', - 'owns': 2, - 'size': 7, - 'expected_size': 7, - 'expected_effective_size': 7 - } - ] - }, - { - 'name': 'heaps', - 'guid': 1, - 'size': 13, - 'expected_size': 13, - 'expected_effective_size': 2, - 'expected_owned_by_sibling_sizes': { - 'objects': 11 - }, - 'children': [ - { - 'name': '<unspecified>', - 'skip_build': true, - 'expected_size': 3, - 'expected_effective_size': 1 - }, - { - 'name': 'heap1', - 'guid': 2, - 'size': 10, - 'expected_size': 10, - 'expected_effective_size': 1, - } - ] - } - ] - } - ] - ]); - - calculationTest('importance_sharedRefinement', [ - [ // GMD. - { - 'name': 'shared_bitmap', - 'guid': 0, - 'size': 23, - 'expected_size': 23, - 'expected_effective_size': 5, - 'children': [ - { - 'name': '<unspecified>', - 'skip_build': true, - 'expected_size': 13, - 'expected_effective_size': 13 * 5 / (13 + 3) - }, - { - 'name': 'bitmap0x7', - 'guid': 999, - 'size': 10, - 'expected_size': 10, - 'expected_effective_size': 3 * 5 / (13 + 3), - } - ] - } - ], - [ // PMD1. - { - 'name': 'tile_manager', - 'owns': 0, - 'importance': 2, - 'size': 12, - 'expected_size': 12, - 'expected_effective_size': 5 + 2, - 'children': [ - { - 'name': '<unspecified>', - 'skip_build': true, - 'expected_size': 5, - 'expected_effective_size': 5 - }, - { - 'name': 'tile42', - 'owns': 999, - 'importance': 1, - 'size': 7, - 'expected_size': 7, - 'expected_effective_size': 2, - } - ] - } - ], - [ // PMD2. - { - 'name': 'gpu', - 'owns': 0, - 'importance': 1, - 'size': 16, - 'expected_size': 16, - 'expected_effective_size': 6 + 5, - 'children': [ - { - 'name': '<unspecified>', - 'skip_build': true, - 'expected_size': 11, - 'expected_effective_size': 6 - }, - { - 'name': 'chunk-3.14', - 'owns': 999, - 'importance': 2, - 'size': 5, - 'expected_size': 5, - 'expected_effective_size': 5, - } - ] - } - ] - ]); - - // Example taken from https://goo.gl/fKg0dt. - calculationTest('documentationExample', [ - [ // GMD, Global (shared) memory. - { - 'name': 'unknown', - 'guid': 2, - 'expected_size': 16, - 'expected_effective_size': 0, - } - ], - [ // PMD1, Browser process. - { - 'name': 'sharedbitmap', - 'size': 17, - 'expected_size': 17, - 'expected_effective_size': 9, - 'children': [ - { - 'name': '<unspecified>', - 'skip_build': true, - 'expected_size': 1, - 'expected_effective_size': 1 - }, - { - 'name': '0x7', - 'size': 16, - 'expected_size': 16, - 'expected_effective_size': 8, - 'owns': 2, - 'importance': 1, - 'children': [ - { - 'name': '<unspecified>', - 'skip_build': true, - 'expected_size': 16, - 'expected_effective_size': 8 - }, - { - 'name': 'y' - } - ] - } - ] - } - ], - [ // PMD2, Renderer process. - { - 'name': 'v8', - 'expected_size': 13, - 'expected_effective_size': 13, - 'children': [ - { - 'name': 'heaps', - 'guid': 100, - 'expected_size': 12, - 'expected_effective_size': 3, - 'expected_owned_by_sibling_sizes': { - 'objects': 9 - }, - 'children': [ - { - 'name': '1', - 'size': 8, - 'expected_size': 8, - 'expected_effective_size': 2, - 'owns': 2, - 'importance': 2 - }, - { - 'name': '2', - 'expected_size': 4, - 'expected_effective_size': 1, - 'size': 4 - } - ] - }, - { - 'name': 'objects', - 'size': 10, - 'expected_size': 10, - 'expected_effective_size': 10, - 'children': [ - { - 'name': '<unspecified>', - 'skip_build': true, - 'expected_size': 1, - 'expected_effective_size': 1 - }, - { - 'name': 'strings', - 'size': 9, - 'expected_size': 9, - 'expected_effective_size': 9, - 'owns': 100 - } - ] - } - ] - } - ] - ]); - - // This should never happen. Nevertheless, this test checks that we can - // handle invalid sizes (parent dump being smaller than its aggregated - // children and owned dump being smaller than its largest owner) gracefully. - calculationTest('invalidSizes', [ - [ - { - 'name': 'root1', - 'size': 24, - 'expected_size': 24, - 'expected_effective_size': 4, - 'children': [ - { - 'name': '<unspecified>', - 'skip_build': true, - 'expected_size': 4, - 'expected_effective_size': 4 - }, - { - 'name': 'parent', - 'guid': 2, - 'size': 17, // Invalid: child has larger size. - 'expected_size': 20, - 'expected_infos': [ - { - type: PROVIDED_SIZE_LESS_THAN_AGGREGATED_CHILDREN, - providedSize: 17, - dependencySize: 20 - }, - { - type: PROVIDED_SIZE_LESS_THAN_LARGEST_OWNER, - providedSize: 17, - dependencySize: 18 - } - ], - 'expected_effective_size': 0, - 'children': [ - { - 'name': 'child', - 'guid': 1, - 'size': 10, // Invalid: owner has larger size. - 'expected_size': 20, - 'expected_infos': [ - { - type: PROVIDED_SIZE_LESS_THAN_LARGEST_OWNER, - providedSize: 10, - dependencySize: 20 - } - ], - 'expected_effective_size': 0, - } - ] - } - ] - }, - { - 'name': 'root2', - 'owns': 1, - 'size': 20, - 'expected_size': 20, - 'expected_effective_size': 20 - }, - { - 'name': 'root3', - 'owns': 2, - 'importance': -1, - 'size': 18, - 'expected_size': 18, - 'expected_effective_size': 18 - } - ] - ]); - - calculationTest('multipleInfos', [ - [ - { - 'name': 'root', - 'expected_size': 10, - 'expected_effective_size': 10, - 'children': [ - { - 'name': 'parent1', - 'size': 5, - 'expected_size': 10, - 'expected_infos': [ - { - type: PROVIDED_SIZE_LESS_THAN_AGGREGATED_CHILDREN, - providedSize: 5, - dependencySize: 10 - } - ], - 'expected_effective_size': 1, - 'expected_owned_by_sibling_sizes': { - 'parent2': 17, - 'parent3': 7 - }, - 'children': [ - { - 'name': 'child', - 'guid': 3, - 'size': 10, - 'expected_size': 10, - 'expected_effective_size': 1, - } - ] - }, - { - 'name': 'parent2', - // NOTE(petrcermak): The expected size here is a little strange - // because the children both own the same dump (namely - // root/parent1/child). It would, therefore, probably make more - // sense for the calculated size to be 9. Since this is an unlikely - // case and would complicate the (already complex) size - // calculation, we will now keep the algorithm as is. - 'expected_size': 17, - 'expected_effective_size': 14 / 3 + 2, - 'children': [ - { - 'name': 'child1', - 'owns': 3, - 'size': 9, - 'expected_size': 9, - 'expected_effective_size': 7 / 3 + 1 / 2 + 1, - }, - { - 'name': 'child2', - 'owns': 3, - 'size': 8, - 'expected_size': 8, - 'expected_effective_size': 7 / 3 + 1 / 2, - } - ] - }, - { - 'name': 'parent3', - 'size': 7, - 'expected_size': 7, - 'expected_effective_size': 7 / 3, - 'owns': 3 - } - ] - } - ] - ]); - - // Check that size calculation is NOT preceded by numeric aggregation, which - // would recursively sum up size numerics. - test('finalizeGraph_aggregation', function() { - var model = tr.c.TestUtils.newModel(function(model) { - buildDumpTrees([ - undefined, // GMD. - [ // PMD. - { - 'name': 'root', - 'children': [ - { - 'name': 'owner_child', - 'owns': 9, - 'size': 7 - }, - { - 'name': 'owned_child', - 'guid': 9, - 'size': 20 - } - ] - } - ] - ], model); - }); - var pmd = model.getProcess(0).memoryDumps[0]; - - var rootDump = pmd.getMemoryAllocatorDumpByFullName('root'); - assertDumpSizes(rootDump, 20, 20); - - var ownerChildDump = pmd.getMemoryAllocatorDumpByFullName( - 'root/owner_child'); - assertDumpSizes(ownerChildDump, 7, 7); - - var ownedChildDump = pmd.getMemoryAllocatorDumpByFullName( - 'root/owned_child'); - assertDumpSizes(ownedChildDump, 20, 13, [] /* expectedInfos */, - { owner_child: 7 } /* expectedOwnedBySiblingSizes */); - }); - - // Check that numeric and diagnostics propagation and aggregation are - // performed in the correct order. - test('finalizeGraph_propagation', function() { - var model = tr.c.TestUtils.newModel(function(model) { - buildDumpTrees([ - [ // GMD. - { - 'name': 'owned_root', - 'guid': 1, - 'size': 10, - 'diagnostics': { - 'url': 'https://hello.world.com:42' - }, - 'children': [ - { - 'name': 'owned_child1', - 'numerics': { - 'summed': new ScalarNumeric(sizeInBytes_smallerIsBetter, 12) - }, - 'diagnostics': { - 'url2': 'http://not.aggregated.to/owned/parent/dump' - } - }, - { - 'name': 'owned_child2', - 'numerics': { - 'summed': new ScalarNumeric(sizeInBytes_smallerIsBetter, 15) - } - } - ] - } - ], - [ // PMD. - { - 'name': 'direct_owner', - 'owns': 1, - 'guid': 2, - 'diagnostics': { - 'url': 'file://not_overriden.html' - } - }, - { - 'name': 'parent_owner', - 'children': [ - { - 'name': 'child_owner', - 'owns': 1 - }, - { - 'name': 'sibling', - 'size': 5, - 'numerics': { - 'summed': new ScalarNumeric(sizeInBytes_smallerIsBetter, 13) - } - } - ] - }, - { - 'name': 'precedent_owner', - 'owns': 1, - 'numerics': { - 'summed': new ScalarNumeric(sizeInBytes_smallerIsBetter, 0) - } - }, - { - 'name': 'indirect_owner', - 'owns': 2 - } - ] - ], model); - }); - var pmd = model.getProcess(0).memoryDumps[0]; - - checkDumpNumericsAndDiagnostics( - pmd.getMemoryAllocatorDumpByFullName('direct_owner'), - { - 'size': 10, - 'effective_size': 3.3333, - 'summed': 27 - }, - { - 'url': 'file://not_overriden.html' - }); - checkDumpNumericsAndDiagnostics( - pmd.getMemoryAllocatorDumpByFullName('parent_owner/child_owner'), - { - 'size': 10, - 'effective_size': 3.3333, - 'summed': 27 - }, - { - 'url': 'https://hello.world.com:42' - }); - checkDumpNumericsAndDiagnostics( - pmd.getMemoryAllocatorDumpByFullName('parent_owner'), - { - 'size': 15, - 'effective_size': 8.3333, - 'summed': 40 - }, {}); - checkDumpNumericsAndDiagnostics( - pmd.getMemoryAllocatorDumpByFullName('precedent_owner'), - { - 'size': 10, - 'effective_size': 3.3333, - 'summed': 0 - }, - { - 'url': 'https://hello.world.com:42' - }); - checkDumpNumericsAndDiagnostics( - pmd.getMemoryAllocatorDumpByFullName('indirect_owner'), {}, {}); - }); - - // Check that weak dumps are removed before size size calculation. - test('finalizeGraph_weakDumpRemoval', function() { - var model = tr.c.TestUtils.newModel(function(model) { - buildDumpTrees([ - undefined, // GMD. - [ // PMD. - { - 'name': 'root', - 'children': [ - { - 'name': 'directly_weak_child', - 'weak': true, - 'guid': 5, - 'owns': 10, - 'size': 100 - }, - { - 'name': 'strong_child', - 'guid': 10, - 'size': 120 - }, - { - 'name': 'indirectly_weak_child', - 'owns': 5, - 'size': 70 - }, - { - 'name': 'separate_weak_child', - 'weak': true, - 'size': 300 - } - ] - } - ] - ], model); - }); - var pmd = model.getProcess(0).memoryDumps[0]; - - var rootDump = pmd.getMemoryAllocatorDumpByFullName('root'); - assertDumpSizes(rootDump, 120, 120); - assert.lengthOf(rootDump.children, 1); - - var strongChildDump = pmd.getMemoryAllocatorDumpByFullName( - 'root/strong_child'); - assertDumpSizes(strongChildDump, 120, 120); - assert.lengthOf(strongChildDump.ownedBy, 0); - - assert.isUndefined(pmd.getMemoryAllocatorDumpByFullName( - 'root/directly_weak_child')); - assert.isUndefined(pmd.getMemoryAllocatorDumpByFullName( - 'root/indirectly_weak_child')); - assert.isUndefined(pmd.getMemoryAllocatorDumpByFullName( - 'root/separate_weak_child')); - }); - - test('indicesUpdatedCorrectly', function() { - var gmd, rootDump, childDump; - var model = tr.c.TestUtils.newModel(function(model) { - gmd = new GlobalMemoryDump(model, 10); - model.globalMemoryDumps.push(gmd); - - rootDump = newAllocatorDump(gmd, 'root', { size: 64 }); - childDump = addChildDump(rootDump, 'child', { size: 48 }); - - gmd.memoryAllocatorDumps = [rootDump]; - - // Before model is finalized. - assert.strictEqual( - gmd.getMemoryAllocatorDumpByFullName('root'), rootDump); - assert.strictEqual( - gmd.getMemoryAllocatorDumpByFullName('root/child'), childDump); - assert.isUndefined( - gmd.getMemoryAllocatorDumpByFullName('root/<unspecified>')); - }); - - // Test sanity check. - assert.isDefined(gmd); - assert.isDefined(rootDump); - assert.isDefined(childDump); - - // After model is finalized. - assert.strictEqual(gmd.getMemoryAllocatorDumpByFullName('root'), rootDump); - assert.strictEqual( - gmd.getMemoryAllocatorDumpByFullName('root/child'), childDump); - var unspecifiedDump = - gmd.getMemoryAllocatorDumpByFullName('root/<unspecified>'); - assert.strictEqual(unspecifiedDump.fullName, 'root/<unspecified>'); - assert.strictEqual(unspecifiedDump.parent, rootDump); - assert.strictEqual(rootDump.children[0], unspecifiedDump); - }); - - weakDumpRemovalTest('allDumpsNonWeak', [ - [ // GMD. - { - 'name': 'malloc', - 'children': [ - { - 'name': 'allocated_objects', - 'children': [ - { - 'name': 'obj42', - 'guid': 5, - 'expected_owned_by_links_count': 2 - } - ] - } - ] - } - ], - undefined, // PMD1. - [ // PMD2. - { - 'name': 'oilpan' - }, - { - 'name': 'v8', - 'children': [ - { - 'name': 'heaps', - 'children': [ - { - 'name': 'S', - 'owns': 5 - }, - { - 'name': 'L', - 'owns': 5 - } - ] - } - ] - } - ] - ]); - - weakDumpRemovalTest('weakRootDump', [ - [], // GMD. - [ // PMD1. - { - 'name': 'strong1' - }, - { - 'name': 'weak', - 'weak': true, - 'expected_removed': true - }, - { - 'name': 'strong2' - } - ] - ]); - - weakDumpRemovalTest('weakChildDump', [ - [ // GMD. - { - 'name': 'root', - 'children': [ - { - 'name': 'parent', - 'children': [ - { - 'name': 'strong1' - }, - { - 'name': 'weak', - 'weak': true, - 'expected_removed': true, - 'children': [ - { - 'name': 'implicitly-removed' - } - ] - }, - { - 'name': 'strong2' - } - ] - } - ] - } - ] - ]); - - weakDumpRemovalTest('transitiveOwnerRemoval', [ - [ // GMD. - { - 'name': 'not-removed-strong-dump', - 'guid': 0, - 'expected_owned_by_links_count': 1 - }, - { - 'name': 'weak-owned-dump', - 'guid': 1, - 'owns': 0, - 'weak': true, - 'expected_removed': true - } - ], - [ // PMD1. - { - 'name': 'direct-owner-dump', - 'guid': 2, - 'owns': 1, - 'expected_removed': true - }, - { - 'name': 'also-not-removed-strong-dump', - 'owns': 0 - } - ], - [ // PMD2. - { - 'name': 'indirect-owner-dump', - 'owns': 2, - 'expected_removed': true - } - ] - ]); - - weakDumpRemovalTest('transitiveDescendantRemoval', [ - [ // GMD. - { - 'name': 'A', - 'owns': 10, - // A =owns=> B -child-of-> C -> D => E -> F -> G (weak). - 'expected_removed': true - }, - { - 'name': 'D', - 'owns': 5, - 'expected_removed': true, // D =owns=> E -child-of-> F -> G (weak). - 'children': [ - { - 'name': 'C', - 'children': [ - { - 'name': 'B', - 'guid': 10 - } - ] - } - ] - } - ], - undefined, // PMD1. - [ // PMD2. - { - 'name': 'first-retained-dump', - 'children': [ - { - 'name': 'G', - 'weak': true, - 'expected_removed': true, - 'children': [ - { - 'name': 'F', - 'children': [ - { - 'name': 'E', - 'guid': 5 - } - ] - }, - { - 'name': 'H', - 'children': [ - { - 'name': 'I', - 'children': [ - { - 'name': 'J', - 'owns': 2 - } - ] - } - ] - } - ] - } - ] - } - ], - [ // PMD3. - { - 'name': 'second-retained-dump', - 'guid': 2, - // The only owner (J) is removed because J -child-of-> I -> H -> - // G (weak). - 'expected_owned_by_links_count': 0 - } - ] - ]); - - weakDumpRemovalTest('subownerships', [ - [ // GMD. - { - 'name': 'root1', - 'owns': 20, - 'expected_removed': true, // root1 =owns=> root2 (weak). - 'children': [ - { - 'name': 'child1', - 'owns': 2 - } - ] - }, - { - 'name': 'root2', - 'guid': 20, - 'owns': 30, - 'weak': true, - 'expected_removed': true, - 'children': [ - { - 'name': 'child2', - 'guid': 2, - 'owns': 3 - } - ] - }, - { - 'name': 'root3', - 'guid': 30, - 'owns': 40, - 'expected_owned_by_links_count': 0, - 'children': [ - { - 'name': 'child3', - 'guid': 3, - 'owns': 4, - 'weak': true, - 'expected_removed': true - } - ] - } - ], - [ // PMD1. - { - 'name': 'root4', - 'guid': 40, - 'expected_owned_by_links_count': 1, - 'children': [ - { - 'name': 'child4', - 'guid': 4, - 'expected_owned_by_links_count': 0 - } - ] - } - ], - [ // PMD2. - { - 'name': 'root5', - 'owns': 60, - 'expected_removed': true, // root5 =owns=> root6 => root7 (weak). - 'children': [ - { - 'name': 'child5', - 'owns': 6 - } - ] - }, - { - 'name': 'root6', - 'guid': 60, - 'owns': 70, - 'expected_removed': true, // root6 =owns=> root7 (weak). - 'children': [ - { - 'name': 'child6', - 'guid': 6, - 'owns': 7 - } - ] - }, - { - 'name': 'root7', - 'guid': 70, - 'owns': 40, - 'weak': true, - 'expected_removed': true, - 'children': [ - { - 'name': 'child7', - 'guid': 7, - 'owns': 4 - } - ] - } - ] - ]); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/heap_dump.html b/chromium/third_party/catapult/tracing/tracing/model/heap_dump.html deleted file mode 100644 index d3f4a29dbef..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/heap_dump.html +++ /dev/null @@ -1,67 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - - /** - * HeapEntry represents a single value describing the state of the heap of an - * allocator in a single process. - * - * An entry specifies how much space (e.g. 19 MiB) was allocated in a - * particular context, which consists of a codepath (e.g. drawQuad <- draw <- - * MessageLoop::RunTask) and an object type (e.g. HTMLImportLoader). - * - * @{constructor} - */ - function HeapEntry(heapDump, leafStackFrame, objectTypeName, size, count) { - this.heapDump = heapDump; - - // The leaf stack frame of the associated backtrace (e.g. drawQuad for the - // drawQuad <- draw <- MessageLoop::RunTask backtrace). If undefined, the - // backtrace is empty. - this.leafStackFrame = leafStackFrame; - - // The name of the allocated object type (e.g. 'HTMLImportLoader'). If - // undefined, the entry represents the sum over all object types. - this.objectTypeName = objectTypeName; - - this.size = size; - this.count = count; - } - - /** - * HeapDump represents a dump of the heap of an allocator in a single process - * at a particular timestamp. - * - * @{constructor} - */ - function HeapDump(processMemoryDump, allocatorName) { - this.processMemoryDump = processMemoryDump; - this.allocatorName = allocatorName; - this.entries = []; - } - - HeapDump.prototype = { - addEntry: function(leafStackFrame, objectTypeName, size, count) { - var entry = new HeapEntry( - this, leafStackFrame, objectTypeName, size, count); - this.entries.push(entry); - return entry; - } - }; - - return { - HeapEntry: HeapEntry, - HeapDump: HeapDump - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/heap_dump_test.html b/chromium/third_party/catapult/tracing/tracing/model/heap_dump_test.html deleted file mode 100644 index cb3170ad85e..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/heap_dump_test.html +++ /dev/null @@ -1,60 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/global_memory_dump.html"> -<link rel="import" href="/tracing/model/heap_dump.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/process_memory_dump.html"> -<link rel="import" href="/tracing/model/stack_frame.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Model = tr.Model; - var GlobalMemoryDump = tr.model.GlobalMemoryDump; - var ProcessMemoryDump = tr.model.ProcessMemoryDump; - var StackFrame = tr.model.StackFrame; - var HeapEntry = tr.model.HeapEntry; - var HeapDump = tr.model.HeapDump; - - test('heapDumps', function() { - var model = new tr.Model(); - var process = model.getOrCreateProcess(89); - var gmd = new GlobalMemoryDump(model, 42); - model.globalMemoryDumps.push(gmd); - var pmd = new ProcessMemoryDump(gmd, process, 42); - process.memoryDumps.push(pmd); - - var rootFrame = new StackFrame( - undefined, tr.b.GUID.allocateSimple(), undefined); - var childFrame = new StackFrame( - rootFrame, tr.b.GUID.allocateSimple(), 'draw'); - rootFrame.addChild(childFrame); - - var dump = new HeapDump(pmd); - assert.strictEqual(dump.processMemoryDump, pmd); - assert.lengthOf(dump.entries, 0); - - var entry1 = dump.addEntry(childFrame, 'HTMLImportLoader', 1024, undefined); - assert.strictEqual(entry1.heapDump, dump); - assert.strictEqual(entry1.leafStackFrame, childFrame); - assert.strictEqual(entry1.objectTypeName, 'HTMLImportLoader'); - assert.strictEqual(entry1.size, 1024); - assert.isUndefined(entry1.count); - - var entry2 = dump.addEntry(undefined, undefined, 1048576, 42); - assert.strictEqual(entry2.heapDump, dump); - assert.isUndefined(entry2.leafStackFrame); - assert.isUndefined(entry2.objectTypeName); - assert.strictEqual(entry2.size, 1048576); - assert.strictEqual(entry2.count, 42); - - assert.deepEqual(dump.entries, [entry1, entry2]); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/helpers/android_app.html b/chromium/third_party/catapult/tracing/tracing/model/helpers/android_app.html deleted file mode 100644 index 8504a34c98e..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/helpers/android_app.html +++ /dev/null @@ -1,310 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/range_utils.html"> -<link rel="import" href="/tracing/base/sorted_array_utils.html"> -<link rel="import" href="/tracing/base/statistics.html"> -<link rel="import" href="/tracing/model/frame.html"> - -<script> -'use strict'; - -/** - * @fileoverview Class for managing android-specific model meta data, - * such as rendering apps, and frames rendered. - */ -tr.exportTo('tr.model.helpers', function() { - var Frame = tr.model.Frame; - var Statistics = tr.b.Statistics; - - var UI_DRAW_TYPE = { - NONE: 'none', - LEGACY: 'legacy', - MARSHMALLOW: 'marshmallow' - }; - - var UI_THREAD_DRAW_NAMES = { - 'performTraversals': UI_DRAW_TYPE.LEGACY, - 'Choreographer#doFrame': UI_DRAW_TYPE.MARSHMALLOW - }; - - var RENDER_THREAD_DRAW_NAME = 'DrawFrame'; - var RENDER_THREAD_INDEP_DRAW_NAME = 'doFrame'; - var THREAD_SYNC_NAME = 'syncFrameState'; - - function getSlicesForThreadTimeRanges(threadTimeRanges) { - var ret = []; - threadTimeRanges.forEach(function(threadTimeRange) { - var slices = []; - - threadTimeRange.thread.sliceGroup.iterSlicesInTimeRange( - function(slice) { slices.push(slice); }, - threadTimeRange.start, threadTimeRange.end); - ret.push.apply(ret, slices); - }); - return ret; - } - - function makeFrame(threadTimeRanges, surfaceFlinger) { - var args = {}; - if (surfaceFlinger && surfaceFlinger.hasVsyncs) { - var start = Statistics.min(threadTimeRanges, - function(threadTimeRanges) { return threadTimeRanges.start; }); - args['deadline'] = surfaceFlinger.getFrameDeadline(start); - args['frameKickoff'] = surfaceFlinger.getFrameKickoff(start); - } - var events = getSlicesForThreadTimeRanges(threadTimeRanges); - return new Frame(events, threadTimeRanges, args); - } - - function findOverlappingDrawFrame(renderThread, time) { - if (!renderThread) - return undefined; - - var slices = renderThread.sliceGroup.slices; - for (var i = 0; i < slices.length; i++) { - var slice = slices[i]; - if (slice.title == RENDER_THREAD_DRAW_NAME && - slice.start <= time && - time <= slice.end) { - return slice; - } - } - return undefined; - } - - /** - * Builds an array of {start, end} ranges grouping common work of a frame - * that occurs just before performTraversals(). - * - * Only necessary before Choreographer#doFrame tracing existed. - */ - function getPreTraversalWorkRanges(uiThread) { - if (!uiThread) - return []; - - // gather all frame work that occurs outside of performTraversals - var preFrameEvents = []; - uiThread.sliceGroup.slices.forEach(function(slice) { - if (slice.title == 'obtainView' || - slice.title == 'setupListItem' || - slice.title == 'deliverInputEvent' || - slice.title == 'RV Scroll') - preFrameEvents.push(slice); - }); - uiThread.asyncSliceGroup.slices.forEach(function(slice) { - if (slice.title == 'deliverInputEvent') - preFrameEvents.push(slice); - }); - - return tr.b.mergeRanges( - tr.b.convertEventsToRanges(preFrameEvents), - 3, - function(events) { - return { - start: events[0].min, - end: events[events.length - 1].max - }; - }); - } - - function getFrameStartTime(traversalStart, preTraversalWorkRanges) { - var preTraversalWorkRange = tr.b.findClosestIntervalInSortedIntervals( - preTraversalWorkRanges, - function(range) { return range.start }, - function(range) { return range.end }, - traversalStart, - 3); - - if (preTraversalWorkRange) - return preTraversalWorkRange.start; - return traversalStart; - } - - function getUiThreadDrivenFrames(app) { - if (!app.uiThread) - return []; - - var preTraversalWorkRanges = []; - if (app.uiDrawType == UI_DRAW_TYPE.LEGACY) - preTraversalWorkRanges = getPreTraversalWorkRanges(app.uiThread); - - var frames = []; - app.uiThread.sliceGroup.slices.forEach(function(slice) { - if (!(slice.title in UI_THREAD_DRAW_NAMES)) { - return; - } - - var threadTimeRanges = []; - var uiThreadTimeRange = { - thread: app.uiThread, - start: getFrameStartTime(slice.start, preTraversalWorkRanges), - end: slice.end - }; - threadTimeRanges.push(uiThreadTimeRange); - - // on SDK 21+ devices with RenderThread, - // account for time taken on RenderThread - var rtDrawSlice = findOverlappingDrawFrame( - app.renderThread, slice.end); - if (rtDrawSlice) { - var rtSyncSlice = rtDrawSlice.findDescendentSlice(THREAD_SYNC_NAME); - if (rtSyncSlice) { - // Generally, the UI thread is only on the critical path - // until the start of sync. - uiThreadTimeRange.end = Math.min(uiThreadTimeRange.end, - rtSyncSlice.start); - } - - threadTimeRanges.push({ - thread: app.renderThread, - start: rtDrawSlice.start, - end: rtDrawSlice.end - }); - } - frames.push(makeFrame(threadTimeRanges, app.surfaceFlinger)); - }); - return frames; - } - - function getRenderThreadDrivenFrames(app) { - if (!app.renderThread) - return []; - - var frames = []; - app.renderThread.sliceGroup.getSlicesOfName(RENDER_THREAD_INDEP_DRAW_NAME) - .forEach(function(slice) { - var threadTimeRanges = [{ - thread: app.renderThread, - start: slice.start, - end: slice.end - }]; - frames.push(makeFrame(threadTimeRanges, app.surfaceFlinger)); - }); - return frames; - } - - function getUiDrawType(uiThread) { - if (!uiThread) - return UI_DRAW_TYPE.NONE; - - var slices = uiThread.sliceGroup.slices; - for (var i = 0; i < slices.length; i++) { - if (slices[i].title in UI_THREAD_DRAW_NAMES) { - return UI_THREAD_DRAW_NAMES[slices[i].title]; - } - } - return UI_DRAW_TYPE.NONE; - } - - function getInputSamples(process) { - var samples = undefined; - for (var counterName in process.counters) { - if (/^android\.aq\:pending/.test(counterName) && - process.counters[counterName].numSeries == 1) { - samples = process.counters[counterName].series[0].samples; - break; - } - } - - if (!samples) - return []; - - // output rising edges only, since those are user inputs - var inputSamples = []; - var lastValue = 0; - samples.forEach(function(sample) { - if (sample.value > lastValue) { - inputSamples.push(sample); - } - lastValue = sample.value; - }); - return inputSamples; - } - - function getAnimationAsyncSlices(uiThread) { - if (!uiThread) - return []; - - var slices = []; - for (var slice of uiThread.asyncSliceGroup.getDescendantEvents()) { - if (/^animator\:/.test(slice.title)) - slices.push(slice); - } - return slices; - } - - /** - * Model for Android App specific data. - * @constructor - */ - function AndroidApp(process, uiThread, renderThread, surfaceFlinger, - uiDrawType) { - this.process = process; - this.uiThread = uiThread; - this.renderThread = renderThread; - this.surfaceFlinger = surfaceFlinger; - this.uiDrawType = uiDrawType; - - this.frames_ = undefined; - this.inputs_ = undefined; - }; - - AndroidApp.createForProcessIfPossible = function(process, surfaceFlinger) { - var uiThread = process.getThread(process.pid); - var uiDrawType = getUiDrawType(uiThread); - if (uiDrawType == UI_DRAW_TYPE.NONE) { - uiThread = undefined; - } - var renderThreads = process.findAllThreadsNamed('RenderThread'); - var renderThread = renderThreads.length == 1 ? renderThreads[0] : undefined; - - if (uiThread || renderThread) { - return new AndroidApp(process, uiThread, renderThread, surfaceFlinger, - uiDrawType); - } - }; - - AndroidApp.prototype = { - /** - * Returns a list of all frames in the trace for the app, - * constructed on first query. - */ - getFrames: function() { - if (!this.frames_) { - var uiFrames = getUiThreadDrivenFrames(this); - var rtFrames = getRenderThreadDrivenFrames(this); - this.frames_ = uiFrames.concat(rtFrames); - - // merge frames by sorting by end timestamp - this.frames_.sort(function(a, b) { a.end - b.end }); - } - return this.frames_; - }, - - /** - * Returns list of CounterSamples for each input event enqueued to the app. - */ - getInputSamples: function() { - if (!this.inputs_) { - this.inputs_ = getInputSamples(this.process); - } - return this.inputs_; - }, - - getAnimationAsyncSlices: function() { - if (!this.animations_) { - this.animations_ = getAnimationAsyncSlices(this.uiThread); - } - return this.animations_; - } - }; - - return { - AndroidApp: AndroidApp - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/helpers/android_model_helper.html b/chromium/third_party/catapult/tracing/tracing/model/helpers/android_model_helper.html deleted file mode 100644 index c0b3d5ce5bb..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/helpers/android_model_helper.html +++ /dev/null @@ -1,104 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/guid.html"> -<link rel="import" href="/tracing/base/range_utils.html"> -<link rel="import" href="/tracing/core/auditor.html"> -<link rel="import" href="/tracing/model/helpers/android_app.html"> -<link rel="import" href="/tracing/model/helpers/android_surface_flinger.html"> - -<script> -'use strict'; - -/** - * @fileoverview Class for managing android-specific model meta data, - * such as rendering apps, frames rendered, and SurfaceFlinger. - */ -tr.exportTo('tr.model.helpers', function() { - var AndroidApp = tr.model.helpers.AndroidApp; - var AndroidSurfaceFlinger = tr.model.helpers.AndroidSurfaceFlinger; - - var IMPORTANT_SURFACE_FLINGER_SLICES = { - 'doComposition' : true, - 'updateTexImage' : true, - 'postFramebuffer' : true - }; - var IMPORTANT_UI_THREAD_SLICES = { - 'Choreographer#doFrame' : true, - 'performTraversals' : true, - 'deliverInputEvent' : true - }; - var IMPORTANT_RENDER_THREAD_SLICES = { - 'doFrame' : true - }; - - function iterateImportantThreadSlices(thread, important, callback) { - if (!thread) - return; - - thread.sliceGroup.slices.forEach(function(slice) { - if (slice.title in important) - callback(slice); - }); - } - - /** - * Model for Android-specific data. - * @constructor - */ - function AndroidModelHelper(model) { - this.model = model; - this.apps = []; - this.surfaceFlinger = undefined; - - var processes = model.getAllProcesses(); - for (var i = 0; i < processes.length && !this.surfaceFlinger; i++) { - this.surfaceFlinger = - AndroidSurfaceFlinger.createForProcessIfPossible(processes[i]); - } - - model.getAllProcesses().forEach(function(process) { - var app = AndroidApp.createForProcessIfPossible( - process, this.surfaceFlinger); - if (app) - this.apps.push(app); - }, this); - }; - - AndroidModelHelper.guid = tr.b.GUID.allocateSimple(); - - AndroidModelHelper.supportsModel = function(model) { - return true; - }; - - AndroidModelHelper.prototype = { - iterateImportantSlices: function(callback) { - if (this.surfaceFlinger) { - iterateImportantThreadSlices( - this.surfaceFlinger.thread, - IMPORTANT_SURFACE_FLINGER_SLICES, - callback); - } - - this.apps.forEach(function(app) { - iterateImportantThreadSlices( - app.uiThread, - IMPORTANT_UI_THREAD_SLICES, - callback); - iterateImportantThreadSlices( - app.renderThread, - IMPORTANT_RENDER_THREAD_SLICES, - callback); - }); - } - }; - - return { - AndroidModelHelper: AndroidModelHelper - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/helpers/android_model_helper_test.html b/chromium/third_party/catapult/tracing/tracing/model/helpers/android_model_helper_test.html deleted file mode 100644 index 114bd5a8a10..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/helpers/android_model_helper_test.html +++ /dev/null @@ -1,227 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/extras/android/android_auditor.html"> -<link rel="import" href="/tracing/extras/importer/linux_perf/ftrace_importer.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var AndroidModelHelper = tr.model.helpers.AndroidModelHelper; - var newAsyncSliceNamed = tr.c.TestUtils.newAsyncSliceNamed; - var newSliceEx = tr.c.TestUtils.newSliceEx; - var newCounterNamed = tr.c.TestUtils.newCounterNamed; - var newCounterSeries = tr.c.TestUtils.newCounterSeries; - - function createSurfaceFlingerWithVsyncs(model) { - if (model.getProcess(2)) - throw new Error('process already exists'); - - var sfProcess = model.getOrCreateProcess(2); - var sfThread = sfProcess.getOrCreateThread(2); // main thread, tid = pid - sfThread.name = '/system/bin/surfaceflinger'; - - // ensure slicegroup has data - sfThread.sliceGroup.pushSlice(newSliceEx({ - title: 'doComposition', - start: 8, - duration: 2 - })); - - var counter = sfProcess.getOrCreateCounter('android', 'VSYNC'); - var series = newCounterSeries(); - for (var i = 0; i <= 10; i++) { - series.addCounterSample(i * 10, i % 2); - } - counter.addSeries(series); - } - - /* - * List of customizeModelCallbacks which produce different 80ms frames, - * each starting at 10ms, and with a single important slice - */ - var SINGLE_FRAME_CUSTOM_MODELS = [ - function(model) { - // UI thread only - var uiThread = model.getOrCreateProcess(120).getOrCreateThread(120); - uiThread.sliceGroup.pushSlice(newSliceEx( - {title: 'performTraversals', start: 10, duration: 80})); - - model.uiThread = uiThread; - }, - - function(model) { - // RenderThread only - var renderThread = model.getOrCreateProcess(120).getOrCreateThread(200); - renderThread.name = 'RenderThread'; - renderThread.sliceGroup.pushSlice(newSliceEx( - {title: 'doFrame', start: 10, duration: 80})); - - model.renderThread = renderThread; - }, - - function(model) { - var uiThread = model.getOrCreateProcess(120).getOrCreateThread(120); - - // UI thread time - 19 (from 10 to 29) - uiThread.asyncSliceGroup.push( - newAsyncSliceNamed('deliverInputEvent', 10, 9, uiThread, uiThread)); - uiThread.sliceGroup.pushSlice(newSliceEx( - {title: 'performTraversals', start: 20, duration: 10})); - uiThread.sliceGroup.pushSlice(newSliceEx( - {title: 'draw', start: 20, duration: 8})); - uiThread.sliceGroup.pushSlice(newSliceEx( - {title: 'Record View#draw()', start: 20, duration: 8})); - - // RenderThread time - 61 (from 29 to 90) - var renderThread = model.getOrCreateProcess(120).getOrCreateThread(200); - renderThread.name = 'RenderThread'; - renderThread.sliceGroup.pushSlice(newSliceEx( - {title: 'DrawFrame', start: 29, duration: 61})); - renderThread.sliceGroup.pushSlice(newSliceEx( - {title: 'syncFrameState', start: 29, duration: 1})); - - model.uiThread = uiThread; - model.renderThread = renderThread; - } - ]; - - test('getThreads', function() { - SINGLE_FRAME_CUSTOM_MODELS.forEach(function(customizeModelCallback) { - var model = tr.c.TestUtils.newModel(customizeModelCallback); - var helper = model.getOrCreateHelper(AndroidModelHelper); - assert.equal(helper.apps[0].uiThread, model.uiThread); - assert.equal(helper.apps[0].renderThread, model.renderThread); - }); - }); - - test('iterateImportantSlices', function() { - SINGLE_FRAME_CUSTOM_MODELS.forEach(function(customizeModelCallback) { - var model = tr.c.TestUtils.newModel(customizeModelCallback); - var helper = model.getOrCreateHelper(AndroidModelHelper); - - var seen = 0; - helper.iterateImportantSlices(function(importantSlice) { - assert.isTrue(importantSlice instanceof tr.model.Slice); - seen++; - }); - assert.equal(seen, 1); - }); - }); - - test('getFrames', function() { - SINGLE_FRAME_CUSTOM_MODELS.forEach(function(customizeModelCallback) { - var model = tr.c.TestUtils.newModel(customizeModelCallback); - var helper = model.getOrCreateHelper(AndroidModelHelper); - assert.equal(helper.apps.length, 1); - - var frames = helper.apps[0].getFrames(); - assert.equal(frames.length, 1); - assert.closeTo(frames[0].totalDuration, 80, 1e-5); - - assert.closeTo(frames[0].start, 10, 1e-5); - assert.closeTo(frames[0].end, 90, 1e-5); - }); - }); - - test('surfaceFlingerVsyncs', function() { - var model = tr.c.TestUtils.newModel(createSurfaceFlingerWithVsyncs); - var helper = model.getOrCreateHelper(AndroidModelHelper); - assert.isTrue(helper.surfaceFlinger.hasVsyncs); - - // test querying the vsyncs - assert.closeTo(helper.surfaceFlinger.getFrameKickoff(5), 0, 1e-5); - assert.closeTo(helper.surfaceFlinger.getFrameDeadline(95), 100, 1e-5); - - assert.closeTo(helper.surfaceFlinger.getFrameKickoff(10), 10, 1e-5); - assert.closeTo(helper.surfaceFlinger.getFrameDeadline(90), 100, 1e-5); - - // test undefined behavior outside of vsyncs. - assert.isUndefined(helper.surfaceFlinger.getFrameKickoff(-5)); - assert.isUndefined(helper.surfaceFlinger.getFrameDeadline(105)); - }); - - test('frameVsyncInterop', function() { - var model = tr.c.TestUtils.newModel(function(model) { - // app - 3 good, 3 bad frames - var uiThread = model.getOrCreateProcess(1).getOrCreateThread(1); - uiThread.sliceGroup.pushSlice(newSliceEx( - {title: 'performTraversals', start: 1, duration: 8})); - uiThread.sliceGroup.pushSlice(newSliceEx( - {title: 'performTraversals', start: 10, duration: 8})); - uiThread.sliceGroup.pushSlice(newSliceEx( - {title: 'performTraversals', start: 20, duration: 8})); - uiThread.sliceGroup.pushSlice(newSliceEx( - {title: 'performTraversals', start: 31, duration: 11})); - uiThread.sliceGroup.pushSlice(newSliceEx( - {title: 'performTraversals', start: 45, duration: 6})); - uiThread.sliceGroup.pushSlice(newSliceEx( - {title: 'performTraversals', start: 60, duration: 20})); - - // surface flinger - vsync every 10ms - createSurfaceFlingerWithVsyncs(model); - }); - var helper = model.getOrCreateHelper(AndroidModelHelper); - - var frames = helper.apps[0].getFrames(); - assert.equal(frames.length, 6); - for (var i = 0; i < 6; i++) { - var shouldMissDeadline = i >= 3; - var missedDeadline = frames[i].args['deadline'] < frames[i].end; - assert.equal(shouldMissDeadline, missedDeadline); - } - }); - - test('appInputs', function() { - var model = tr.c.TestUtils.newModel(function(model) { - var process = model.getOrCreateProcess(120); - var uiThread = process.getOrCreateThread(120); - uiThread.sliceGroup.pushSlice(newSliceEx( - {title: 'performTraversals', start: 20, duration: 4})); - uiThread.sliceGroup.pushSlice(newSliceEx( - {title: 'performTraversals', start: 40, duration: 4})); - - var counter = process.getOrCreateCounter('android', 'aq:pending:foo'); - var series = newCounterSeries(); - series.addCounterSample(10, 1); - series.addCounterSample(20, 0); - series.addCounterSample(30, 1); - series.addCounterSample(40, 2); - series.addCounterSample(50, 0); - counter.addSeries(series); - }); - var helper = model.getOrCreateHelper(AndroidModelHelper); - assert.equal(helper.apps.length, 1); - - var inputSamples = helper.apps[0].getInputSamples(); - assert.equal(inputSamples.length, 3); - assert.equal(inputSamples[0].timestamp, 10); - assert.equal(inputSamples[1].timestamp, 30); - assert.equal(inputSamples[2].timestamp, 40); - }); - - test('appAnimations', function() { - var model = tr.c.TestUtils.newModel(function(model) { - var process = model.getOrCreateProcess(120); - var uiThread = process.getOrCreateThread(120); - uiThread.sliceGroup.pushSlice(newSliceEx( - {title: 'performTraversals', start: 10, duration: 10})); - uiThread.asyncSliceGroup.push(newAsyncSliceNamed('animator:foo', 0, 10, - uiThread, uiThread)); - }); - var helper = model.getOrCreateHelper(AndroidModelHelper); - assert.equal(helper.apps.length, 1); - - var animations = helper.apps[0].getAnimationAsyncSlices(); - assert.equal(animations.length, 1); - assert.equal(animations[0].start, 0); - assert.equal(animations[0].end, 10); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/helpers/android_surface_flinger.html b/chromium/third_party/catapult/tracing/tracing/model/helpers/android_surface_flinger.html deleted file mode 100644 index 0ecc05f1054..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/helpers/android_surface_flinger.html +++ /dev/null @@ -1,105 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/sorted_array_utils.html"> - -<script> -'use strict'; - -/** - * @fileoverview Class for representing SurfaceFlinger process and its Vsyncs. - */ -tr.exportTo('tr.model.helpers', function() { - var findLowIndexInSortedArray = tr.b.findLowIndexInSortedArray; - - var VSYNC_SF_NAME = 'android.VSYNC-sf'; - var VSYNC_APP_NAME = 'android.VSYNC-app'; - var VSYNC_FALLBACK_NAME = 'android.VSYNC'; - - // when sampling vsync, push samples back by this much to ensure - // frame start samples *between* vsyncs - var TIMESTAMP_FUDGE_MS = 0.01; - - function getVsyncTimestamps(process, counterName) { - - var vsync = process.counters[counterName]; - if (!vsync) - vsync = process.counters[VSYNC_FALLBACK_NAME]; - - if (vsync && vsync.numSeries == 1 && vsync.numSamples > 1) - return vsync.series[0].timestamps; - return undefined; - } - - /** - * Model for SurfaceFlinger specific data. - * @constructor - */ - function AndroidSurfaceFlinger(process, thread) { - this.process = process; - this.thread = thread; - - this.appVsync_ = undefined; - this.sfVsync_ = undefined; - - this.appVsyncTimestamps_ = getVsyncTimestamps(process, VSYNC_APP_NAME); - this.sfVsyncTimestamps_ = getVsyncTimestamps(process, VSYNC_SF_NAME); - }; - - AndroidSurfaceFlinger.createForProcessIfPossible = function(process) { - var mainThread = process.getThread(process.pid); - - // newer versions - main thread, lowercase name, preceeding forward slash - if (mainThread && mainThread.name && - /surfaceflinger/.test(mainThread.name)) - return new AndroidSurfaceFlinger(process, mainThread); - - // older versions - another thread is named SurfaceFlinger - var primaryThreads = process.findAllThreadsNamed('SurfaceFlinger'); - if (primaryThreads.length == 1) - return new AndroidSurfaceFlinger(process, primaryThreads[0]); - return undefined; - }; - - AndroidSurfaceFlinger.prototype = { - get hasVsyncs() { - return !!this.appVsyncTimestamps_ && !!this.sfVsyncTimestamps_; - }, - - getFrameKickoff: function(timestamp) { - if (!this.hasVsyncs) - throw new Error('cannot query vsync info without vsyncs'); - - var firstGreaterIndex = - findLowIndexInSortedArray(this.appVsyncTimestamps_, - function(x) { return x; }, - timestamp + TIMESTAMP_FUDGE_MS); - - if (firstGreaterIndex < 1) - return undefined; - return this.appVsyncTimestamps_[firstGreaterIndex - 1]; - }, - - getFrameDeadline: function(timestamp) { - if (!this.hasVsyncs) - throw new Error('cannot query vsync info without vsyncs'); - - var firstGreaterIndex = - findLowIndexInSortedArray(this.sfVsyncTimestamps_, - function(x) { return x; }, - timestamp + TIMESTAMP_FUDGE_MS); - if (firstGreaterIndex >= this.sfVsyncTimestamps_.length) - return undefined; - return this.sfVsyncTimestamps_[firstGreaterIndex]; - } - }; - - return { - AndroidSurfaceFlinger: AndroidSurfaceFlinger - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_browser_helper.html b/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_browser_helper.html deleted file mode 100644 index f1f0a438e15..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_browser_helper.html +++ /dev/null @@ -1,129 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/model/helpers/chrome_process_helper.html"> - -<script> -'use strict'; - -/** - * @fileoverview Utilities for accessing trace data about the Chrome browser. - */ -tr.exportTo('tr.model.helpers', function() { - function ChromeBrowserHelper(modelHelper, process) { - tr.model.helpers.ChromeProcessHelper.call(this, modelHelper, process); - this.mainThread_ = process.findAtMostOneThreadNamed('CrBrowserMain'); - } - - ChromeBrowserHelper.isBrowserProcess = function(process) { - return !!process.findAtMostOneThreadNamed('CrBrowserMain'); - }; - - ChromeBrowserHelper.prototype = { - __proto__: tr.model.helpers.ChromeProcessHelper.prototype, - - // TODO(petrcermak): Pass browser name in a metadata event (see - // crbug.com/605088). - get browserName() { - var hasInProcessRendererThread = this.process.findAllThreadsNamed( - 'Chrome_InProcRendererThread').length > 0; - return hasInProcessRendererThread ? 'webview' : 'chrome'; - }, - - get rendererHelpers() { - return this.modelHelper.rendererHelpers; - }, - - getLoadingEventsInRange: function(rangeOfInterest) { - return this.getAllAsyncSlicesMatching(function(slice) { - return slice.title.indexOf('WebContentsImpl Loading') === 0 && - rangeOfInterest.intersectsExplicitRangeInclusive( - slice.start, slice.end); - }); - }, - - getCommitProvisionalLoadEventsInRange: function(rangeOfInterest) { - return this.getAllAsyncSlicesMatching(function(slice) { - return slice.title === 'RenderFrameImpl::didCommitProvisionalLoad' && - rangeOfInterest.intersectsExplicitRangeInclusive( - slice.start, slice.end); - }); - }, - - get hasLatencyEvents() { - var hasLatency = false; - for (var thread of this.modelHelper.model.getAllThreads()) - for (var event of thread.getDescendantEvents()) { - if (!event.isTopLevel) - continue; - if (!(event instanceof tr.e.cc.InputLatencyAsyncSlice)) - continue; - hasLatency = true; - } - return hasLatency; - }, - - getLatencyEventsInRange: function(rangeOfInterest) { - return this.getAllAsyncSlicesMatching(function(slice) { - return (slice.title.indexOf('InputLatency') === 0) && - rangeOfInterest.intersectsExplicitRangeInclusive( - slice.start, slice.end); - }); - }, - - getAllAsyncSlicesMatching: function(pred, opt_this) { - var events = []; - this.iterAllThreads(function(thread) { - for (var slice of thread.getDescendantEvents()) - if (pred.call(opt_this, slice)) - events.push(slice); - }); - return events; - }, - - getAllNetworkEventsInRange: function(rangeOfInterest) { - var networkEvents = []; - this.modelHelper.model.getAllThreads().forEach(function(thread) { - thread.asyncSliceGroup.slices.forEach(function(slice) { - var match = false; - if (slice.category == 'net' || // old-style URLRequest/Resource - slice.category == 'disabled-by-default-netlog' || - slice.category == 'netlog') { - match = true; - } - - if (!match) - return; - - if (rangeOfInterest.intersectsExplicitRangeInclusive( - slice.start, slice.end)) - networkEvents.push(slice); - }); - }); - return networkEvents; - }, - - iterAllThreads: function(func, opt_this) { - tr.b.iterItems(this.process.threads, function(tid, thread) { - func.call(opt_this, thread); - }); - - tr.b.iterItems(this.rendererHelpers, function(pid, rendererHelper) { - var rendererProcess = rendererHelper.process; - tr.b.iterItems(rendererProcess.threads, function(tid, thread) { - func.call(opt_this, thread); - }); - }, this); - } - }; - - return { - ChromeBrowserHelper: ChromeBrowserHelper - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_browser_helper_test.html b/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_browser_helper_test.html deleted file mode 100644 index eba20ad50af..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_browser_helper_test.html +++ /dev/null @@ -1,83 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/extras/chrome/cc/input_latency_async_slice.html"> -<link rel="import" href="/tracing/extras/chrome/chrome_test_utils.html"> -<link rel="import" href="/tracing/extras/importer/trace_event_importer.html"> -<link rel="import" href="/tracing/model/helpers/chrome_browser_helper.html"> -<link rel="import" href="/tracing/model/helpers/chrome_model_helper.html"> -<link rel="import" href="/tracing/model/model.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var INPUT_TYPE = tr.e.cc.INPUT_EVENT_TYPE_NAMES; - - function getRange(min, max) { - var range = new tr.b.Range(); - range.min = min; - range.max = max; - return range; - } - - test('LoadingEvent', function() { - var model = tr.e.chrome.ChromeTestUtils.newChromeModel(function() { }); - var modelHelper = model.getOrCreateHelper( - tr.model.helpers.ChromeModelHelper); - tr.e.chrome.ChromeTestUtils.addLoadingEvent(model, {start: 1, end: 10}); - assert.equal(1, modelHelper.browserHelper.getLoadingEventsInRange( - getRange(0, 100)).length); - }); - - test('ProvisionalLoadEvent', function() { - var model = tr.e.chrome.ChromeTestUtils.newChromeModel(function() { }); - var modelHelper = model.getOrCreateHelper( - tr.model.helpers.ChromeModelHelper); - tr.e.chrome.ChromeTestUtils.addCommitLoadEvent(model, {start: 1, end: 10}); - assert.equal(1, - modelHelper.browserHelper.getCommitProvisionalLoadEventsInRange( - getRange(0, 100)).length); - }); - - test('LatencyEvent', function() { - var model = tr.e.chrome.ChromeTestUtils.newChromeModel(function() { }); - var modelHelper = model.getOrCreateHelper( - tr.model.helpers.ChromeModelHelper); - tr.e.chrome.ChromeTestUtils.addInputEvent( - model, INPUT_TYPE.UNKNOWN, {start: 1, end: 10}); - assert.equal(1, modelHelper.browserHelper.getLatencyEventsInRange( - getRange(0, 100)).length); - }); - - test('NetworkEvent', function() { - var model = tr.e.chrome.ChromeTestUtils.newChromeModel(function() { }); - var modelHelper = model.getOrCreateHelper( - tr.model.helpers.ChromeModelHelper); - tr.e.chrome.ChromeTestUtils.addNetworkEvent(model, {start: 1, end: 10}); - assert.equal(1, modelHelper.browserHelper.getAllNetworkEventsInRange( - getRange(0, 100)).length); - }); - - test('browserName_chrome', function() { - var model = tr.e.chrome.ChromeTestUtils.newChromeModel(function() { }); - var modelHelper = model.getOrCreateHelper( - tr.model.helpers.ChromeModelHelper); - assert.strictEqual(modelHelper.browserHelper.browserName, 'chrome'); - }); - - test('browserName_webview', function() { - var model = tr.e.chrome.ChromeTestUtils.newChromeModel(function() { }); - model.browserProcess.getOrCreateThread(42).name = - 'Chrome_InProcRendererThread'; - var modelHelper = model.getOrCreateHelper( - tr.model.helpers.ChromeModelHelper); - assert.strictEqual(modelHelper.browserHelper.browserName, 'webview'); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_gpu_helper.html b/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_gpu_helper.html deleted file mode 100644 index fe3cb49e108..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_gpu_helper.html +++ /dev/null @@ -1,41 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/model/helpers/chrome_process_helper.html"> - -<script> -'use strict'; - -/** - * @fileoverview Utilities for accessing the Chrome GPU Process. - */ -tr.exportTo('tr.model.helpers', function() { - function ChromeGpuHelper(modelHelper, process) { - tr.model.helpers.ChromeProcessHelper.call(this, modelHelper, process); - this.mainThread_ = process.findAtMostOneThreadNamed('CrGpuMain'); - }; - - ChromeGpuHelper.isGpuProcess = function(process) { - // In some android builds the GPU thread is not in a separate process. - if (process.findAtMostOneThreadNamed('CrBrowserMain') || - process.findAtMostOneThreadNamed('CrRendererMain')) - return false; - return process.findAtMostOneThreadNamed('CrGpuMain'); - }; - - ChromeGpuHelper.prototype = { - __proto__: tr.model.helpers.ChromeProcessHelper.prototype, - - get mainThread() { - return this.mainThread_; - } - }; - - return { - ChromeGpuHelper: ChromeGpuHelper - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_model_helper.html b/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_model_helper.html deleted file mode 100644 index 51b762abb3c..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_model_helper.html +++ /dev/null @@ -1,124 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/guid.html"> -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/model/helpers/chrome_browser_helper.html"> -<link rel="import" href="/tracing/model/helpers/chrome_gpu_helper.html"> -<link rel="import" href="/tracing/model/helpers/chrome_renderer_helper.html"> - -<script> -'use strict'; - -/** - * @fileoverview Utilities for accessing trace data about the Chrome browser. - */ -tr.exportTo('tr.model.helpers', function() { - function findChromeBrowserProcesses(model) { - return model.getAllProcesses( - tr.model.helpers.ChromeBrowserHelper.isBrowserProcess); - } - - function findChromeRenderProcesses(model) { - return model.getAllProcesses( - tr.model.helpers.ChromeRendererHelper.isRenderProcess); - } - - function findChromeGpuProcess(model) { - var gpuProcesses = model.getAllProcesses( - tr.model.helpers.ChromeGpuHelper.isGpuProcess); - if (gpuProcesses.length !== 1) - return undefined; - return gpuProcesses[0]; - } - - /** - * @constructor - */ - function ChromeModelHelper(model) { - this.model_ = model; - - // Find browserHelpers. - var browserProcesses = findChromeBrowserProcesses(model); - this.browserHelpers_ = browserProcesses.map( - p => new tr.model.helpers.ChromeBrowserHelper(this, p)); - - // Find gpuHelper. - var gpuProcess = findChromeGpuProcess(model); - if (gpuProcess) { - this.gpuHelper_ = new tr.model.helpers.ChromeGpuHelper( - this, gpuProcess); - } else { - this.gpuHelper_ = undefined; - } - - // Find rendererHelpers. - var rendererProcesses_ = findChromeRenderProcesses(model); - - this.rendererHelpers_ = {}; - rendererProcesses_.forEach(function(renderProcess) { - var rendererHelper = new tr.model.helpers.ChromeRendererHelper( - this, renderProcess); - this.rendererHelpers_[rendererHelper.pid] = rendererHelper; - }, this); - } - - ChromeModelHelper.guid = tr.b.GUID.allocateSimple(); - - ChromeModelHelper.supportsModel = function(model) { - if (findChromeBrowserProcesses(model).length) - return true; - if (findChromeRenderProcesses(model).length) - return true; - return false; - }; - - ChromeModelHelper.prototype = { - get pid() { - throw new Error('woah'); - }, - - get process() { - throw new Error('woah'); - }, - - get model() { - return this.model_; - }, - - // TODO: Make all users of ChromeModelHelper support multiple browsers and - // remove this getter (see #2119). - get browserProcess() { - if (this.browserHelper === undefined) - return undefined; - return this.browserHelper.process; - }, - - // TODO: Make all users of ChromeModelHelper support multiple browsers and - // remove this getter (see #2119). - get browserHelper() { - return this.browserHelpers_[0]; - }, - - get browserHelpers() { - return this.browserHelpers_; - }, - - get gpuHelper() { - return this.gpuHelper_; - }, - - get rendererHelpers() { - return this.rendererHelpers_; - } - }; - - return { - ChromeModelHelper: ChromeModelHelper - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_model_helper_test.html b/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_model_helper_test.html deleted file mode 100644 index f9664840ade..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_model_helper_test.html +++ /dev/null @@ -1,167 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/extras/chrome/chrome_test_utils.html"> -<link rel="import" href="/tracing/extras/importer/trace_event_importer.html"> -<link rel="import" href="/tracing/model/helpers/chrome_browser_helper.html"> -<link rel="import" href="/tracing/model/helpers/chrome_model_helper.html"> -<link rel="import" href="/tracing/model/model.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var newAsyncSliceEx = tr.c.TestUtils.newAsyncSliceEx; - - test('getLatencyData', function() { - var m = tr.e.chrome.ChromeTestUtils.newChromeModel(function(m) { - m.browserMain.asyncSliceGroup.push(newAsyncSliceEx({ - title: 'InputLatency::GestureScrollUpdate', - cat: 'benchmark', - start: 0, - end: 10, - id: '0x100', - isTopLevel: true, - args: { - data: { - INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT: {'time' : 0}, - INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT: {time: 10} - } - } - })); - }); - - var modelHelper = m.getOrCreateHelper(tr.model.helpers.ChromeModelHelper); - var latencyEvents = modelHelper.browserHelper.getLatencyEventsInRange( - m.bounds); - assert.equal(latencyEvents.length, 1); - }); - - test('getFrametime', function() { - var frame_ts; - var events = []; - // Browser process 3507 - events.push({'cat' : '__metadata', 'pid' : 3507, 'tid' : 3507, 'ts' : 0, 'ph' : 'M', 'name' : 'thread_name', 'args' : {'name' : 'CrBrowserMain'}}); // @suppress longLineCheck - - // Renderer process 3508 - events.push({'cat' : '__metadata', 'pid' : 3508, 'tid' : 3508, 'ts' : 0, 'ph' : 'M', 'name' : 'thread_name', 'args' : {'name' : 'CrRendererMain'}}); // @suppress longLineCheck - // Compositor thread 3510 - events.push({'cat' : '__metadata', 'pid' : 3508, 'tid' : 3510, 'ts' : 0, 'ph' : 'M', 'name' : 'thread_name', 'args' : {'name' : 'Compositor'}}); // @suppress longLineCheck - - // Renderer process 3509 - events.push({'cat' : '__metadata', 'pid' : 3509, 'tid' : 3509, 'ts' : 0, 'ph' : 'M', 'name' : 'thread_name', 'args' : {'name' : 'CrRendererMain'}}); // @suppress longLineCheck - - // Compositor thread 3511 - events.push({'cat' : '__metadata', 'pid' : 3509, 'tid' : 3511, 'ts' : 0, 'ph' : 'M', 'name' : 'thread_name', 'args' : {'name' : 'Compositor'}}); // @suppress longLineCheck - - frame_ts = 0; - // Add impl rendering stats for browser process 3507 - for (var i = 0; i < 10; i++) { - events.push({'cat' : 'benchmark', 'pid' : 3507, 'tid' : 3507, 'ts' : frame_ts, 'ph' : 'i', 'name' : 'BenchmarkInstrumentation::ImplThreadRenderingStats', 's' : 't'}); // @suppress longLineCheck - frame_ts += 16000 + 1000 * (i % 2); - } - - frame_ts = 0; - // Add main rendering stats for renderer process 3508 - for (var i = 0; i < 10; i++) { - events.push({'cat' : 'benchmark', 'pid' : 3508, 'tid' : 3508, 'ts' : frame_ts, 'ph' : 'i', 'name' : 'BenchmarkInstrumentation::MainThreadRenderingStats', 's' : 't'}); // @suppress longLineCheck - frame_ts += 16000 + 1000 * (i % 2); - } - events.push({'cat' : 'benchmark', 'pid' : 3508, 'tid' : 3510, 'ts' : 1600, 'ph' : 'i', 'name' : 'KeepAlive', 's' : 't'}); // @suppress longLineCheck - - frame_ts = 0; - // Add impl and main rendering stats for renderer process 3509 - for (var i = 0; i < 10; i++) { - events.push({'cat' : 'benchmark', 'pid' : 3509, 'tid' : 3511, 'ts' : frame_ts, 'ph' : 'i', 'name' : 'BenchmarkInstrumentation::ImplThreadRenderingStats', 's' : 't'}); // @suppress longLineCheck - events.push({'cat' : 'benchmark', 'pid' : 3509, 'tid' : 3509, 'ts' : frame_ts, 'ph' : 'i', 'name' : 'BenchmarkInstrumentation::MainThreadRenderingStats', 's' : 't'}); // @suppress longLineCheck - frame_ts += 16000 + 1000 * (i % 2); - } - - var m = tr.c.TestUtils.newModelWithEvents([events]); - var modelHelper = m.getOrCreateHelper(tr.model.helpers.ChromeModelHelper); - - // Testing browser impl and main rendering stats. - var frameEvents = modelHelper.browserHelper.getFrameEventsInRange( - tr.model.helpers.IMPL_FRAMETIME_TYPE, m.bounds); - var frametimeData = tr.model.helpers.getFrametimeDataFromEvents( - frameEvents); - assert.equal(frametimeData.length, 9); - for (var i = 0; i < frametimeData.length; i++) { - assert.equal(frametimeData[i].frametime, 16 + i % 2); - } - // No main rendering stats. - frameEvents = modelHelper.browserHelper.getFrameEventsInRange( - tr.model.helpers.MAIN_FRAMETIME_TYPE, m.bounds); - assert.equal(frameEvents.length, 0); - - - // Testing renderer 3508 impl and main rendering stats. - frameEvents = modelHelper.rendererHelpers[3508].getFrameEventsInRange( - tr.model.helpers.MAIN_FRAMETIME_TYPE, m.bounds); - frametimeData = tr.model.helpers.getFrametimeDataFromEvents(frameEvents); - assert.equal(frametimeData.length, 9); - for (var i = 0; i < frametimeData.length; i++) { - assert.equal(frametimeData[i].frametime, 16 + i % 2); - } - - // No impl rendering stats. - frameEvents = modelHelper.rendererHelpers[3508].getFrameEventsInRange( - tr.model.helpers.IMPL_FRAMETIME_TYPE, m.bounds); - assert.equal(frameEvents.length, 0); - - - // Testing renderer 3509 impl and main rendering stats. - frameEvents = modelHelper.rendererHelpers[3509].getFrameEventsInRange( - tr.model.helpers.IMPL_FRAMETIME_TYPE, m.bounds); - frametimeData = tr.model.helpers.getFrametimeDataFromEvents(frameEvents); - assert.equal(frametimeData.length, 9); - for (var i = 0; i < frametimeData.length; i++) { - assert.equal(frametimeData[i].frametime, 16 + i % 2); - } - - frameEvents = modelHelper.rendererHelpers[3509].getFrameEventsInRange( - tr.model.helpers.MAIN_FRAMETIME_TYPE, m.bounds); - frametimeData = tr.model.helpers.getFrametimeDataFromEvents(frameEvents); - assert.equal(frametimeData.length, 9); - for (var i = 0; i < frametimeData.length; i++) { - assert.equal(frametimeData[i].frametime, 16 + i % 2); - } - - }); - - test('multipleBrowsers', function() { - var m = tr.c.TestUtils.newModel(function(model) { - var browserProcess1 = model.getOrCreateProcess(1); - browserProcess1.getOrCreateThread(2).name = 'CrBrowserMain'; - - var browserProcess2 = model.getOrCreateProcess(3); - browserProcess2.getOrCreateThread(4); - browserProcess2.getOrCreateThread(5).name = 'CrBrowserMain'; - - var nonBrowserProcess = model.getOrCreateProcess(6); - nonBrowserProcess.getOrCreateThread(7); - - var browserProcess3 = model.getOrCreateProcess(8); - browserProcess3.getOrCreateThread(9).name = 'CrBrowserMain'; - browserProcess3.getOrCreateThread(10); - }); - - var modelHelper = m.getOrCreateHelper(tr.model.helpers.ChromeModelHelper); - var browserHelpers = modelHelper.browserHelpers; - - // Check that the correct processes were marked as Chrome browser processes. - assert.sameMembers(browserHelpers.map(h => h.process.pid), [1, 3, 8]); - - // Check that the browser helpers have the correct structure. - browserHelpers.forEach(function(helper) { - assert.instanceOf(helper, tr.model.helpers.ChromeBrowserHelper); - assert.strictEqual(helper.modelHelper, modelHelper); - }); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_process_helper.html b/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_process_helper.html deleted file mode 100644 index 7c31f100451..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_process_helper.html +++ /dev/null @@ -1,86 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/base.html"> - -<script> -'use strict'; - -/** - * @fileoverview Utilities for accessing trace data about the Chrome browser. - */ -tr.exportTo('tr.model.helpers', function() { - var MAIN_FRAMETIME_TYPE = 'main_frametime_type'; - var IMPL_FRAMETIME_TYPE = 'impl_frametime_type'; - - var MAIN_RENDERING_STATS = - 'BenchmarkInstrumentation::MainThreadRenderingStats'; - var IMPL_RENDERING_STATS = - 'BenchmarkInstrumentation::ImplThreadRenderingStats'; - - - function getSlicesIntersectingRange(rangeOfInterest, slices) { - var slicesInFilterRange = []; - for (var i = 0; i < slices.length; i++) { - var slice = slices[i]; - if (rangeOfInterest.intersectsExplicitRangeInclusive( - slice.start, slice.end)) - slicesInFilterRange.push(slice); - } - return slicesInFilterRange; - } - - - function ChromeProcessHelper(modelHelper, process) { - this.modelHelper = modelHelper; - this.process = process; - } - - ChromeProcessHelper.prototype = { - get pid() { - return this.process.pid; - }, - - getFrameEventsInRange: function(frametimeType, range) { - var titleToGet = (frametimeType === MAIN_FRAMETIME_TYPE ? - MAIN_RENDERING_STATS : IMPL_RENDERING_STATS); - - var frameEvents = []; - for (var event of this.process.getDescendantEvents()) - if (event.title === titleToGet) - if (range.intersectsExplicitRangeInclusive(event.start, event.end)) - frameEvents.push(event); - - frameEvents.sort(function(a, b) {return a.start - b.start}); - return frameEvents; - } - }; - - function getFrametimeDataFromEvents(frameEvents) { - var frametimeData = []; - for (var i = 1; i < frameEvents.length; i++) { - var diff = frameEvents[i].start - frameEvents[i - 1].start; - frametimeData.push({ - 'x': frameEvents[i].start, - 'frametime': diff - }); - } - return frametimeData; - } - - return { - ChromeProcessHelper: ChromeProcessHelper, - - MAIN_FRAMETIME_TYPE: MAIN_FRAMETIME_TYPE, - IMPL_FRAMETIME_TYPE: IMPL_FRAMETIME_TYPE, - MAIN_RENDERING_STATS: MAIN_RENDERING_STATS, - IMPL_RENDERING_STATS: IMPL_RENDERING_STATS, - - getSlicesIntersectingRange: getSlicesIntersectingRange, - getFrametimeDataFromEvents: getFrametimeDataFromEvents - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_renderer_helper.html b/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_renderer_helper.html deleted file mode 100644 index a75906feb1c..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_renderer_helper.html +++ /dev/null @@ -1,69 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2014 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/model/helpers/chrome_process_helper.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model.helpers', function() { - function ChromeRendererHelper(modelHelper, process) { - tr.model.helpers.ChromeProcessHelper.call(this, modelHelper, process); - this.mainThread_ = process.findAtMostOneThreadNamed('CrRendererMain'); - this.compositorThread_ = process.findAtMostOneThreadNamed('Compositor'); - this.rasterWorkerThreads_ = process.findAllThreadsMatching(function(t) { - if (t.name === undefined) - return false; - if (t.name.indexOf('CompositorTileWorker') === 0) - return true; - if (t.name.indexOf('CompositorRasterWorker') === 0) - return true; - return false; - }); - - this.isChromeTracingUI_ = - process.labels !== undefined && - process.labels.length === 1 && - process.labels[0] === 'chrome://tracing'; - }; - - // Returns true if there is either a main thread or a compositor thread. - ChromeRendererHelper.isRenderProcess = function(process) { - if (process.findAtMostOneThreadNamed('CrRendererMain')) - return true; - if (process.findAtMostOneThreadNamed('Compositor')) - return true; - return false; - }; - - ChromeRendererHelper.prototype = { - __proto__: tr.model.helpers.ChromeProcessHelper.prototype, - - // May be undefined. - get mainThread() { - return this.mainThread_; - }, - - // May be undefined. - get compositorThread() { - return this.compositorThread_; - }, - - // May be empty. - get rasterWorkerThreads() { - return this.rasterWorkerThreads_; - }, - - get isChromeTracingUI() { - return this.isChromeTracingUI_; - } - }; - - return { - ChromeRendererHelper: ChromeRendererHelper - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/instant_event.html b/chromium/third_party/catapult/tracing/tracing/model/instant_event.html deleted file mode 100644 index 5c50132116c..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/instant_event.html +++ /dev/null @@ -1,102 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/timed_event.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - var InstantEventType = { - GLOBAL: 1, - PROCESS: 2 - }; - - /** - * An InstantEvent is a zero-duration event. - * - * @constructor - */ - function InstantEvent(category, title, colorId, start, args) { - tr.model.TimedEvent.call(this, start); - - this.category = category || ''; - this.title = title; - this.colorId = colorId; - this.args = args; - - this.type = undefined; - }; - - InstantEvent.prototype = { - __proto__: tr.model.TimedEvent.prototype - }; - - /** - * A GlobalInstantEvent is a zero-duration event that's not tied to any - * particular process. - * - * An example is a trace event that's issued when a new USB device is plugged - * into the machine. - * - * @constructor - */ - function GlobalInstantEvent(category, title, colorId, start, args) { - InstantEvent.apply(this, arguments); - this.type = InstantEventType.GLOBAL; - }; - - GlobalInstantEvent.prototype = { - __proto__: InstantEvent.prototype, - get userFriendlyName() { - return 'Global instant event ' + this.title + ' @ ' + - tr.v.Unit.byName.timeStampInMs.format(start); - } - }; - - /** - * A ProcessInstantEvent is a zero-duration event that's tied to a - * particular process. - * - * An example is a trace event that's issued when a kill signal is received. - * - * @constructor - */ - function ProcessInstantEvent(category, title, colorId, start, args) { - InstantEvent.apply(this, arguments); - this.type = InstantEventType.PROCESS; - }; - - ProcessInstantEvent.prototype = { - __proto__: InstantEvent.prototype, - - get userFriendlyName() { - return 'Process-level instant event ' + this.title + ' @ ' + - tr.v.Unit.byName.timeStampInMs.format(start); - } - }; - - tr.model.EventRegistry.register( - InstantEvent, - { - name: 'instantEvent', - pluralName: 'instantEvents', - singleViewElementName: 'tr-ui-a-single-instant-event-sub-view', - multiViewElementName: 'tr-ui-a-multi-instant-event-sub-view' - }); - - return { - GlobalInstantEvent: GlobalInstantEvent, - ProcessInstantEvent: ProcessInstantEvent, - - InstantEventType: InstantEventType, - InstantEvent: InstantEvent - }; -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/interaction_record_test.html b/chromium/third_party/catapult/tracing/tracing/model/interaction_record_test.html deleted file mode 100644 index 1302f6517b6..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/interaction_record_test.html +++ /dev/null @@ -1,117 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/user_model/stub_expectation.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var TestUtils = tr.c.TestUtils; - var CompoundEventSelectionState = tr.model.CompoundEventSelectionState; - - function createModel(opt_customizeModelCallback) { - return TestUtils.newModel(function(model) { - model.p1 = model.getOrCreateProcess(1); - model.t2 = model.p1.getOrCreateThread(2); - - model.s1 = model.t2.sliceGroup.pushSlice(TestUtils.newSliceEx({ - title: 'a', start: 10, end: 20 - })); - model.s2 = model.t2.sliceGroup.pushSlice(TestUtils.newSliceEx({ - title: 'b', start: 20, end: 30 - })); - - model.ir1 = new tr.model.um.StubExpectation({ - parentModel: model, - start: 100, end: 200, - typeName: 'Response', - normalizedEfficiency: 1., - normalizedUserComfort: 0.0 - }); - model.userModel.expectations.push(model.ir1); - model.ir1.associatedEvents.push(model.s1); - model.ir1.associatedEvents.push(model.s2); - - if (opt_customizeModelCallback) - opt_customizeModelCallback(model); - }); - } - test('notSelected', function() { - var model = createModel(); - - var sel = new tr.model.EventSet(); - - assert.equal(CompoundEventSelectionState.NOT_SELECTED, - model.ir1.computeCompoundEvenSelectionState(sel)); - }); - - test('directSelected', function() { - var model = createModel(); - - var sel = new tr.model.EventSet(); - sel.push(model.ir1); - - assert.equal(CompoundEventSelectionState.EVENT_SELECTED, - model.ir1.computeCompoundEvenSelectionState(sel)); - }); - - test('directAndSomeAssociatedSelected', function() { - var model = createModel(); - - var sel = new tr.model.EventSet(); - sel.push(model.ir1); - sel.push(model.s1); - - assert.equal( - CompoundEventSelectionState.EVENT_AND_SOME_ASSOCIATED_SELECTED, - model.ir1.computeCompoundEvenSelectionState(sel)); - - }); - - test('allAssociatedEventsSelected', function() { - var model = createModel(); - - var sel = new tr.model.EventSet(); - sel.push(model.s1); - sel.push(model.s2); - - assert.equal(CompoundEventSelectionState.ALL_ASSOCIATED_EVENTS_SELECTED, - model.ir1.computeCompoundEvenSelectionState(sel)); - }); - - test('directAndAllAssociated', function() { - var model = createModel(); - - var sel = new tr.model.EventSet(); - sel.push(model.ir1); - sel.push(model.s1); - sel.push(model.s2); - - assert.equal(CompoundEventSelectionState.EVENT_AND_ALL_ASSOCIATED_SELECTED, - model.ir1.computeCompoundEvenSelectionState(sel)); - }); - - test('stableId', function() { - var model = TestUtils.newModel(); - - var ir1 = model.userModel.expectations.push( - TestUtils.newInteractionRecord(model, 0, 10)); - var ir2 = model.userModel.expectations.push( - TestUtils.newInteractionRecord(model, 10, 10)); - var ir3 = model.userModel.expectations.push( - TestUtils.newInteractionRecord(model, 20, 10)); - - assert.equal('UserExpectation.' + ir1.guid, ir1.stableId); - assert.equal('UserExpectation.' + ir2.guid, ir2.stableId); - assert.equal('UserExpectation.' + ir3.guid, ir3.stableId); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/ir_coverage.html b/chromium/third_party/catapult/tracing/tracing/model/ir_coverage.html deleted file mode 100644 index 80cdd387a3c..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/ir_coverage.html +++ /dev/null @@ -1,87 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/model/event_set.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - function getAssociatedEvents(irs) { - var allAssociatedEvents = new tr.model.EventSet(); - irs.forEach(function(ir) { - ir.associatedEvents.forEach(function(event) { - // FlowEvents don't have parentContainers or cpuDurations, and it's - // annoying to highlight them. - if (event instanceof tr.model.FlowEvent) - return; - allAssociatedEvents.push(event); - }); - }); - return allAssociatedEvents; - } - - function getUnassociatedEvents(model, associatedEvents) { - var unassociatedEvents = new tr.model.EventSet(); - // The set of unassociated events contains only events that are not in - // the set of associated events. - // Only add event to the set of unassociated events if it is not in - // the set of associated events. - for (var proc of model.getAllProcesses()) - for (var thread of tr.b.dictionaryValues(proc.threads)) - for (var event of thread.sliceGroup.getDescendantEvents()) - if (!associatedEvents.contains(event)) - unassociatedEvents.push(event); - return unassociatedEvents; - } - - function getTotalCpuDuration(events) { - var cpuMs = 0; - events.forEach(function(event) { - // Add up events' cpu self time if they have any. - if (event.cpuSelfTime) - cpuMs += event.cpuSelfTime; - }); - return cpuMs; - } - - function getIRCoverageFromModel(model) { - var associatedEvents = getAssociatedEvents(model.userModel.expectations); - - if (!associatedEvents.length) - return undefined; - - var unassociatedEvents = getUnassociatedEvents( - model, associatedEvents); - - var associatedCpuMs = getTotalCpuDuration(associatedEvents); - var unassociatedCpuMs = getTotalCpuDuration(unassociatedEvents); - - var totalEventCount = associatedEvents.length + unassociatedEvents.length; - var totalCpuMs = associatedCpuMs + unassociatedCpuMs; - var coveredEventsCpuTimeRatio = undefined; - if (totalCpuMs !== 0) - coveredEventsCpuTimeRatio = associatedCpuMs / totalCpuMs; - - return { - associatedEventsCount: associatedEvents.length, - unassociatedEventsCount: unassociatedEvents.length, - associatedEventsCpuTimeMs: associatedCpuMs, - unassociatedEventsCpuTimeMs: unassociatedCpuMs, - coveredEventsCountRatio: associatedEvents.length / totalEventCount, - coveredEventsCpuTimeRatio: coveredEventsCpuTimeRatio - }; - } - - return { - getIRCoverageFromModel: getIRCoverageFromModel, - getAssociatedEvents: getAssociatedEvents, - getUnassociatedEvents: getUnassociatedEvents - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/ir_coverage_test.html b/chromium/third_party/catapult/tracing/tracing/model/ir_coverage_test.html deleted file mode 100644 index e8a1637e60d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/ir_coverage_test.html +++ /dev/null @@ -1,90 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/ir_coverage.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var newSliceEx = tr.c.TestUtils.newSliceEx; - - function createModel() { - return tr.c.TestUtils.newModel(function(model) { - var process = model.getOrCreateProcess(1); - var thread = process.getOrCreateThread(2); - var s0 = thread.sliceGroup.pushSlice(newSliceEx( - {title: 's0', start: 0.0, duration: 1.0})); - s0.isTopLevel = true; - var unassociatedEvent = thread.sliceGroup.pushSlice(newSliceEx( - {title: 's1', start: 6.0, duration: 1.0})); - unassociatedEvent.isTopLevel = true; - var s2 = thread.sliceGroup.pushSlice(newSliceEx( - {title: 's2', start: 2.0, duration: 1.0})); - s2.isTopLevel = true; - var f0 = tr.c.TestUtils.newFlowEventEx({ - title: 'test1', - start: 0, - end: 10, - startSlice: s0, - endSlice: s2, - id: '0x100' - }); - model.flowEvents.push(f0); - var as1 = tr.c.TestUtils.newAsyncSliceEx({ - title: 'InputLatency::GestureTap', - cat: 'benchmark,latencyInfo', - start: 2, - end: 10, - id: '0x100', - isTopLevel: true, - startThread: thread - }); - thread.asyncSliceGroup.push(as1); - var ir = new tr.model.um.StubExpectation( - {parentModel: model, start: 0, duration: 7}); - ir.associatedEvents.push(as1); - ir.associatedEvents.push(s0); - ir.associatedEvents.push(s2); - ir.associatedEvents.push(f0); - model.userModel.expectations.push(ir); - }); - } - - test('computeCoverage', function() { - var model = createModel(); - for (var event of model.getDescendantEvents()) { - if (event.title === 's0' || event.title === 's2') { - event.cpuSelfTime = 0.4; - } else if (event.title === 's1') { - event.cpuSelfTime = 0.8; - } - } - - var coverage = tr.model.getIRCoverageFromModel(model); - assert.equal(3, coverage.associatedEventsCount); - assert.equal(1, coverage.unassociatedEventsCount); - assert.closeTo(0.75, coverage.coveredEventsCountRatio, 1e-3); - assert.closeTo(0.8, coverage.associatedEventsCpuTimeMs, 1e-3); - assert.closeTo(0.8, coverage.unassociatedEventsCpuTimeMs, 1e-3); - assert.closeTo(0.5, coverage.coveredEventsCpuTimeRatio, 1e-3); - }); - - test('zeroCPU', function() { - var model = createModel(); - var coverage = tr.model.getIRCoverageFromModel(model); - assert.equal(3, coverage.associatedEventsCount); - assert.equal(1, coverage.unassociatedEventsCount); - assert.closeTo(0.75, coverage.coveredEventsCountRatio, 1e-3); - assert.closeTo(0.0, coverage.associatedEventsCpuTimeMs, 1e-3); - assert.closeTo(0.0, coverage.unassociatedEventsCpuTimeMs, 1e-3); - assert.equal(undefined, coverage.coveredEventsCpuTimeRatio, 1e-3); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/kernel.html b/chromium/third_party/catapult/tracing/tracing/model/kernel.html deleted file mode 100644 index bf8aed5916e..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/kernel.html +++ /dev/null @@ -1,134 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/model/cpu.html"> -<link rel="import" href="/tracing/model/process_base.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the Process class. - */ -tr.exportTo('tr.model', function() { - var Cpu = tr.model.Cpu; - var ProcessBase = tr.model.ProcessBase; - - /** - * The Kernel represents kernel-level objects in the model. - * @constructor - */ - function Kernel(model) { - ProcessBase.call(this, model); - - this.cpus = {}; - this.softwareMeasuredCpuCount_ = undefined; - }; - - /** - * Comparison between kernels is pretty meaningless. - */ - Kernel.compare = function(x, y) { - return 0; - }; - - Kernel.prototype = { - __proto__: ProcessBase.prototype, - - compareTo: function(that) { - return Kernel.compare(this, that); - }, - - get userFriendlyName() { - return 'Kernel'; - }, - - get userFriendlyDetails() { - return 'Kernel'; - }, - - get stableId() { - return 'Kernel'; - }, - - /** - * @return {Cpu} Gets a specific Cpu or creates one if - * it does not exist. - */ - getOrCreateCpu: function(cpuNumber) { - if (!this.cpus[cpuNumber]) - this.cpus[cpuNumber] = new Cpu(this, cpuNumber); - return this.cpus[cpuNumber]; - }, - - get softwareMeasuredCpuCount() { - return this.softwareMeasuredCpuCount_; - }, - - set softwareMeasuredCpuCount(softwareMeasuredCpuCount) { - if (this.softwareMeasuredCpuCount_ !== undefined && - this.softwareMeasuredCpuCount_ !== softwareMeasuredCpuCount) { - throw new Error( - 'Cannot change the softwareMeasuredCpuCount once it is set'); - } - - this.softwareMeasuredCpuCount_ = softwareMeasuredCpuCount; - }, - - /** - * Estimates how many cpus are in the system, for use in system load - * estimation. - * - * If kernel trace was provided, uses that data. Otherwise, uses the - * software measured cpu count. - */ - get bestGuessAtCpuCount() { - var realCpuCount = tr.b.dictionaryLength(this.cpus); - if (realCpuCount !== 0) - return realCpuCount; - return this.softwareMeasuredCpuCount; - }, - - updateBounds: function() { - ProcessBase.prototype.updateBounds.call(this); - for (var cpuNumber in this.cpus) { - var cpu = this.cpus[cpuNumber]; - cpu.updateBounds(); - this.bounds.addRange(cpu.bounds); - } - }, - - createSubSlices: function() { - ProcessBase.prototype.createSubSlices.call(this); - for (var cpuNumber in this.cpus) { - var cpu = this.cpus[cpuNumber]; - cpu.createSubSlices(); - } - }, - - addCategoriesToDict: function(categoriesDict) { - ProcessBase.prototype.addCategoriesToDict.call(this, categoriesDict); - for (var cpuNumber in this.cpus) - this.cpus[cpuNumber].addCategoriesToDict(categoriesDict); - }, - - getSettingsKey: function() { - return 'kernel'; - }, - - childEventContainers: function*() { - yield * ProcessBase.prototype.childEventContainers.call(this); - yield * tr.b.dictionaryValues(this.cpus); - }, - }; - - return { - Kernel: Kernel - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/kernel_test.html b/chromium/third_party/catapult/tracing/tracing/model/kernel_test.html deleted file mode 100644 index c4ca0ca8e72..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/kernel_test.html +++ /dev/null @@ -1,73 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/kernel.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - function newModel(events, callback) { - return tr.c.TestUtils.newModelWithEvents([events], { - shiftWorldToZero: false, - pruneContainers: false, - customizeModelCallback: callback - }); - } - - test('bestGuessAtCpuCountWithNoData', function() { - var m = newModel([]); - assert.isUndefined(m.kernel.bestGuessAtCpuCount); - }); - - test('bestGuessAtCpuCountWithCpuData', function() { - var m = newModel([], function(m) { - var c1 = m.kernel.getOrCreateCpu(1); - var c2 = m.kernel.getOrCreateCpu(2); - }); - assert.equal(m.kernel.bestGuessAtCpuCount, 2); - }); - - test('bestGuessAtCpuCountWithSoftwareCpuCount', function() { - var m = newModel([], function(m) { - m.kernel.softwareMeasuredCpuCount = 2; - }); - assert.equal(m.kernel.bestGuessAtCpuCount, 2); - }); - - test('kernelStableId', function() { - var model = newModel([]); - assert.equal(model.kernel.stableId, 'Kernel'); - }); - - test('kernelTimeShifting', function() { - var m = newModel([]); - var ctr1 = m.kernel.getOrCreateCounter('cat', 'ctr1'); - var series1 = new tr.model.CounterSeries('a', 0); - series1.addCounterSample(100, 5); - series1.addCounterSample(200, 5); - ctr1.addSeries(series1); - - var ctr2 = m.kernel.getOrCreateCpu(1).getOrCreateCounter('cat', 'ctr2'); - var series2 = new tr.model.CounterSeries('b', 0); - series2.addCounterSample(300, 5); - series2.addCounterSample(400, 5); - ctr2.addSeries(series2); - - m.kernel.shiftTimestampsForward(2); - - assert.equal(ctr1.series[0].samples[0].timestamp, 102); - assert.equal(ctr1.series[0].samples[1].timestamp, 202); - - assert.equal(ctr2.series[0].samples[0].timestamp, 302); - assert.equal(ctr2.series[0].samples[1].timestamp, 402); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/location.html b/chromium/third_party/catapult/tracing/tracing/model/location.html deleted file mode 100644 index 11d31eef7e4..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/location.html +++ /dev/null @@ -1,162 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - /** - * YComponent is a class that handles storing the stableId and the percentage - * offset in the y direction of all tracks within a specific viewX and viewY - * coordinate. - * @constructor - */ - function YComponent(stableId, yPercentOffset) { - this.stableId = stableId; - this.yPercentOffset = yPercentOffset; - } - - YComponent.prototype = { - toDict: function() { - return { - stableId: this.stableId, - yPercentOffset: this.yPercentOffset - }; - } - }; - - /** - * Location is a class that represents a spatial location on the timeline - * that is specified by percent offsets within tracks rather than specific - * points. - * - * @constructor - */ - function Location(xWorld, yComponents) { - this.xWorld_ = xWorld; - this.yComponents_ = yComponents; - }; - - /** - * Returns a new Location given by x and y coordinates with respect to - * the timeline's drawing canvas. - */ - Location.fromViewCoordinates = function(viewport, viewX, viewY) { - var dt = viewport.currentDisplayTransform; - var xWorld = dt.xViewToWorld(viewX); - var yComponents = []; - - // Since we're given coordinates within the timeline canvas, we need to - // convert them to document coordinates to get the element. - var elem = document.elementFromPoint( - viewX + viewport.modelTrackContainer.canvas.offsetLeft, - viewY + viewport.modelTrackContainer.canvas.offsetTop); - // Build yComponents by calculating percentage offset with respect to - // each parent track. - while (elem instanceof tr.ui.tracks.Track) { - if (elem.eventContainer) { - var boundRect = elem.getBoundingClientRect(); - var yPercentOffset = (viewY - boundRect.top) / boundRect.height; - yComponents.push( - new YComponent(elem.eventContainer.stableId, yPercentOffset)); - } - elem = elem.parentElement; - } - - if (yComponents.length == 0) - return; - return new Location(xWorld, yComponents); - } - - Location.fromStableIdAndTimestamp = function(viewport, stableId, ts) { - var xWorld = ts; - var yComponents = []; - - // The y components' percentage offsets will be calculated with respect to - // the boundingRect's top of containing track. - var containerToTrack = viewport.containerToTrackMap; - var elem = containerToTrack.getTrackByStableId(stableId); - if (!elem) - return; - - var firstY = elem.getBoundingClientRect().top; - while (elem instanceof tr.ui.tracks.Track) { - if (elem.eventContainer) { - var boundRect = elem.getBoundingClientRect(); - var yPercentOffset = (firstY - boundRect.top) / boundRect.height; - yComponents.push( - new YComponent(elem.eventContainer.stableId, yPercentOffset)); - } - elem = elem.parentElement; - } - - if (yComponents.length == 0) - return; - return new Location(xWorld, yComponents); - } - - Location.prototype = { - - get xWorld() { - return this.xWorld_; - }, - - /** - * Returns the first valid containing track based on the - * internal yComponents. - */ - getContainingTrack: function(viewport) { - var containerToTrack = viewport.containerToTrackMap; - for (var i in this.yComponents_) { - var yComponent = this.yComponents_[i]; - var track = containerToTrack.getTrackByStableId(yComponent.stableId); - if (track !== undefined) - return track; - } - }, - - /** - * Calculates and returns x and y coordinates of the current location with - * respect to the timeline's canvas. - */ - toViewCoordinates: function(viewport) { - var dt = viewport.currentDisplayTransform; - var containerToTrack = viewport.containerToTrackMap; - var viewX = dt.xWorldToView(this.xWorld_); - - var viewY = -1; - for (var index in this.yComponents_) { - var yComponent = this.yComponents_[index]; - var track = containerToTrack.getTrackByStableId(yComponent.stableId); - if (track !== undefined) { - var boundRect = track.getBoundingClientRect(); - viewY = yComponent.yPercentOffset * boundRect.height + boundRect.top; - break; - } - } - - return { - viewX: viewX, - viewY: viewY - }; - }, - - toDict: function() { - return { - xWorld: this.xWorld_, - yComponents: this.yComponents_ - }; - } - }; - - return { - Location: Location - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/memory_allocator_dump.html b/chromium/third_party/catapult/tracing/tracing/model/memory_allocator_dump.html deleted file mode 100644 index 5e83a75e362..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/memory_allocator_dump.html +++ /dev/null @@ -1,221 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/value/numeric.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the MemoryAllocatorDump class. - */ -tr.exportTo('tr.model', function() { - /** - * @constructor - */ - function MemoryAllocatorDump(containerMemoryDump, fullName, opt_guid) { - this.fullName = fullName; - this.parent = undefined; - this.children = []; - - // String -> ScalarNumeric. - this.numerics = {}; - - // String -> string. - this.diagnostics = {}; - - // The associated container memory dump. - this.containerMemoryDump = containerMemoryDump; - - // Ownership relationship between memory allocator dumps. - this.owns = undefined; - this.ownedBy = []; - - // Map from sibling dumps (other children of this dump's parent) to the - // proportion of this dump's size which they (or their descendants) own. - this.ownedBySiblingSizes = new Map(); - - // Retention relationship between memory allocator dumps. - this.retains = []; - this.retainedBy = []; - - // Weak memory allocator dumps are removed from the model after import in - // tr.model.GlobalMemoryDump.removeWeakDumps(). See - // base::trace_event::MemoryAllocatorDump::Flags::WEAK in the Chromium - // codebase. - this.weak = false; - - // A list of information about the memory allocator dump (e.g. about how - // its fields were calculated). Each item should be an object with - // a mandatory 'type' property and type-specific extra arguments (see - // MemoryAllocatorDumpInfoType). - this.infos = []; - - // For debugging purposes. - this.guid = opt_guid; - }; - - /** - * Size numeric names. Please refer to the Memory Dump Graph Metric - * Calculation design document for more details (https://goo.gl/fKg0dt). - */ - MemoryAllocatorDump.SIZE_NUMERIC_NAME = 'size'; - MemoryAllocatorDump.EFFECTIVE_SIZE_NUMERIC_NAME = 'effective_size'; - MemoryAllocatorDump.RESIDENT_SIZE_NUMERIC_NAME = 'resident_size'; - MemoryAllocatorDump.DISPLAYED_SIZE_NUMERIC_NAME = - MemoryAllocatorDump.EFFECTIVE_SIZE_NUMERIC_NAME; - - MemoryAllocatorDump.prototype = { - get name() { - return this.fullName.substring(this.fullName.lastIndexOf('/') + 1); - }, - - get quantifiedName() { - return '\'' + this.fullName + '\' in ' + - this.containerMemoryDump.containerName; - }, - - getDescendantDumpByFullName: function(fullName) { - return this.containerMemoryDump.getMemoryAllocatorDumpByFullName( - this.fullName + '/' + fullName); - }, - - isDescendantOf: function(otherDump) { - var dump = this; - while (dump !== undefined) { - if (dump === otherDump) - return true; - dump = dump.parent; - } - return false; - }, - - addNumeric: function(name, numeric) { - if (!(numeric instanceof tr.v.ScalarNumeric)) - throw new Error('Numeric value must be an instance of ScalarNumeric.'); - if (name in this.numerics) - throw new Error('Duplicate numeric name: ' + name + '.'); - this.numerics[name] = numeric; - }, - - addDiagnostic: function(name, text) { - if (typeof text !== 'string') - throw new Error('Diagnostic text must be a string.'); - if (name in this.diagnostics) - throw new Error('Duplicate diagnostic name: ' + name + '.'); - this.diagnostics[name] = text; - }, - - aggregateNumericsRecursively: function(opt_model) { - var numericNames = new Set(); - - // Aggregate descendants's numerics recursively and gather children's - // numeric names. - this.children.forEach(function(child) { - child.aggregateNumericsRecursively(opt_model); - tr.b.iterItems(child.numerics, numericNames.add, numericNames); - }, this); - - // Aggregate children's numerics. - numericNames.forEach(function(numericName) { - if (numericName === MemoryAllocatorDump.SIZE_NUMERIC_NAME || - numericName === MemoryAllocatorDump.EFFECTIVE_SIZE_NUMERIC_NAME || - this.numerics[numericName] !== undefined) { - // Don't aggregate size and effective size numerics. These are - // calculated in GlobalMemoryDump.prototype.calculateSizes() and - // GlobalMemoryDump.prototype.calculateEffectiveSizes respectively. - // Also don't aggregate numerics that the parent already has. - return; - } - - this.numerics[numericName] = MemoryAllocatorDump.aggregateNumerics( - this.children.map(function(child) { - return child.numerics[numericName]; - }), opt_model); - }, this); - } - }; - - // TODO(petrcermak): Consider moving this to tr.v.Numeric. - MemoryAllocatorDump.aggregateNumerics = function(numerics, opt_model) { - var shouldLogWarning = !!opt_model; - var aggregatedUnit = undefined; - var aggregatedValue = 0; - - // Aggregate the units and sum up the values of the numerics. - numerics.forEach(function(numeric) { - if (numeric === undefined) - return; - - var unit = numeric.unit; - if (aggregatedUnit === undefined) { - aggregatedUnit = unit; - } else if (aggregatedUnit !== unit) { - if (shouldLogWarning) { - opt_model.importWarning({ - type: 'numeric_parse_error', - message: 'Multiple units provided for numeric: \'' + - aggregatedUnit.unitName + '\' and \'' + unit.unitName + '\'.' - }); - shouldLogWarning = false; // Don't log multiple warnings. - } - // Use the most generic unit when the numerics don't agree (best - // effort). - aggregatedUnit = tr.v.Unit.byName.unitlessNumber_smallerIsBetter; - } - - aggregatedValue += numeric.value; - }, this); - - if (aggregatedUnit === undefined) - return undefined; - - return new tr.v.ScalarNumeric(aggregatedUnit, aggregatedValue); - }; - - /** - * @constructor - */ - function MemoryAllocatorDumpLink(source, target, opt_importance) { - this.source = source; - this.target = target; - this.importance = opt_importance; - this.size = undefined; - } - - /** - * Types of size numeric information. - * - * @enum - */ - var MemoryAllocatorDumpInfoType = { - // The provided size of a MemoryAllocatorDump was less than the aggregated - // size of its children. - // - // Mandatory extra args: - // * providedSize: The inconsistent provided size. - // * dependencySize: The aggregated size of the children. - PROVIDED_SIZE_LESS_THAN_AGGREGATED_CHILDREN: 0, - - // The provided size of a MemoryAllocatorDump was less than the size of its - // largest owner. - // - // Mandatory extra args: - // * providedSize: The inconsistent provided size. - // * dependencySize: The size of the largest owner. - PROVIDED_SIZE_LESS_THAN_LARGEST_OWNER: 1 - }; - - return { - MemoryAllocatorDump: MemoryAllocatorDump, - MemoryAllocatorDumpLink: MemoryAllocatorDumpLink, - MemoryAllocatorDumpInfoType: MemoryAllocatorDumpInfoType - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/memory_allocator_dump_test.html b/chromium/third_party/catapult/tracing/tracing/model/memory_allocator_dump_test.html deleted file mode 100644 index 440dc5ffcd1..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/memory_allocator_dump_test.html +++ /dev/null @@ -1,218 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/container_memory_dump.html"> -<link rel="import" href="/tracing/model/memory_allocator_dump.html"> -<link rel="import" href="/tracing/model/memory_dump_test_utils.html"> -<link rel="import" href="/tracing/value/numeric.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var ContainerMemoryDump = tr.model.ContainerMemoryDump; - var MemoryAllocatorDump = tr.model.MemoryAllocatorDump; - var MemoryAllocatorDumpLink = tr.model.MemoryAllocatorDumpLink; - var ScalarNumeric = tr.v.ScalarNumeric; - var unitlessNumber_smallerIsBetter = - tr.v.Unit.byName.unitlessNumber_smallerIsBetter; - var sizeInBytes = tr.v.Unit.byName.sizeInBytes; - var powerInWatts = tr.v.Unit.byName.powerInWatts; - var newAllocatorDump = tr.model.MemoryDumpTestUtils.newAllocatorDump; - var addChildDump = tr.model.MemoryDumpTestUtils.addChildDump; - var checkDumpNumericsAndDiagnostics = - tr.model.MemoryDumpTestUtils.checkDumpNumericsAndDiagnostics; - - test('memoryAllocatorDump_instantiate', function() { - var containerDump = new ContainerMemoryDump(42); - containerDump.containerName = 'super dump'; - var dump = new MemoryAllocatorDump(containerDump, 'v8/objects/object7'); - - assert.equal(dump.name, 'object7'); - assert.equal(dump.fullName, 'v8/objects/object7'); - assert.strictEqual(dump.containerMemoryDump, containerDump); - assert.equal(dump.quantifiedName, '\'v8/objects/object7\' in super dump'); - }); - - test('memoryAllocatorDumps_aggregateNumericsRecursively', function() { - var md = new ContainerMemoryDump(42); - - var oilpanDump = newAllocatorDump(md, 'oilpan', { - 'objects_count': new ScalarNumeric(unitlessNumber_smallerIsBetter, 7) - }); - - addChildDump(oilpanDump, 'bucket1', { - size: 512, - objects_count: new ScalarNumeric(unitlessNumber_smallerIsBetter, 3), - inner_size: 256, - outer_size: 1024 - }); - - var oilpanBucket2Dump = addChildDump(oilpanDump, 'bucket2'); - - var oilpanBucket2StringsDump = addChildDump(oilpanBucket2Dump, 'strings', { - size: 512, - objects_count: new ScalarNumeric(unitlessNumber_smallerIsBetter, 4), - inner_size: 512, - outer_size: 2048 - }); - - oilpanDump.aggregateNumericsRecursively(); - - // oilpan has *some* numerics aggregated. - checkDumpNumericsAndDiagnostics(oilpanDump, { - 'objects_count': new ScalarNumeric(unitlessNumber_smallerIsBetter, 7), - 'inner_size': 768, - 'outer_size': 3072 - }, {}); - - // oilpan/bucket2 has *all* numerics aggregated (except for size). - checkDumpNumericsAndDiagnostics(oilpanBucket2Dump, { - 'objects_count': new ScalarNumeric(unitlessNumber_smallerIsBetter, 4), - 'inner_size': 512, - 'outer_size': 2048 - }, {}); - - // oilpan/bucket2/strings has *no* numerics aggregated. - checkDumpNumericsAndDiagnostics(oilpanBucket2StringsDump, { - 'size': 512, - 'objects_count': new ScalarNumeric(unitlessNumber_smallerIsBetter, 4), - 'inner_size': 512, - 'outer_size': 2048 - }, {}); - }); - - test('memoryAllocatorDump_aggregateNumerics', function() { - function checkAggregateNumerics(numerics, expectedValue, expectedUnit, - opt_expectedWarningCount) { - function checkResult(result) { - if (expectedValue === undefined) { - assert.isUndefined(result); - assert.isUndefined(expectedUnit); // Test sanity check. - } else { - assert.instanceOf(result, ScalarNumeric); - assert.strictEqual(result.value, expectedValue); - assert.strictEqual(result.unit, expectedUnit); - } - } - - // Without model parameter. - var result1 = MemoryAllocatorDump.aggregateNumerics(numerics); - checkResult(result1); - - // With model parameter. - var mockModel = { - warnings: [], - importWarning: function(warning) { - this.warnings.push(warning); - } - }; - var result2 = MemoryAllocatorDump.aggregateNumerics(numerics, mockModel); - checkResult(result2); - assert.lengthOf(mockModel.warnings, opt_expectedWarningCount || 0); - } - - // No defined numerics. - checkAggregateNumerics([], undefined); - checkAggregateNumerics([undefined], undefined); - checkAggregateNumerics([undefined, undefined], undefined); - - // Consistent units. - checkAggregateNumerics( - [new ScalarNumeric(unitlessNumber_smallerIsBetter, 10)], - 10, unitlessNumber_smallerIsBetter); - checkAggregateNumerics( - [new ScalarNumeric(sizeInBytes, 10), - new ScalarNumeric(sizeInBytes, 20), - new ScalarNumeric(sizeInBytes, 40)], - 70, sizeInBytes); - checkAggregateNumerics( - [undefined, - new ScalarNumeric(sizeInBytes, 16), - undefined, - new ScalarNumeric(sizeInBytes, 32), - undefined], - 48, sizeInBytes); - - // Inconsistent units. - checkAggregateNumerics( - [new ScalarNumeric(sizeInBytes, 10), - new ScalarNumeric(powerInWatts, 20)], - 30, unitlessNumber_smallerIsBetter, 1 /* opt_expectedWarningCount */); - checkAggregateNumerics( - [undefined, - new ScalarNumeric(powerInWatts, 16), - undefined, - new ScalarNumeric(unitlessNumber_smallerIsBetter, 32), - undefined, - new ScalarNumeric(sizeInBytes, 64), - undefined], - 112, unitlessNumber_smallerIsBetter, 1 /* opt_expectedWarningCount */); - }); - - test('memoryAllocatorDumps_isDescendantOf', function() { - var md = new ContainerMemoryDump(42); - - var v8Dump = new MemoryAllocatorDump(md, 'v8'); - var v8HeapsDump = addChildDump(v8Dump, 'heaps'); - var v8ObjectsDump = addChildDump(v8Dump, 'objects'); - var v8Object1Dump = addChildDump(v8ObjectsDump, 'obj1'); - var v8Object2Dump = addChildDump(v8ObjectsDump, 'obj2'); - - var oilpanDump = new MemoryAllocatorDump(md, 'oilpan'); - - assert.isTrue(v8Dump.isDescendantOf(v8Dump)); - assert.isTrue(v8HeapsDump.isDescendantOf(v8Dump)); - assert.isTrue(v8ObjectsDump.isDescendantOf(v8Dump)); - assert.isTrue(v8Object1Dump.isDescendantOf(v8Dump)); - assert.isTrue(v8Object2Dump.isDescendantOf(v8Dump)); - assert.isTrue(v8ObjectsDump.isDescendantOf(v8ObjectsDump)); - assert.isTrue(v8Object1Dump.isDescendantOf(v8ObjectsDump)); - assert.isTrue(v8Object2Dump.isDescendantOf(v8ObjectsDump)); - assert.isTrue(oilpanDump.isDescendantOf(oilpanDump)); - - assert.isFalse(v8Dump.isDescendantOf(oilpanDump)); - assert.isFalse(v8Dump.isDescendantOf(v8HeapsDump)); - assert.isFalse(v8Dump.isDescendantOf(v8ObjectsDump)); - assert.isFalse(v8Dump.isDescendantOf(v8Object1Dump)); - assert.isFalse(v8Dump.isDescendantOf(v8Object2Dump)); - assert.isFalse(v8Object1Dump.isDescendantOf(v8Object2Dump)); - assert.isFalse(v8Object2Dump.isDescendantOf(v8Object1Dump)); - }); - - test('memoryAllocatorDumps_getDescendantDumpByFullName', function() { - var containerDump = new ContainerMemoryDump(42); - - var gpuDump = new MemoryAllocatorDump(containerDump, 'gpu'); - containerDump.memoryAllocatorDumps = [gpuDump]; - - var memtrackDump = addChildDump(gpuDump, 'android_memtrack'); - var glDump = addChildDump(memtrackDump, 'gl'); - var gfxDump = addChildDump(memtrackDump, 'gfx'); - var tileDump = addChildDump(gfxDump, 'tile'); - - assert.strictEqual(gpuDump.getDescendantDumpByFullName( - 'android_memtrack'), memtrackDump); - assert.strictEqual(gpuDump.getDescendantDumpByFullName( - 'android_memtrack/gfx/tile'), tileDump); - assert.strictEqual(memtrackDump.getDescendantDumpByFullName('gl'), glDump); - assert.strictEqual(memtrackDump.getDescendantDumpByFullName( - 'gfx/tile'), tileDump); - }); - - test('memoryAllocatorDumpLink_instantiate', function() { - var d1 = new MemoryAllocatorDump('v8/isolate1'); - var d2 = new MemoryAllocatorDump('oilpan/document1'); - var link = new MemoryAllocatorDumpLink(d1, d2, 3); - - assert.strictEqual(link.source, d1); - assert.strictEqual(link.target, d2); - assert.strictEqual(link.importance, 3); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/memory_dump_test_utils.html b/chromium/third_party/catapult/tracing/tracing/model/memory_dump_test_utils.html deleted file mode 100644 index 55a499192bf..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/memory_dump_test_utils.html +++ /dev/null @@ -1,151 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/container_memory_dump.html"> -<link rel="import" href="/tracing/model/global_memory_dump.html"> -<link rel="import" href="/tracing/model/memory_allocator_dump.html"> -<link rel="import" href="/tracing/model/process_memory_dump.html"> -<link rel="import" href="/tracing/model/vm_region.html"> -<link rel="import" href="/tracing/value/numeric.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -/** - * @fileoverview Helper functions for tests involving memory dumps. - */ -tr.exportTo('tr.model', function() { - var GlobalMemoryDump = tr.model.GlobalMemoryDump; - var ProcessMemoryDump = tr.model.ProcessMemoryDump; - var MemoryAllocatorDump = tr.model.MemoryAllocatorDump; - var MemoryAllocatorDumpLink = tr.model.MemoryAllocatorDumpLink; - var VMRegion = tr.model.VMRegion; - var VMRegionClassificationNode = tr.model.VMRegionClassificationNode; - var ScalarNumeric = tr.v.ScalarNumeric; - var sizeInBytes_smallerIsBetter = - tr.v.Unit.byName.sizeInBytes_smallerIsBetter; - var LIGHT = tr.model.ContainerMemoryDump.LevelOfDetail.LIGHT; - - function castToScalarNumeric(value) { - if (typeof value === 'number') - return new ScalarNumeric(sizeInBytes_smallerIsBetter, value); - assert.instanceOf(value, ScalarNumeric); - return value; - } - - function MemoryDumpTestUtils() { - throw new Error('Static class'); - } - - MemoryDumpTestUtils.SIZE_DELTA = 0.0001; - - MemoryDumpTestUtils.addGlobalMemoryDump = function( - model, timestamp, opt_levelOfDetail) { - var gmd = new GlobalMemoryDump(model, timestamp); - gmd.levelOfDetail = opt_levelOfDetail === undefined ? - LIGHT : opt_levelOfDetail; - model.globalMemoryDumps.push(gmd); - return gmd; - }; - - MemoryDumpTestUtils.addProcessMemoryDump = function(gmd, process, timestamp) { - var pmd = new ProcessMemoryDump(gmd, process, timestamp); - process.memoryDumps.push(pmd); - if (process.pid in gmd.processMemoryDumps) { - // Test sanity check. - throw new Error('Process memory dump for process with pid=' + - process.pid + ' has already been provided'); - } - gmd.processMemoryDumps[process.pid] = pmd; - return pmd; - }; - - MemoryDumpTestUtils.newAllocatorDump = function( - containerDump, fullName, opt_numerics, opt_guid) { - var dump = new MemoryAllocatorDump(containerDump, fullName, opt_guid); - if (opt_numerics !== undefined) { - tr.b.iterItems(opt_numerics, function(numericName, value) { - dump.addNumeric(numericName, castToScalarNumeric(value)); - }); - } - return dump; - }; - - MemoryDumpTestUtils.addChildDump = - function(parentDump, name, opt_numerics, opt_guid) { - var childDump = MemoryDumpTestUtils.newAllocatorDump( - parentDump.containerMemoryDump, parentDump.fullName + '/' + name, - opt_numerics, opt_guid); - childDump.parent = parentDump; - parentDump.children.push(childDump); - return childDump; - }; - - MemoryDumpTestUtils.addOwnershipLink = function( - ownerDump, ownedDump, opt_importance) { - assert.isUndefined(ownerDump.owns); // Sanity check. - var ownershipLink = - new MemoryAllocatorDumpLink(ownerDump, ownedDump, opt_importance); - ownerDump.owns = ownershipLink; - ownedDump.ownedBy.push(ownershipLink); - return ownershipLink; - }; - - MemoryDumpTestUtils.checkDumpNumericsAndDiagnostics = - function(dump, expectedNumerics, expectedDiagnostics) { - var actualNumerics = dump.numerics; - assert.sameMembers( - Object.keys(actualNumerics), Object.keys(expectedNumerics)); - for (var numericName in actualNumerics) { - var actualNumeric = actualNumerics[numericName]; - var expectedNumeric = castToScalarNumeric(expectedNumerics[numericName]); - assert.instanceOf(actualNumeric, tr.v.ScalarNumeric); - assert.strictEqual(actualNumeric.unit, expectedNumeric.unit); - assert.closeTo(actualNumeric.value, expectedNumeric.value, - MemoryDumpTestUtils.SIZE_DELTA); - } - - assert.deepEqual(dump.diagnostics, expectedDiagnostics); - }; - - MemoryDumpTestUtils.checkVMRegions = function(vmRegions, expectedRegions) { - if (vmRegions instanceof VMRegionClassificationNode) - vmRegions = vmRegions.allRegionsForTesting; - - var expectedRegionsMap = new Map(); - expectedRegions.forEach(function(region) { - if (!(region instanceof VMRegion)) - region = VMRegion.fromDict(region); - expectedRegionsMap.set(region.uniqueIdWithinProcess, region); - }); - var actualRegionsMap = new Map(); - vmRegions.forEach(function(region) { - actualRegionsMap.set(region.uniqueIdWithinProcess, region); - }); - - assert.strictEqual(actualRegionsMap.size, expectedRegionsMap.size); - for (var id of expectedRegionsMap.keys()) { - var expectedRegion = expectedRegionsMap.get(id); - var actualRegion = actualRegionsMap.get(id); - - assert.instanceOf(actualRegion, VMRegion); - assert.strictEqual(actualRegion.startAddress, - expectedRegion.startAddress); - assert.strictEqual(actualRegion.sizeInBytes, expectedRegion.sizeInBytes); - assert.strictEqual(actualRegion.protectionFlags, - expectedRegion.protectionFlags); - assert.strictEqual(actualRegion.mappedFile, expectedRegion.mappedFile); - assert.deepEqual(actualRegion.byteStats, expectedRegion.byteStats); - } - }; - - return { - MemoryDumpTestUtils: MemoryDumpTestUtils - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/model.html b/chromium/third_party/catapult/tracing/tracing/model/model.html deleted file mode 100644 index b1164f7ebf7..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/model.html +++ /dev/null @@ -1,650 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2012 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> -<link rel="import" href="/tracing/base/event.html"> -<link rel="import" href="/tracing/base/interval_tree.html"> -<link rel="import" href="/tracing/base/quad.html"> -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/base/task.html"> -<link rel="import" href="/tracing/core/auditor.html"> -<link rel="import" href="/tracing/core/filter.html"> -<link rel="import" href="/tracing/model/alert.html"> -<link rel="import" href="/tracing/model/clock_sync_manager.html"> -<link rel="import" href="/tracing/model/constants.html"> -<link rel="import" href="/tracing/model/device.html"> -<link rel="import" href="/tracing/model/flow_event.html"> -<link rel="import" href="/tracing/model/frame.html"> -<link rel="import" href="/tracing/model/global_memory_dump.html"> -<link rel="import" href="/tracing/model/instant_event.html"> -<link rel="import" href="/tracing/model/kernel.html"> -<link rel="import" href="/tracing/model/model_indices.html"> -<link rel="import" href="/tracing/model/model_stats.html"> -<link rel="import" href="/tracing/model/object_snapshot.html"> -<link rel="import" href="/tracing/model/process.html"> -<link rel="import" href="/tracing/model/process_memory_dump.html"> -<link rel="import" href="/tracing/model/sample.html"> -<link rel="import" href="/tracing/model/stack_frame.html"> -<link rel="import" href="/tracing/model/user_model/user_expectation.html"> -<link rel="import" href="/tracing/model/user_model/user_model.html"> -<link rel="import" href="/tracing/ui/base/overlay.html"> -<link rel="import" href="/tracing/value/time_display_mode.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -/** - * @fileoverview Model is a parsed representation of the - * TraceEvents obtained from base/trace_event in which the begin-end - * tokens are converted into a hierarchy of processes, threads, - * subrows, and slices. - * - * The building block of the model is a slice. A slice is roughly - * equivalent to function call executing on a specific thread. As a - * result, slices may have one or more subslices. - * - * A thread contains one or more subrows of slices. Row 0 corresponds to - * the "root" slices, e.g. the topmost slices. Row 1 contains slices that - * are nested 1 deep in the stack, and so on. We use these subrows to draw - * nesting tasks. - * - */ -tr.exportTo('tr', function() { - var Process = tr.model.Process; - var Device = tr.model.Device; - var Kernel = tr.model.Kernel; - var GlobalMemoryDump = tr.model.GlobalMemoryDump; - var GlobalInstantEvent = tr.model.GlobalInstantEvent; - var FlowEvent = tr.model.FlowEvent; - var Alert = tr.model.Alert; - var Sample = tr.model.Sample; - - /** - * @constructor - */ - function Model() { - tr.model.EventContainer.call(this); - tr.b.EventTarget.decorate(this); - - this.timestampShiftToZeroAmount_ = 0; - - this.faviconHue = 'blue'; // Should be a key from favicons.html - - this.device = new Device(this); - this.kernel = new Kernel(this); - this.processes = {}; - this.metadata = []; - this.categories = []; - this.instantEvents = []; - this.flowEvents = []; - this.clockSyncManager = new tr.model.ClockSyncManager(); - this.intrinsicTimeUnit_ = undefined; - - this.stackFrames = {}; - this.samples = []; - - this.alerts = []; - this.userModel = new tr.model.um.UserModel(this); - - this.flowIntervalTree = new tr.b.IntervalTree((f) => f.start, (f) => f.end); - this.globalMemoryDumps = []; - - this.userFriendlyCategoryDrivers_ = []; - - this.annotationsByGuid_ = {}; - this.modelIndices = undefined; - - this.stats = new tr.model.ModelStats(); - - this.importWarnings_ = []; - this.reportedImportWarnings_ = {}; - - this.isTimeHighResolution_ = true; - - this.patchupsToApply_ = []; - - this.doesHelperGUIDSupportThisModel_ = {}; - this.helpersByConstructorGUID_ = {}; - this.eventsByStableId_ = undefined; - } - - Model.prototype = { - __proto__: tr.model.EventContainer.prototype, - - getEventByStableId: function(stableId) { - if (this.eventsByStableId_ === undefined) { - this.eventsByStableId_ = {}; - for (var event of this.getDescendantEvents()) { - this.eventsByStableId_[event.stableId] = event; - } - } - return this.eventsByStableId_[stableId]; - }, - - getOrCreateHelper: function(constructor) { - if (!constructor.guid) - throw new Error('Helper constructors must have GUIDs'); - - if (this.helpersByConstructorGUID_[constructor.guid] === undefined) { - if (this.doesHelperGUIDSupportThisModel_[constructor.guid] === - undefined) { - this.doesHelperGUIDSupportThisModel_[constructor.guid] = - constructor.supportsModel(this); - } - - if (!this.doesHelperGUIDSupportThisModel_[constructor.guid]) - return undefined; - - this.helpersByConstructorGUID_[constructor.guid] = new constructor( - this); - } - return this.helpersByConstructorGUID_[constructor.guid]; - }, - - childEvents: function*() { - yield * this.globalMemoryDumps; - yield * this.instantEvents; - yield * this.flowEvents; - yield * this.alerts; - yield * this.samples; - }, - - childEventContainers: function*() { - yield this.userModel; - yield this.device; - yield this.kernel; - yield * tr.b.dictionaryValues(this.processes); - }, - - /** - * Some objects in the model can persist their state in ModelSettings. - * - * This iterates through them. - */ - iterateAllPersistableObjects: function(callback) { - this.kernel.iterateAllPersistableObjects(callback); - for (var pid in this.processes) - this.processes[pid].iterateAllPersistableObjects(callback); - }, - - updateBounds: function() { - this.bounds.reset(); - var bounds = this.bounds; - for (var ec of this.childEventContainers()) { - ec.updateBounds(); - bounds.addRange(ec.bounds); - } - for (var event of this.childEvents()) - event.addBoundsToRange(bounds); - }, - - shiftWorldToZero: function() { - var shiftAmount = -this.bounds.min; - this.timestampShiftToZeroAmount_ = shiftAmount; - for (var ec of this.childEventContainers()) - ec.shiftTimestampsForward(shiftAmount); - - for (var event of this.childEvents()) - event.start += shiftAmount; - this.updateBounds(); - }, - - convertTimestampToModelTime: function(sourceClockDomainName, ts) { - if (sourceClockDomainName !== 'traceEventClock') - throw new Error('Only traceEventClock is supported.'); - return tr.v.Unit.timestampFromUs(ts) + - this.timestampShiftToZeroAmount_; - }, - - get numProcesses() { - var n = 0; - for (var p in this.processes) - n++; - return n; - }, - - /** - * @return {Process} Gets a TimelineProcess for a specified pid. Returns - * undefined if the process doesn't exist. - */ - getProcess: function(pid) { - return this.processes[pid]; - }, - - /** - * @return {Process} Gets a TimelineProcess for a specified pid or - * creates one if it does not exist. - */ - getOrCreateProcess: function(pid) { - if (!this.processes[pid]) - this.processes[pid] = new Process(this, pid); - return this.processes[pid]; - }, - - addStackFrame: function(stackFrame) { - if (this.stackFrames[stackFrame.id]) - throw new Error('Stack frame already exists'); - this.stackFrames[stackFrame.id] = stackFrame; - return stackFrame; - }, - - /** - * Generates the set of categories from the slices and counters. - */ - updateCategories_: function() { - var categoriesDict = {}; - this.userModel.addCategoriesToDict(categoriesDict); - this.device.addCategoriesToDict(categoriesDict); - this.kernel.addCategoriesToDict(categoriesDict); - for (var pid in this.processes) - this.processes[pid].addCategoriesToDict(categoriesDict); - - this.categories = []; - for (var category in categoriesDict) - if (category != '') - this.categories.push(category); - }, - - getAllThreads: function() { - var threads = []; - for (var tid in this.kernel.threads) { - threads.push(process.threads[tid]); - } - for (var pid in this.processes) { - var process = this.processes[pid]; - for (var tid in process.threads) { - threads.push(process.threads[tid]); - } - } - return threads; - }, - - /** - * @param {(!function(!tr.model.Process): boolean)=} opt_predicate Optional - * predicate for filtering the returned processes. If undefined, all - * process in the model will be returned. - * @return {!Array<!tr.model.Process>} An array of processes in the model. - */ - getAllProcesses: function(opt_predicate) { - var processes = []; - for (var pid in this.processes) { - var process = this.processes[pid]; - if (opt_predicate === undefined || opt_predicate(process)) - processes.push(process); - } - return processes; - }, - - /** - * @return {Array} An array of all the counters in the model. - */ - getAllCounters: function() { - var counters = []; - counters.push.apply( - counters, tr.b.dictionaryValues(this.device.counters)); - counters.push.apply( - counters, tr.b.dictionaryValues(this.kernel.counters)); - for (var pid in this.processes) { - var process = this.processes[pid]; - for (var tid in process.counters) { - counters.push(process.counters[tid]); - } - } - return counters; - }, - - getAnnotationByGUID: function(guid) { - return this.annotationsByGuid_[guid]; - }, - - addAnnotation: function(annotation) { - if (!annotation.guid) - throw new Error('Annotation with undefined guid given'); - - this.annotationsByGuid_[annotation.guid] = annotation; - tr.b.dispatchSimpleEvent(this, 'annotationChange'); - }, - - removeAnnotation: function(annotation) { - this.annotationsByGuid_[annotation.guid].onRemove(); - delete this.annotationsByGuid_[annotation.guid]; - tr.b.dispatchSimpleEvent(this, 'annotationChange'); - }, - - getAllAnnotations: function() { - return tr.b.dictionaryValues(this.annotationsByGuid_); - }, - - addUserFriendlyCategoryDriver: function(ufcd) { - this.userFriendlyCategoryDrivers_.push(ufcd); - }, - - /** - * Gets the user friendly category string from an event. - * - * Returns undefined if none is known. - */ - getUserFriendlyCategoryFromEvent: function(event) { - for (var i = 0; i < this.userFriendlyCategoryDrivers_.length; i++) { - var ufc = this.userFriendlyCategoryDrivers_[i].fromEvent(event); - if (ufc !== undefined) - return ufc; - } - return undefined; - }, - - /** - * @param {String} The name of the thread to find. - * @return {Array} An array of all the matched threads. - */ - findAllThreadsNamed: function(name) { - var namedThreads = []; - namedThreads.push.apply( - namedThreads, - this.kernel.findAllThreadsNamed(name)); - for (var pid in this.processes) { - namedThreads.push.apply( - namedThreads, - this.processes[pid].findAllThreadsNamed(name)); - } - return namedThreads; - }, - - get importOptions() { - return this.importOptions_; - }, - - set importOptions(options) { - this.importOptions_ = options; - }, - - /** - * Returns a time unit that is used to format values and determines the - * precision of the timestamp values. - */ - get intrinsicTimeUnit() { - if (this.intrinsicTimeUnit_ === undefined) - return tr.v.TimeDisplayModes.ms; - return this.intrinsicTimeUnit_; - }, - - set intrinsicTimeUnit(value) { - if (this.intrinsicTimeUnit_ === value) - return; - if (this.intrinsicTimeUnit_ !== undefined) - throw new Error('Intrinsic time unit already set'); - this.intrinsicTimeUnit_ = value; - }, - - get isTimeHighResolution() { - return this.isTimeHighResolution_; - }, - - set isTimeHighResolution(value) { - this.isTimeHighResolution_ = value; - }, - - /** - * Returns a link to a trace data file that this model was imported from. - * This is NOT the URL of a site being traced, but instead an indicator of - * where the data is stored. - */ - get canonicalUrl() { - return this.canonicalUrl_; - }, - - set canonicalUrl(value) { - if (this.canonicalUrl_ === value) - return; - if (this.canonicalUrl_ !== undefined) - throw new Error('canonicalUrl already set'); - this.canonicalUrl_ = value; - }, - - /** - * Saves a warning that happened during import. - * - * Warnings are typically logged to the console, and optionally, the - * more critical ones are shown to the user. - * - * @param {Object} data The import warning data. Data must provide two - * accessors: type, message. The types are used to determine if we - * should output the message, we'll only output one message of each type. - * The message is the actual warning content. - */ - importWarning: function(data) { - data.showToUser = !!data.showToUser; - - this.importWarnings_.push(data); - - // Only log each warning type once. We may want to add some kind of - // flag to allow reporting all importer warnings. - if (this.reportedImportWarnings_[data.type] === true) - return; - - if (this.importOptions_.showImportWarnings) - console.warn(data.message); - - this.reportedImportWarnings_[data.type] = true; - }, - - get hasImportWarnings() { - return (this.importWarnings_.length > 0); - }, - - get importWarnings() { - return this.importWarnings_; - }, - - get importWarningsThatShouldBeShownToUser() { - return this.importWarnings_.filter(function(warning) { - return warning.showToUser; - }); - }, - - autoCloseOpenSlices: function() { - // Sort the samples. - this.samples.sort(function(x, y) { - return x.start - y.start; - }); - - this.updateBounds(); - this.kernel.autoCloseOpenSlices(); - for (var pid in this.processes) - this.processes[pid].autoCloseOpenSlices(); - }, - - createSubSlices: function() { - this.kernel.createSubSlices(); - for (var pid in this.processes) - this.processes[pid].createSubSlices(); - }, - - preInitializeObjects: function() { - for (var pid in this.processes) - this.processes[pid].preInitializeObjects(); - }, - - initializeObjects: function() { - for (var pid in this.processes) - this.processes[pid].initializeObjects(); - }, - - pruneEmptyContainers: function() { - this.kernel.pruneEmptyContainers(); - for (var pid in this.processes) - this.processes[pid].pruneEmptyContainers(); - }, - - mergeKernelWithUserland: function() { - for (var pid in this.processes) - this.processes[pid].mergeKernelWithUserland(); - }, - - computeWorldBounds: function(shiftWorldToZero) { - this.updateBounds(); - this.updateCategories_(); - - if (shiftWorldToZero) - this.shiftWorldToZero(); - }, - - buildFlowEventIntervalTree: function() { - for (var i = 0; i < this.flowEvents.length; ++i) { - var flowEvent = this.flowEvents[i]; - this.flowIntervalTree.insert(flowEvent); - } - this.flowIntervalTree.updateHighValues(); - }, - - cleanupUndeletedObjects: function() { - for (var pid in this.processes) - this.processes[pid].autoDeleteObjects(this.bounds.max); - }, - - sortMemoryDumps: function() { - this.globalMemoryDumps.sort(function(x, y) { - return x.start - y.start; - }); - - for (var pid in this.processes) - this.processes[pid].sortMemoryDumps(); - }, - - finalizeMemoryGraphs: function() { - this.globalMemoryDumps.forEach(function(dump) { - dump.finalizeGraph(); - }); - }, - - buildEventIndices: function() { - this.modelIndices = new tr.model.ModelIndices(this); - }, - - sortAlerts: function() { - this.alerts.sort(function(x, y) { - return x.start - y.start; - }); - }, - - applyObjectRefPatchups: function() { - // Change all the fields pointing at id_refs to their real values. - var unresolved = []; - this.patchupsToApply_.forEach(function(patchup) { - if (patchup.pidRef in this.processes) { - var snapshot = this.processes[patchup.pidRef].objects.getSnapshotAt( - patchup.scopedId, patchup.ts); - if (snapshot) { - patchup.object[patchup.field] = snapshot; - snapshot.referencedAt(patchup.item, patchup.object, patchup.field); - return; - } - } - unresolved.push(patchup); - }, this); - this.patchupsToApply_ = unresolved; - }, - - replacePIDRefsInPatchups: function(old_pid_ref, new_pid_ref) { - this.patchupsToApply_.forEach(function(patchup) { - if (patchup.pidRef === old_pid_ref) - patchup.pidRef = new_pid_ref; - }); - }, - - /** - * Called by the model to join references between objects, after final model - * bounds have been computed. - */ - joinRefs: function() { - this.joinObjectRefs_(); - this.applyObjectRefPatchups(); - }, - - joinObjectRefs_: function() { - tr.b.iterItems(this.processes, function(pid, process) { - this.joinObjectRefsForProcess_(pid, process); - }, this); - }, - - joinObjectRefsForProcess_: function(pid, process) { - // Iterate the world, looking for id_refs - tr.b.iterItems(process.threads, function(tid, thread) { - thread.asyncSliceGroup.slices.forEach(function(item) { - this.searchItemForIDRefs_(pid, 'start', item); - }, this); - thread.sliceGroup.slices.forEach(function(item) { - this.searchItemForIDRefs_(pid, 'start', item); - }, this); - }, this); - process.objects.iterObjectInstances(function(instance) { - instance.snapshots.forEach(function(item) { - this.searchItemForIDRefs_(pid, 'ts', item); - }, this); - }, this); - }, - - searchItemForIDRefs_: function(pid, itemTimestampField, item) { - if (!item.args && !item.contexts) - return; - var patchupsToApply = this.patchupsToApply_; - - function handleField(object, fieldName, fieldValue) { - if (!fieldValue || (!fieldValue.id_ref && !fieldValue.idRef)) - return; - - var scope = fieldValue.scope || tr.model.OBJECT_DEFAULT_SCOPE; - var idRef = fieldValue.id_ref || fieldValue.idRef; - var scopedId = new tr.model.ScopedId(scope, idRef); - var pidRef = fieldValue.pid_ref || fieldValue.pidRef || pid; - var ts = item[itemTimestampField]; - // We have to delay the actual change to the new value until after all - // refs have been located. Otherwise, we could end up recursing in - // ways we definitely didn't intend. - patchupsToApply.push({ - item: item, - object: object, - field: fieldName, - pidRef: pidRef, - scopedId: scopedId, - ts: ts}); - } - function iterObjectFieldsRecursively(object) { - if (!(object instanceof Object)) - return; - - if ((object instanceof tr.model.ObjectSnapshot) || - (object instanceof Float32Array) || - (object instanceof tr.b.Quad)) - return; - - if (object instanceof Array) { - for (var i = 0; i < object.length; i++) { - handleField(object, i, object[i]); - iterObjectFieldsRecursively(object[i]); - } - return; - } - - for (var key in object) { - var value = object[key]; - handleField(object, key, value); - iterObjectFieldsRecursively(value); - } - } - - iterObjectFieldsRecursively(item.args); - iterObjectFieldsRecursively(item.contexts); - } - }; - - return { - Model: Model - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/model_indices.html b/chromium/third_party/catapult/tracing/tracing/model/model_indices.html deleted file mode 100644 index 5a132f8fecf..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/model_indices.html +++ /dev/null @@ -1,55 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the Event Index class. - */ -tr.exportTo('tr.model', function() { - /** - * A Event Index maps an id to all the events that have that particular id - * - * @constructor - */ - function ModelIndices(model) { - // For now the only indices we construct are for flowEvents - this.flowEventsById_ = {}; - model.flowEvents.forEach(function(fe) { - if (fe.id !== undefined) { - if (!this.flowEventsById_.hasOwnProperty(fe.id)) { - this.flowEventsById_[fe.id] = new Array(); - } - this.flowEventsById_[fe.id].push(fe); - } - }, this); - } - - ModelIndices.prototype = { - addEventWithId: function(id, event) { - if (!this.flowEventsById_.hasOwnProperty(id)) { - this.flowEventsById_[id] = new Array(); - } - this.flowEventsById_[id].push(event); - }, - - getFlowEventsWithId: function(id) { - if (!this.flowEventsById_.hasOwnProperty(id)) - return []; - return this.flowEventsById_[id]; - } - }; - - return { - ModelIndices: ModelIndices - }; -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/model_indices_test.html b/chromium/third_party/catapult/tracing/tracing/model/model_indices_test.html deleted file mode 100644 index 750e0b02390..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/model_indices_test.html +++ /dev/null @@ -1,45 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/model.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var newFlowEventEx = tr.c.TestUtils.newFlowEventEx; - var newModel = tr.c.TestUtils.newModel; - - test('getCorrectModelIndices', function() { - var m = newModel(function(m) { - m.f1 = newFlowEventEx({ - 'title': 'test1', - start: 0, - end: 10, - id: '0x100' - }); - - m.f2 = newFlowEventEx({ - 'title': 'test2', - start: 0, - end: 10, - id: '0x100' - }); - - m.flowEvents.push(m.f1); - m.flowEvents.push(m.f2); - }); - - assert.isDefined(m.modelIndices); - var modelIndices = m.modelIndices; - assert.equal(modelIndices.getFlowEventsWithId('0x100').length, 2); - assert.equal(modelIndices.getFlowEventsWithId('0x100')[0].id, '0x100'); - assert.equal(modelIndices.getFlowEventsWithId('0x101').length, 0); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/model_settings.html b/chromium/third_party/catapult/tracing/tracing/model/model_settings.html deleted file mode 100644 index fbe69d60b66..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/model_settings.html +++ /dev/null @@ -1,140 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/settings.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - var Settings = tr.b.Settings; - - /** - * A way to persist settings specific to parts of a trace model. - * - * This object should not be persisted because it builds up internal data - * structures that map model objects to settings keys. It should thus be - * created for the duration of whatever interaction(s) you're going to do with - * model settings, and then discarded. - * - * This system works on a notion of an object key: for an object's key, it - * considers all the other keys in the model. If it is unique, then the key is - * persisted to tr.b.Settings. However, if it is not unique, then the - * setting is stored on the object itself. Thus, objects with unique keys will - * be persisted across page reloads, whereas objects with nonunique keys will - * not. - */ - function ModelSettings(model) { - this.model = model; - this.objectsByKey_ = []; - this.nonuniqueKeys_ = []; - this.buildObjectsByKeyMap_(); - this.removeNonuniqueKeysFromSettings_(); - this.ephemeralSettingsByGUID_ = {}; - } - - ModelSettings.prototype = { - buildObjectsByKeyMap_: function() { - var objects = []; - this.model.iterateAllPersistableObjects(function(o) { - objects.push(o); - }); - - var objectsByKey = {}; - var NONUNIQUE_KEY = 'nonuniqueKey'; - for (var i = 0; i < objects.length; i++) { - var object = objects[i]; - var objectKey = object.getSettingsKey(); - if (!objectKey) - continue; - if (objectsByKey[objectKey] === undefined) { - objectsByKey[objectKey] = object; - continue; - } - objectsByKey[objectKey] = NONUNIQUE_KEY; - } - - var nonuniqueKeys = {}; - tr.b.dictionaryKeys(objectsByKey).forEach(function(objectKey) { - if (objectsByKey[objectKey] !== NONUNIQUE_KEY) - return; - delete objectsByKey[objectKey]; - nonuniqueKeys[objectKey] = true; - }); - - this.nonuniqueKeys = nonuniqueKeys; - this.objectsByKey_ = objectsByKey; - }, - - removeNonuniqueKeysFromSettings_: function() { - var settings = Settings.get('trace_model_settings', {}); - var settingsChanged = false; - tr.b.dictionaryKeys(settings).forEach(function(objectKey) { - if (!this.nonuniqueKeys[objectKey]) - return; - settingsChanged = true; - delete settings[objectKey]; - }, this); - if (settingsChanged) - Settings.set('trace_model_settings', settings); - }, - - hasUniqueSettingKey: function(object) { - var objectKey = object.getSettingsKey(); - if (!objectKey) - return false; - return this.objectsByKey_[objectKey] !== undefined; - }, - - getSettingFor: function(object, objectLevelKey, defaultValue) { - var objectKey = object.getSettingsKey(); - if (!objectKey || !this.objectsByKey_[objectKey]) { - var settings = this.getEphemeralSettingsFor_(object); - var ephemeralValue = settings[objectLevelKey]; - if (ephemeralValue !== undefined) - return ephemeralValue; - return defaultValue; - } - - var settings = Settings.get('trace_model_settings', {}); - if (!settings[objectKey]) - settings[objectKey] = {}; - var value = settings[objectKey][objectLevelKey]; - if (value !== undefined) - return value; - return defaultValue; - }, - - setSettingFor: function(object, objectLevelKey, value) { - var objectKey = object.getSettingsKey(); - if (!objectKey || !this.objectsByKey_[objectKey]) { - this.getEphemeralSettingsFor_(object)[objectLevelKey] = value; - return; - } - - var settings = Settings.get('trace_model_settings', {}); - if (!settings[objectKey]) - settings[objectKey] = {}; - if (settings[objectKey][objectLevelKey] === value) - return; - settings[objectKey][objectLevelKey] = value; - Settings.set('trace_model_settings', settings); - }, - - getEphemeralSettingsFor_: function(object) { - if (object.guid === undefined) - throw new Error('Only objects with GUIDs can be persisted'); - if (this.ephemeralSettingsByGUID_[object.guid] === undefined) - this.ephemeralSettingsByGUID_[object.guid] = {}; - return this.ephemeralSettingsByGUID_[object.guid]; - } - }; - - return { - ModelSettings: ModelSettings - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/model_settings_test.html b/chromium/third_party/catapult/tracing/tracing/model/model_settings_test.html deleted file mode 100644 index 3b7b58ee107..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/model_settings_test.html +++ /dev/null @@ -1,178 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/model_settings.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('process_name_uniqueness_0', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var settings = new tr.model.ModelSettings(model); - assert.isFalse(settings.hasUniqueSettingKey(p1)); - }); - - test('process_name_uniqueness_1', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - p1.name = 'Browser'; - var settings = new tr.model.ModelSettings(model); - assert.isTrue(settings.hasUniqueSettingKey(p1)); - }); - - test('process_name_uniqueness_2', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var p2 = model.getOrCreateProcess(2); - p1.name = 'Renderer'; - p2.name = 'Renderer'; - var settings = new tr.model.ModelSettings(model); - assert.isFalse(settings.hasUniqueSettingKey(p1)); - assert.isFalse(settings.hasUniqueSettingKey(p2)); - }); - - test('process_name_uniqueness_3', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var p2 = model.getOrCreateProcess(2); - p1.name = 'Renderer'; - p1.labels.push('Google Search'); - p2.name = 'Renderer'; - var settings = new tr.model.ModelSettings(model); - assert.isTrue(settings.hasUniqueSettingKey(p1)); - assert.isTrue(settings.hasUniqueSettingKey(p2)); - }); - - test('thread_name_uniqueness_0', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var p2 = model.getOrCreateProcess(2); - var t1 = p1.getOrCreateThread(1); - var t2 = p2.getOrCreateThread(2); - p1.name = 'Browser'; - p2.name = 'Renderer'; - t1.name = 'Main'; - t2.name = 'Main'; - var settings = new tr.model.ModelSettings(model); - assert.isTrue(settings.hasUniqueSettingKey(t1)); - assert.isTrue(settings.hasUniqueSettingKey(t2)); - }); - - test('thread_name_uniqueness_1', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var p2 = model.getOrCreateProcess(2); - var t1 = p1.getOrCreateThread(1); - var t2 = p2.getOrCreateThread(2); - p1.name = 'Renderer'; - p2.name = 'Renderer'; - t1.name = 'Main'; - t2.name = 'Main'; - var settings = new tr.model.ModelSettings(model); - assert.isFalse(settings.hasUniqueSettingKey(t1)); - assert.isFalse(settings.hasUniqueSettingKey(t2)); - }); - - test('process_persistence_when_not_unique', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var settings = new tr.model.ModelSettings(model); - assert.isTrue(settings.getSettingFor(p1, 'true_by_default', true)); - - settings.setSettingFor(p1, 'true_by_default', false); - assert.isFalse(settings.getSettingFor(p1, 'true_by_default', true)); - - // Now, clobber the model, and verify that it didn't persist. - model = new tr.Model(); - p1 = model.getOrCreateProcess(1); - settings = new tr.model.ModelSettings(model); - assert.isTrue(settings.getSettingFor(p1, 'true_by_default', true)); - }); - - test('process_persistence_when_not_unique_with_name', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - p1.name = 'Browser'; - var settings = new tr.model.ModelSettings(model); - assert.isTrue(settings.getSettingFor(p1, 'true_by_default', true)); - - settings.setSettingFor(p1, 'true_by_default', false); - assert.isFalse(settings.getSettingFor(p1, 'true_by_default', true)); - - // Now, clobber the model, and verify that it persisted. - model = new tr.Model(); - p1 = model.getOrCreateProcess(1); - p1.name = 'Browser'; - settings = new tr.model.ModelSettings(model); - assert.isFalse(settings.getSettingFor(p1, 'true_by_default', true)); - }); - - test('thread_persistence_when_not_unique', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var p2 = model.getOrCreateProcess(2); - var t1 = p1.getOrCreateThread(1); - var t2 = p2.getOrCreateThread(2); - p1.name = 'Renderer'; - p2.name = 'Renderer'; - t1.name = 'Main'; - t2.name = 'Main'; - var settings = new tr.model.ModelSettings(model); - assert.isTrue(settings.getSettingFor(t1, 'true_by_default', true)); - - settings.setSettingFor(t1, 'true_by_default', false); - assert.isFalse(settings.getSettingFor(t1, 'true_by_default', true)); - - // Now, clobber the model, and verify that it persisted. - model = new tr.Model(); - p1 = model.getOrCreateProcess(1); - p2 = model.getOrCreateProcess(2); - t1 = p1.getOrCreateThread(1); - t2 = p2.getOrCreateThread(2); - p1.name = 'Renderer'; - p2.name = 'Renderer'; - t1.name = 'Main'; - t2.name = 'Main'; - settings = new tr.model.ModelSettings(model); - assert.isTrue(settings.getSettingFor(t1, 'true_by_default', true)); - }); - - test('thread_persistence_when_unique', function() { - var model = new tr.Model(); - var p1 = model.getOrCreateProcess(1); - var p2 = model.getOrCreateProcess(2); - var t1 = p1.getOrCreateThread(1); - var t2 = p2.getOrCreateThread(2); - p1.name = 'Browser'; - p2.name = 'Renderer'; - t1.name = 'Main'; - t2.name = 'Main'; - var settings = new tr.model.ModelSettings(model); - assert.isTrue(settings.getSettingFor(t1, 'true_by_default', true)); - - settings.setSettingFor(t1, 'true_by_default', false); - assert.isFalse(settings.getSettingFor(t1, 'true_by_default', true)); - - // Now, clobber the model, and verify that it persisted. - model = new tr.Model(); - p1 = model.getOrCreateProcess(1); - p2 = model.getOrCreateProcess(2); - t1 = p1.getOrCreateThread(1); - t2 = p2.getOrCreateThread(2); - p1.name = 'Browser'; - p2.name = 'Renderer'; - t1.name = 'Main'; - t2.name = 'Main'; - settings = new tr.model.ModelSettings(model); - assert.isFalse(settings.getSettingFor(t1, 'true_by_default', true)); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/model_stats.html b/chromium/third_party/catapult/tracing/tracing/model/model_stats.html deleted file mode 100644 index fd5bf957dc8..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/model_stats.html +++ /dev/null @@ -1,89 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - - /** - * @constructor - */ - function ModelStats() { - this.traceEventCountsByKey_ = new Map(); - this.allTraceEventStats_ = []; - - this.traceEventStatsInTimeIntervals_ = new Map(); - this.allTraceEventStatsInTimeIntervals_ = []; - - this.hasEventSizesinBytes_ = false; - } - - ModelStats.prototype = { - TIME_INTERVAL_SIZE_IN_MS: 100, - - willProcessBasicTraceEvent: function(phase, category, title, ts, - opt_eventSizeinBytes) { - var key = phase + '/' + category + '/' + title; - var eventStats = this.traceEventCountsByKey_.get(key); - if (eventStats === undefined) { - eventStats = { - phase: phase, - category: category, - title: title, - numEvents: 0, - totalEventSizeinBytes: 0 - }; - this.traceEventCountsByKey_.set(key, eventStats); - this.allTraceEventStats_.push(eventStats); - } - eventStats.numEvents++; - - var timeIntervalKey = Math.floor( - tr.v.Unit.timestampFromUs(ts) / this.TIME_INTERVAL_SIZE_IN_MS); - var eventStatsByTimeInverval = - this.traceEventStatsInTimeIntervals_.get(timeIntervalKey); - if (eventStatsByTimeInverval === undefined) { - eventStatsByTimeInverval = { - timeInterval: timeIntervalKey, - numEvents: 0, - totalEventSizeinBytes: 0 - }; - this.traceEventStatsInTimeIntervals_.set(timeIntervalKey, - eventStatsByTimeInverval); - this.allTraceEventStatsInTimeIntervals_.push(eventStatsByTimeInverval); - } - eventStatsByTimeInverval.numEvents++; - - if (opt_eventSizeinBytes !== undefined) { - this.hasEventSizesinBytes_ = true; - eventStats.totalEventSizeinBytes += opt_eventSizeinBytes; - eventStatsByTimeInverval.totalEventSizeinBytes += opt_eventSizeinBytes; - } - }, - - get allTraceEventStats() { - return this.allTraceEventStats_; - }, - - get allTraceEventStatsInTimeIntervals() { - return this.allTraceEventStatsInTimeIntervals_; - }, - - get hasEventSizesinBytes() { - return this.hasEventSizesinBytes_; - } - }; - - return { - ModelStats: ModelStats - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/model_stats_test.html b/chromium/third_party/catapult/tracing/tracing/model/model_stats_test.html deleted file mode 100644 index 2a5631820b1..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/model_stats_test.html +++ /dev/null @@ -1,62 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/model/model_stats.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var ModelStats = tr.model.ModelStats; - - test('getTraceEventStatsByCategory', function() { - var modelStats = new ModelStats(); - modelStats.willProcessBasicTraceEvent('X', 'cat1', 'title1'); - modelStats.willProcessBasicTraceEvent('X', 'cat1', 'title1'); - modelStats.willProcessBasicTraceEvent('X', 'cat2', 'title3'); - - assert.equal(modelStats.allTraceEventStats.length, 2); - assert.equal( - modelStats.traceEventCountsByKey_.get('X/cat1/title1').numEvents, - 2); - assert.equal( - modelStats.traceEventCountsByKey_.get('X/cat2/title3').numEvents, - 1); - }); - - test('getTraceEventStatsInTimeIntervals', function() { - var modelStats = new ModelStats(); - var timeIntervalSizeInUs = modelStats.TIME_INTERVAL_SIZE_IN_MS * 1000; - modelStats.willProcessBasicTraceEvent('X', 'cat1', 'title1', 1, 1); - modelStats.willProcessBasicTraceEvent( - 'X', 'cat1', 'title1', timeIntervalSizeInUs + 1, 2); - modelStats.willProcessBasicTraceEvent( - 'X', 'cat1', 'title1', 2 * timeIntervalSizeInUs + 1, 3); - modelStats.willProcessBasicTraceEvent( - 'X', 'cat2', 'title3', 2 * timeIntervalSizeInUs + 2, 4); - - assert.strictEqual(modelStats.allTraceEventStatsInTimeIntervals.length, 3); - assert.strictEqual( - modelStats.traceEventStatsInTimeIntervals_.get(0).numEvents, 1); - assert.strictEqual( - modelStats.traceEventStatsInTimeIntervals_.get(1).numEvents, 1); - assert.strictEqual( - modelStats.traceEventStatsInTimeIntervals_.get(2).numEvents, 2); - - assert.isTrue(modelStats.hasEventSizesinBytes); - assert.strictEqual( - modelStats.traceEventStatsInTimeIntervals_.get(0).totalEventSizeinBytes, - 1); - assert.strictEqual( - modelStats.traceEventStatsInTimeIntervals_.get(1).totalEventSizeinBytes, - 2); - assert.strictEqual( - modelStats.traceEventStatsInTimeIntervals_.get(2).totalEventSizeinBytes, - 7); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/model_test.html b/chromium/third_party/catapult/tracing/tracing/model/model_test.html deleted file mode 100644 index 75c1f9d5155..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/model_test.html +++ /dev/null @@ -1,341 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/extras/importer/trace_event_importer.html"> -<link rel="import" href="/tracing/importer/import.html"> -<link rel="import" href="/tracing/model/annotation.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/value/time_display_mode.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var ThreadSlice = tr.model.ThreadSlice; - var TitleOrCategoryFilter = tr.c.TitleOrCategoryFilter; - var Frame = tr.model.Frame; - - var createModelWithOneOfEverything = function() { - var m = new tr.Model(); - var cpu = m.kernel.getOrCreateCpu(1); - cpu.slices.push(tr.c.TestUtils.newSliceEx({start: 1, duration: 3})); - - var p = m.getOrCreateProcess(1); - var t = p.getOrCreateThread(1); - var slice = new ThreadSlice('', 'a', 0, 1, {}, 4); - t.sliceGroup.pushSlice(slice); - t.asyncSliceGroup.push(tr.c.TestUtils.newAsyncSlice(0, 1, t, t)); - - var c = p.getOrCreateCounter('', 'ProcessCounter'); - var aSeries = new tr.model.CounterSeries('a', 0); - var bSeries = new tr.model.CounterSeries('b', 0); - c.addSeries(aSeries); - c.addSeries(bSeries); - - aSeries.addCounterSample(0, 5); - aSeries.addCounterSample(1, 6); - aSeries.addCounterSample(2, 5); - aSeries.addCounterSample(3, 7); - - bSeries.addCounterSample(0, 10); - bSeries.addCounterSample(1, 15); - bSeries.addCounterSample(2, 12); - bSeries.addCounterSample(3, 16); - - var c1 = cpu.getOrCreateCounter('', 'CpuCounter'); - var aSeries = new tr.model.CounterSeries('a', 0); - var bSeries = new tr.model.CounterSeries('b', 0); - c1.addSeries(aSeries); - c1.addSeries(bSeries); - - aSeries.addCounterSample(0, 5); - aSeries.addCounterSample(1, 6); - aSeries.addCounterSample(2, 5); - aSeries.addCounterSample(3, 7); - - bSeries.addCounterSample(0, 10); - bSeries.addCounterSample(1, 15); - bSeries.addCounterSample(2, 12); - bSeries.addCounterSample(3, 16); - - var frame1 = new Frame([slice], [{thread: t, start: 1, end: 5}]); - p.frames.push.apply(p.frames, frame1); - - var gd = new tr.model.GlobalMemoryDump(m, 2); - var pd = new tr.model.ProcessMemoryDump(gd, p, 2); - gd.processMemoryDumps[1] = pd; - m.globalMemoryDumps.push(gd); - p.memoryDumps.push(pd); - - m.updateBounds(); - - return m; - }; - - test('helper', function() { - function Helper(model) { - this.model = model; - } - Helper.guid = tr.b.GUID.allocateSimple(); - Helper.supportsModel = function(model) { - return true; - }; - - var m = new tr.Model(); - var h = m.getOrCreateHelper(Helper); - assert.isTrue(h instanceof Helper); - assert.isTrue(h === m.getOrCreateHelper(Helper)); - - function UnsupportedHelper(model) { - this.model = model; - } - UnsupportedHelper.guid = tr.b.GUID.allocateSimple(); - UnsupportedHelper.supportsModel = function(model) { - return false; - }; - - assert.isUndefined(m.getOrCreateHelper(UnsupportedHelper)); - // Try again to test doesHelperGUIDSupportThisModel_ . - assert.isUndefined(m.getOrCreateHelper(UnsupportedHelper)); - }); - - test('modelBounds_EmptyModel', function() { - var m = new tr.Model(); - m.updateBounds(); - assert.isUndefined(m.bounds.min); - assert.isUndefined(m.bounds.max); - }); - - test('modelBounds_OneEmptyThread', function() { - var m = new tr.Model(); - var t = m.getOrCreateProcess(1).getOrCreateThread(1); - m.updateBounds(); - assert.isUndefined(m.bounds.min); - assert.isUndefined(m.bounds.max); - }); - - test('modelBounds_OneThread', function() { - var m = new tr.Model(); - var t = m.getOrCreateProcess(1).getOrCreateThread(1); - t.sliceGroup.pushSlice(new ThreadSlice('', 'a', 0, 1, {}, 3)); - m.updateBounds(); - assert.equal(m.bounds.min, 1); - assert.equal(m.bounds.max, 4); - }); - - test('modelBounds_OneThreadAndOneEmptyThread', function() { - var m = new tr.Model(); - var t1 = m.getOrCreateProcess(1).getOrCreateThread(1); - t1.sliceGroup.pushSlice(new ThreadSlice('', 'a', 0, 1, {}, 3)); - var t2 = m.getOrCreateProcess(1).getOrCreateThread(1); - m.updateBounds(); - assert.equal(m.bounds.min, 1); - assert.equal(m.bounds.max, 4); - }); - - test('modelBounds_OneCpu', function() { - var m = new tr.Model(); - var cpu = m.kernel.getOrCreateCpu(1); - cpu.slices.push(tr.c.TestUtils.newSliceEx({start: 1, duration: 3})); - m.updateBounds(); - assert.equal(m.bounds.min, 1); - assert.equal(m.bounds.max, 4); - }); - - test('modelBounds_OneCpuOneThread', function() { - var m = new tr.Model(); - var cpu = m.kernel.getOrCreateCpu(1); - cpu.slices.push(tr.c.TestUtils.newSliceEx({start: 1, duration: 3})); - - var t = m.getOrCreateProcess(1).getOrCreateThread(1); - t.sliceGroup.pushSlice(new ThreadSlice('', 'a', 0, 1, {}, 4)); - - m.updateBounds(); - assert.equal(m.bounds.min, 1); - assert.equal(m.bounds.max, 5); - }); - - test('modelBounds_GlobalMemoryDumps', function() { - var m = new tr.Model(); - m.globalMemoryDumps.push(new tr.model.GlobalMemoryDump(m, 1)); - m.globalMemoryDumps.push(new tr.model.GlobalMemoryDump(m, 3)); - m.globalMemoryDumps.push(new tr.model.GlobalMemoryDump(m, 5)); - - m.updateBounds(); - assert.equal(m.bounds.min, 1); - assert.equal(m.bounds.max, 5); - }); - - test('modelBounds_ProcessMemoryDumps', function() { - var m = new tr.Model(); - var p = m.getOrCreateProcess(1); - var gd = new tr.model.GlobalMemoryDump(m, -1); - p.memoryDumps.push(new tr.model.ProcessMemoryDump(gd, m, 1)); - p.memoryDumps.push(new tr.model.ProcessMemoryDump(gd, m, 3)); - p.memoryDumps.push(new tr.model.ProcessMemoryDump(gd, m, 5)); - - m.updateBounds(); - assert.equal(m.bounds.min, 1); - assert.equal(m.bounds.max, 5); - }); - - - test('modelConvertsTimestampToModelTime', function() { - var m = new tr.Model(); - var traceEvents = [ - {ts: 1000, pid: 1, tid: 1, ph: 'B', cat: 'a', name: 'taskA', args: {}}, - {ts: 2000, pid: 1, tid: 1, ph: 'E', cat: 'a', name: 'taskA', args: {}} - ]; - var i = new tr.importer.Import(m); - i.importTraces([traceEvents]); - assert.equal(m.convertTimestampToModelTime('traceEventClock', 1000), 0); - assert.equal(m.convertTimestampToModelTime('traceEventClock', 2000), 1); - }); - - test('TitleOrCategoryFilter', function() { - var s0 = tr.c.TestUtils.newSliceEx({start: 1, duration: 3}); - assert.isTrue(new TitleOrCategoryFilter('a').matchSlice(s0)); - assert.isFalse(new TitleOrCategoryFilter('x').matchSlice(s0)); - - var s1 = tr.c.TestUtils.newSliceEx({title: 'ba', start: 1, duration: 3}); - assert.isTrue(new TitleOrCategoryFilter('a').matchSlice(s1)); - assert.isTrue(new TitleOrCategoryFilter('ba').matchSlice(s1)); - assert.isFalse(new TitleOrCategoryFilter('x').matchSlice(s1)); - }); - - test('model_findAllThreadsNamed', function() { - var m = new tr.Model(); - var t = m.getOrCreateProcess(1).getOrCreateThread(1); - t.name = 'CrBrowserMain'; - - m.updateBounds(); - var f = m.findAllThreadsNamed('CrBrowserMain'); - assert.deepEqual([t], f); - f = m.findAllThreadsNamed('NoSuchThread'); - assert.equal(f.length, 0); - }); - - test('model_updateCategories', function() { - var m = new tr.Model(); - var t = m.getOrCreateProcess(1).getOrCreateThread(1); - t.sliceGroup.pushSlice(new ThreadSlice('categoryA', 'a', 0, 1, {}, 3)); - t.sliceGroup.pushSlice(new ThreadSlice('categoryA', 'a', 0, 1, {}, 3)); - t.sliceGroup.pushSlice(new ThreadSlice('categoryB', 'a', 0, 1, {}, 3)); - t.sliceGroup.pushSlice(new ThreadSlice('categoryA', 'a', 0, 1, {}, 3)); - t.sliceGroup.pushSlice(new ThreadSlice('', 'a', 0, 1, {}, 3)); - m.updateCategories_(); - assert.deepEqual(['categoryA', 'categoryB'], m.categories); - }); - - test('getEventByStableId', function() { - var m = new tr.Model(); - var p = m.getOrCreateProcess(0); - var t = p.getOrCreateThread(1); - var slice = tr.c.TestUtils.newSliceEx({start: 0, duration: 10}); - t.sliceGroup.pushSlice(slice); - var ue = tr.c.TestUtils.newInteractionRecord(m, 0, 10); - m.userModel.expectations.push(ue); - var gie = tr.c.TestUtils.newInstantEvent({ - title: 'gie', - start: 0, - colorId: 0 - }); - m.instantEvents.push(gie); - - assert.strictEqual(slice, m.getEventByStableId(slice.stableId)); - assert.strictEqual(ue, m.getEventByStableId(ue.stableId)); - assert.strictEqual(gie, m.getEventByStableId(gie.stableId)); - }); - - test('model_annotationAddRemove', function() { - var m = new tr.Model(); - var a1 = new tr.model.Annotation(); - var a2 = new tr.model.Annotation(); - - assert.equal(m.getAllAnnotations().length, 0); - m.addAnnotation(a1); - assert.equal(m.getAllAnnotations().length, 1); - m.addAnnotation(a2); - assert.equal(m.getAllAnnotations().length, 2); - - assert.equal(m.getAnnotationByGUID(a1.guid), a1); - assert.equal(m.getAnnotationByGUID(a2.guid), a2); - - m.removeAnnotation(a1); - assert.isUndefined(m.getAnnotationByGUID(a1.guid)); - assert.equal(m.getAnnotationByGUID(a2.guid), a2); - assert.equal(m.getAllAnnotations().length, 1); - }); - - test('model_intrinsicTimeUnit', function() { - var unit = tr.v.TimeDisplayModes; - var m = new tr.Model(); - - // by default it should be milliseconds - assert.equal(m.intrinsicTimeUnit, unit.ms); - - m.intrinsicTimeUnit = unit.ns; - assert.equal(m.intrinsicTimeUnit, unit.ns); - // should be able to set to the same - m.intrinsicTimeUnit = unit.ns; - assert.equal(m.intrinsicTimeUnit, unit.ns); - // should not be able to change it after fixing it - assert.throw(function() { m.intrinsicTimeUnit = unit.ms; }); - assert.equal(m.intrinsicTimeUnit, unit.ns); - }); - - test('model_getAllProcesses', function() { - var m = new tr.Model(); - var p1 = m.getOrCreateProcess(1); - var p2 = m.getOrCreateProcess(2); - var p3 = m.getOrCreateProcess(3); - var p4 = m.getOrCreateProcess(4); - var p5 = m.getOrCreateProcess(5); - - assert.sameMembers(m.getAllProcesses(), [p1, p2, p3, p4, p5]); - assert.sameMembers(m.getAllProcesses(p => true), [p1, p2, p3, p4, p5]); - assert.sameMembers(m.getAllProcesses(p => false), []); - assert.sameMembers(m.getAllProcesses(p => p.pid % 2 === 0), [p2, p4]); - }); - - test('model_joinRefs', function() { - function RefCountingSnapshot() { - tr.model.ObjectSnapshot.apply(this, arguments); - this.refCount = 0; - } - - RefCountingSnapshot.prototype = { - __proto__: tr.model.ObjectSnapshot.prototype, - - referencedAt: function() { - ++this.refCount; - } - }; - - var typeName = 'RefCountingSnapshot'; - tr.model.ObjectSnapshot.register( - RefCountingSnapshot, - {typeName: typeName}); - - var m = new tr.Model(); - var p = m.getOrCreateProcess(1); - var s1 = p.objects.addSnapshot(new tr.model.ScopedId(typeName, '0x1'), - 'cat', typeName, 1000, {}); - var s2 = p.objects.addSnapshot(new tr.model.ScopedId(typeName, '0x2'), - 'cat', typeName, 2000, { - myRef: { - scope: typeName, - id_ref: '0x1' - } - }); - m.joinRefs(); - assert.equal(s1.refCount, 1); - assert.equal(s2.refCount, 0); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/object_collection.html b/chromium/third_party/catapult/tracing/tracing/model/object_collection.html deleted file mode 100644 index 93122c8d4f5..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/object_collection.html +++ /dev/null @@ -1,233 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/base/sorted_array_utils.html"> -<link rel="import" href="/tracing/base/utils.html"> -<link rel="import" href="/tracing/model/event_container.html"> -<link rel="import" href="/tracing/model/object_instance.html"> -<link rel="import" href="/tracing/model/time_to_object_instance_map.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the ObjectCollection class. - */ -tr.exportTo('tr.model', function() { - var ObjectInstance = tr.model.ObjectInstance; - var ObjectSnapshot = tr.model.ObjectSnapshot; - - /** - * A collection of object instances and their snapshots, accessible by id and - * time, or by object name. - * - * @constructor - */ - function ObjectCollection(parent) { - tr.model.EventContainer.call(this); - this.parent = parent; - // scope -> {id -> TimeToObjectInstanceMap} - this.instanceMapsByScopedId_ = {}; - this.instancesByTypeName_ = {}; - this.createObjectInstance_ = this.createObjectInstance_.bind(this); - } - - ObjectCollection.prototype = { - __proto__: tr.model.EventContainer.prototype, - - childEvents: function*() { - for (var instance of this.getAllObjectInstances()) { - yield instance; - yield * instance.snapshots; - } - }, - - createObjectInstance_: function( - parent, scopedId, category, name, creationTs, opt_baseTypeName) { - var constructor = tr.model.ObjectInstance.getConstructor( - category, name); - var instance = new constructor( - parent, scopedId, category, name, creationTs, opt_baseTypeName); - var typeName = instance.typeName; - var instancesOfTypeName = this.instancesByTypeName_[typeName]; - if (!instancesOfTypeName) { - instancesOfTypeName = []; - this.instancesByTypeName_[typeName] = instancesOfTypeName; - } - instancesOfTypeName.push(instance); - return instance; - }, - - getOrCreateInstanceMap_: function(scopedId) { - var dict; - if (scopedId.scope in this.instanceMapsByScopedId_) { - dict = this.instanceMapsByScopedId_[scopedId.scope]; - } else { - dict = {}; - this.instanceMapsByScopedId_[scopedId.scope] = dict; - } - var instanceMap = dict[scopedId.id]; - if (instanceMap) - return instanceMap; - instanceMap = new tr.model.TimeToObjectInstanceMap( - this.createObjectInstance_, this.parent, scopedId); - dict[scopedId.id] = instanceMap; - return instanceMap; - }, - - idWasCreated: function(scopedId, category, name, ts) { - var instanceMap = this.getOrCreateInstanceMap_(scopedId); - return instanceMap.idWasCreated(category, name, ts); - }, - - addSnapshot: function( - scopedId, category, name, ts, args, opt_baseTypeName) { - var instanceMap = this.getOrCreateInstanceMap_(scopedId); - var snapshot = instanceMap.addSnapshot( - category, name, ts, args, opt_baseTypeName); - if (snapshot.objectInstance.category != category) { - var msg = 'Added snapshot name=' + name + ' with cat=' + category + - ' impossible. It instance was created/snapshotted with cat=' + - snapshot.objectInstance.category + ' name=' + - snapshot.objectInstance.name; - throw new Error(msg); - } - if (opt_baseTypeName && - snapshot.objectInstance.baseTypeName != opt_baseTypeName) { - throw new Error('Could not add snapshot with baseTypeName=' + - opt_baseTypeName + '. It ' + - 'was previously created with name=' + - snapshot.objectInstance.baseTypeName); - } - if (snapshot.objectInstance.name != name) { - throw new Error('Could not add snapshot with name=' + name + '. It ' + - 'was previously created with name=' + - snapshot.objectInstance.name); - } - return snapshot; - }, - - idWasDeleted: function(scopedId, category, name, ts) { - var instanceMap = this.getOrCreateInstanceMap_(scopedId); - var deletedInstance = instanceMap.idWasDeleted(category, name, ts); - if (!deletedInstance) - return; - if (deletedInstance.category != category) { - var msg = 'Deleting object ' + deletedInstance.name + - ' with a different category ' + - 'than when it was created. It previous had cat=' + - deletedInstance.category + ' but the delete command ' + - 'had cat=' + category; - throw new Error(msg); - } - if (deletedInstance.baseTypeName != name) { - throw new Error('Deletion requested for name=' + - name + ' could not proceed: ' + - 'An existing object with baseTypeName=' + - deletedInstance.baseTypeName + ' existed.'); - } - }, - - autoDeleteObjects: function(maxTimestamp) { - tr.b.iterItems(this.instanceMapsByScopedId_, function(scope, imapById) { - tr.b.iterItems(imapById, function(id, i2imap) { - var lastInstance = i2imap.lastInstance; - if (lastInstance.deletionTs != Number.MAX_VALUE) - return; - i2imap.idWasDeleted( - lastInstance.category, lastInstance.name, maxTimestamp); - // idWasDeleted will cause lastInstance.deletionTsWasExplicit to be - // set to true. Unset it here. - lastInstance.deletionTsWasExplicit = false; - }); - }); - }, - - getObjectInstanceAt: function(scopedId, ts) { - var instanceMap; - if (scopedId.scope in this.instanceMapsByScopedId_) - instanceMap = this.instanceMapsByScopedId_[scopedId.scope][scopedId.id]; - if (!instanceMap) - return undefined; - return instanceMap.getInstanceAt(ts); - }, - - getSnapshotAt: function(scopedId, ts) { - var instance = this.getObjectInstanceAt(scopedId, ts); - if (!instance) - return undefined; - return instance.getSnapshotAt(ts); - }, - - iterObjectInstances: function(iter, opt_this) { - opt_this = opt_this || this; - tr.b.iterItems(this.instanceMapsByScopedId_, function(scope, imapById) { - tr.b.iterItems(imapById, function(id, i2imap) { - i2imap.instances.forEach(iter, opt_this); - }); - }); - }, - - getAllObjectInstances: function() { - var instances = []; - this.iterObjectInstances(function(i) { instances.push(i); }); - return instances; - }, - - getAllInstancesNamed: function(name) { - return this.instancesByTypeName_[name]; - }, - - getAllInstancesByTypeName: function() { - return this.instancesByTypeName_; - }, - - preInitializeAllObjects: function() { - this.iterObjectInstances(function(instance) { - instance.preInitialize(); - }); - }, - - initializeAllObjects: function() { - this.iterObjectInstances(function(instance) { - instance.initialize(); - }); - }, - - initializeInstances: function() { - this.iterObjectInstances(function(instance) { - instance.initialize(); - }); - }, - - updateBounds: function() { - this.bounds.reset(); - this.iterObjectInstances(function(instance) { - instance.updateBounds(); - this.bounds.addRange(instance.bounds); - }, this); - }, - - shiftTimestampsForward: function(amount) { - this.iterObjectInstances(function(instance) { - instance.shiftTimestampsForward(amount); - }); - }, - - addCategoriesToDict: function(categoriesDict) { - this.iterObjectInstances(function(instance) { - categoriesDict[instance.category] = true; - }); - } - }; - - return { - ObjectCollection: ObjectCollection - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/object_collection_test.html b/chromium/third_party/catapult/tracing/tracing/model/object_collection_test.html deleted file mode 100644 index 7137f89b201..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/object_collection_test.html +++ /dev/null @@ -1,231 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/object_collection.html"> -<link rel="import" href="/tracing/model/scoped_id.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var TestObjectInstance = function( - parent, scopedId, category, name, creationTs) { - tr.model.ObjectInstance.call( - this, parent, scopedId, category, name, creationTs); - }; - - TestObjectInstance.prototype = { - __proto__: tr.model.ObjectInstance.prototype - }; - - test('objectInstanceSubtype', function() { - // Register that TestObjects are bound to TestObjectInstance. - tr.model.ObjectInstance.register( - TestObjectInstance, - {typeName: 'TestObject'}); - - try { - var collection = new tr.model.ObjectCollection({ }); - var scopedId = new tr.model.ScopedId('ptr', '0x1000'); - collection.idWasCreated( - scopedId, 'tr.e.cc', 'Frame', 10); - collection.idWasDeleted( - scopedId, 'tr.e.cc', 'Frame', 15); - collection.idWasCreated( - scopedId, 'skia', 'TestObject', 20); - collection.idWasDeleted( - scopedId, 'skia', 'TestObject', 25); - - var testFrame = collection.getObjectInstanceAt(scopedId, 10); - assert.instanceOf(testFrame, tr.model.ObjectInstance); - assert.notInstanceOf(testFrame, TestObjectInstance); - - var testObject = collection.getObjectInstanceAt(scopedId, 20); - assert.instanceOf(testObject, tr.model.ObjectInstance); - assert.instanceOf(testObject, TestObjectInstance); - } finally { - tr.model.ObjectInstance.unregister(TestObjectInstance); - } - }); - - test('twoSnapshots', function() { - var collection = new tr.model.ObjectCollection({}); - var scopedId = new tr.model.ScopedId('ptr', '0x1000'); - collection.idWasCreated( - scopedId, 'cat', 'Frame', 10); - collection.addSnapshot( - scopedId, 'cat', 'Frame', 10, {foo: 1}); - collection.addSnapshot( - scopedId, 'cat', 'Frame', 20, {foo: 2}); - - collection.updateBounds(); - assert.equal(collection.bounds.min, 10); - assert.equal(collection.bounds.max, 20); - - var s0 = collection.getSnapshotAt(scopedId, 1); - assert.isUndefined(s0); - - var s1 = collection.getSnapshotAt(scopedId, 10); - assert.equal(s1.args.foo, 1); - - var s2 = collection.getSnapshotAt(scopedId, 15); - assert.equal(s2.args.foo, 1); - assert.equal(s1, s2); - - var s3 = collection.getSnapshotAt(scopedId, 20); - assert.equal(s3.args.foo, 2); - assert.equal(s1.object, s3.object); - - var s4 = collection.getSnapshotAt(scopedId, 25); - assert.equal(s4, s3); - }); - - test('twoObjectsSharingOneID', function() { - var collection = new tr.model.ObjectCollection({}); - var scopedId = new tr.model.ScopedId('ptr', '0x1000'); - collection.idWasCreated( - scopedId, 'tr.e.cc', 'Frame', 10); - collection.idWasDeleted( - scopedId, 'tr.e.cc', 'Frame', 15); - collection.idWasCreated( - scopedId, 'skia', 'Picture', 20); - collection.idWasDeleted( - scopedId, 'skia', 'Picture', 25); - - var frame = collection.getObjectInstanceAt(scopedId, 10); - assert.equal(frame.category, 'tr.e.cc'); - assert.equal(frame.name, 'Frame'); - - var picture = collection.getObjectInstanceAt(scopedId, 20); - assert.equal(picture.category, 'skia'); - assert.equal(picture.name, 'Picture'); - - var typeNames = tr.b.dictionaryKeys(collection.getAllInstancesByTypeName()); - typeNames.sort(); - assert.deepEqual( - ['Frame', 'Picture'], - typeNames); - assert.deepEqual( - [frame], - collection.getAllInstancesByTypeName()['Frame']); - assert.deepEqual( - [picture], - collection.getAllInstancesByTypeName()['Picture']); - }); - - test('createSnapDelete', function() { - var collection = new tr.model.ObjectCollection({}); - var scopedId = new tr.model.ScopedId('ptr', '0x1000'); - collection.idWasCreated( - scopedId, 'cat', 'Frame', 10); - collection.addSnapshot( - scopedId, 'cat', 'Frame', 10, {foo: 1}); - collection.idWasDeleted( - scopedId, 'cat', 'Frame', 15); - - collection.updateBounds(); - assert.equal(collection.bounds.min, 10); - assert.equal(collection.bounds.max, 15); - - var s10 = collection.getSnapshotAt(scopedId, 10); - var i10 = s10.objectInstance; - assert.equal(i10.creationTs, 10); - assert.equal(i10.deletionTs, 15); - }); - - test('boundsOnUndeletedObject', function() { - var collection = new tr.model.ObjectCollection({}); - var scopedId = new tr.model.ScopedId('ptr', '0x1000'); - collection.idWasCreated( - scopedId, 'cat', 'Frame', 10); - collection.addSnapshot( - scopedId, 'cat', 'Frame', 15, {foo: 1}); - - collection.updateBounds(); - assert.equal(10, collection.bounds.min); - assert.equal(15, collection.bounds.max); - }); - - test('snapshotWithCustomBaseTypeThenDelete', function() { - var collection = new tr.model.ObjectCollection({}); - var scopedId = new tr.model.ScopedId('ptr', '0x1000'); - var s10 = collection.addSnapshot( - scopedId, 'cat', 'cc::PictureLayerImpl', 10, {}, 'cc::LayerImpl'); - collection.idWasDeleted( - scopedId, 'cat', 'cc::LayerImpl', 15); - collection.updateBounds(); - assert.equal(10, collection.bounds.min); - assert.equal(15, collection.bounds.max); - assert.equal(s10.objectInstance.name, 'cc::PictureLayerImpl'); - assert.equal(s10.objectInstance.baseTypeName, 'cc::LayerImpl'); - }); - - test('newWithSnapshotThatChangesBaseType', function() { - var collection = new tr.model.ObjectCollection({}); - var scopedId = new tr.model.ScopedId('ptr', '0x1000'); - var i10 = collection.idWasCreated( - scopedId, 'cat', 'cc::LayerImpl', 10); - var s15 = collection.addSnapshot( - scopedId, 'cat', 'cc::PictureLayerImpl', 15, {}, 'cc::LayerImpl'); - collection.updateBounds(); - assert.equal(10, collection.bounds.min); - assert.equal(15, collection.bounds.max); - assert.equal(s15.objectInstance, i10); - assert.equal(i10.name, 'cc::PictureLayerImpl'); - assert.equal(i10.baseTypeName, 'cc::LayerImpl'); - }); - - test('deleteThenSnapshotWithCustomBase', function() { - var collection = new tr.model.ObjectCollection({}); - var scopedId = new tr.model.ScopedId('ptr', '0x1000'); - collection.idWasDeleted( - scopedId, 'cat', 'cc::LayerImpl', 10); - var s15 = collection.addSnapshot( - scopedId, 'cat', 'cc::PictureLayerImpl', 15, {}, 'cc::LayerImpl'); - collection.updateBounds(); - assert.equal(10, collection.bounds.min); - assert.equal(15, collection.bounds.max); - assert.equal(s15.objectInstance.name, 'cc::PictureLayerImpl'); - }); - - test('autoDelete', function() { - var collection = new tr.model.ObjectCollection({}); - var scopedId = new tr.model.ScopedId('ptr', '0x1000'); - collection.idWasCreated( - scopedId, 'cat', 'Frame', 10); - collection.addSnapshot( - scopedId, 'cat', 'Frame', 10, {foo: 1}); - collection.autoDeleteObjects(15); - - var s10 = collection.getSnapshotAt(scopedId, 10); - var i10 = s10.objectInstance; - assert.equal(15, i10.deletionTs); - }); - - test('differentScopes', function() { - var collection = new tr.model.ObjectCollection({}); - var scopedId1 = new tr.model.ScopedId('ptr', '0x1000'); - var scopedId2 = new tr.model.ScopedId('cc', '0x1000'); - collection.idWasCreated( - scopedId1, 'cat', 'ptr::object', 10); - collection.idWasDeleted( - scopedId1, 'cat', 'ptr::object', 15); - collection.idWasCreated( - scopedId2, 'cat', 'cc::object', 10); - collection.idWasDeleted( - scopedId2, 'cat', 'cc::object', 15); - - var instance = collection.getObjectInstanceAt(scopedId1, 10); - assert.equal(instance.name, 'ptr::object'); - - var instance = collection.getObjectInstanceAt(scopedId2, 10); - assert.equal(instance.name, 'cc::object'); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/object_instance.html b/chromium/third_party/catapult/tracing/tracing/model/object_instance.html deleted file mode 100644 index 37337712073..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/object_instance.html +++ /dev/null @@ -1,206 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/extension_registry.html"> -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/base/sorted_array_utils.html"> -<link rel="import" href="/tracing/model/event.html"> -<link rel="import" href="/tracing/model/object_snapshot.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the ObjectSnapshot and ObjectHistory classes. - */ -tr.exportTo('tr.model', function() { - var ObjectSnapshot = tr.model.ObjectSnapshot; - - /** - * An object with a specific id, whose state has been snapshotted several - * times. - * - * @constructor - */ - function ObjectInstance( - parent, scopedId, category, name, creationTs, opt_baseTypeName) { - tr.model.Event.call(this); - this.parent = parent; - this.scopedId = scopedId; - this.category = category; - this.baseTypeName = opt_baseTypeName ? opt_baseTypeName : name; - this.name = name; - this.creationTs = creationTs; - this.creationTsWasExplicit = false; - this.deletionTs = Number.MAX_VALUE; - this.deletionTsWasExplicit = false; - this.colorId = 0; - this.bounds = new tr.b.Range(); - this.snapshots = []; - this.hasImplicitSnapshots = false; - } - - ObjectInstance.prototype = { - __proto__: tr.model.Event.prototype, - - get typeName() { - return this.name; - }, - - addBoundsToRange: function(range) { - range.addRange(this.bounds); - }, - - addSnapshot: function(ts, args, opt_name, opt_baseTypeName) { - if (ts < this.creationTs) - throw new Error('Snapshots must be >= instance.creationTs'); - if (ts >= this.deletionTs) - throw new Error('Snapshots cannot be added after ' + - 'an objects deletion timestamp.'); - - var lastSnapshot; - if (this.snapshots.length > 0) { - lastSnapshot = this.snapshots[this.snapshots.length - 1]; - if (lastSnapshot.ts == ts) - throw new Error('Snapshots already exists at this time!'); - if (ts < lastSnapshot.ts) { - throw new Error( - 'Snapshots must be added in increasing timestamp order'); - } - } - - // Update baseTypeName if needed. - if (opt_name && - (this.name != opt_name)) { - if (!opt_baseTypeName) - throw new Error('Must provide base type name for name update'); - if (this.baseTypeName != opt_baseTypeName) - throw new Error('Cannot update type name: base types dont match'); - this.name = opt_name; - } - - var snapshotConstructor = - tr.model.ObjectSnapshot.getConstructor( - this.category, this.name); - var snapshot = new snapshotConstructor(this, ts, args); - this.snapshots.push(snapshot); - return snapshot; - }, - - wasDeleted: function(ts) { - var lastSnapshot; - if (this.snapshots.length > 0) { - lastSnapshot = this.snapshots[this.snapshots.length - 1]; - if (lastSnapshot.ts > ts) - throw new Error( - 'Instance cannot be deleted at ts=' + - ts + '. A snapshot exists that is older.'); - } - this.deletionTs = ts; - this.deletionTsWasExplicit = true; - }, - - /** - * See ObjectSnapshot constructor notes on object initialization. - */ - preInitialize: function() { - for (var i = 0; i < this.snapshots.length; i++) - this.snapshots[i].preInitialize(); - }, - - /** - * See ObjectSnapshot constructor notes on object initialization. - */ - initialize: function() { - for (var i = 0; i < this.snapshots.length; i++) - this.snapshots[i].initialize(); - }, - - isAliveAt: function(ts) { - if (ts < this.creationTs && this.creationTsWasExplicit) - return false; - if (ts > this.deletionTs) - return false; - - return true; - }, - - getSnapshotAt: function(ts) { - if (ts < this.creationTs) { - if (this.creationTsWasExplicit) - throw new Error('ts must be within lifetime of this instance'); - return this.snapshots[0]; - } - if (ts > this.deletionTs) - throw new Error('ts must be within lifetime of this instance'); - - var snapshots = this.snapshots; - var i = tr.b.findIndexInSortedIntervals( - snapshots, - function(snapshot) { return snapshot.ts; }, - function(snapshot, i) { - if (i == snapshots.length - 1) - return snapshots[i].objectInstance.deletionTs; - return snapshots[i + 1].ts - snapshots[i].ts; - }, - ts); - if (i < 0) { - // Note, this is a little bit sketchy: this lets early ts point at the - // first snapshot, even before it is taken. We do this because raster - // tasks usually post before their tile snapshots are dumped. This may - // be a good line of code to re-visit if we start seeing strange and - // confusing object references showing up in the traces. - return this.snapshots[0]; - } - if (i >= this.snapshots.length) - return this.snapshots[this.snapshots.length - 1]; - return this.snapshots[i]; - }, - - updateBounds: function() { - this.bounds.reset(); - this.bounds.addValue(this.creationTs); - if (this.deletionTs != Number.MAX_VALUE) - this.bounds.addValue(this.deletionTs); - else if (this.snapshots.length > 0) - this.bounds.addValue(this.snapshots[this.snapshots.length - 1].ts); - }, - - shiftTimestampsForward: function(amount) { - this.creationTs += amount; - if (this.deletionTs != Number.MAX_VALUE) - this.deletionTs += amount; - this.snapshots.forEach(function(snapshot) { - snapshot.ts += amount; - }); - }, - - get userFriendlyName() { - return this.typeName + ' object ' + this.scopedId; - } - }; - - tr.model.EventRegistry.register( - ObjectInstance, - { - name: 'objectInstance', - pluralName: 'objectInstances', - singleViewElementName: 'tr-ui-a-single-object-instance-sub-view', - multiViewElementName: 'tr-ui-a-multi-object-sub-view' - }); - - var options = new tr.b.ExtensionRegistryOptions( - tr.b.TYPE_BASED_REGISTRY_MODE); - options.mandatoryBaseClass = ObjectInstance; - options.defaultConstructor = ObjectInstance; - tr.b.decorateExtensionRegistry(ObjectInstance, options); - - return { - ObjectInstance: ObjectInstance - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/object_instance_test.html b/chromium/third_party/catapult/tracing/tracing/model/object_instance_test.html deleted file mode 100644 index fa02cff3945..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/object_instance_test.html +++ /dev/null @@ -1,70 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/object_instance.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('getSnapshotAtWithImplicitCreation', function() { - var instance = new tr.model.ObjectInstance( - {}, '0x1000', 'cat', 'n', 10); - var s10 = instance.addSnapshot(10, 'a'); - instance.addSnapshot(40, 'b'); - instance.wasDeleted(60); - - var s1 = instance.getSnapshotAt(1); - assert.equal(s1, s10); - - var s10 = instance.getSnapshotAt(10); - assert.equal(s10.args, 'a'); - assert.equal(instance.getSnapshotAt(15), s10); - - var s40 = instance.getSnapshotAt(40); - assert.equal(s40.args, 'b'); - assert.equal(instance.getSnapshotAt(50), s40); - assert.equal(instance.getSnapshotAt(59.9), s40); - }); - - test('getSnapshotAtWithExplicitCreation', function() { - var instance = new tr.model.ObjectInstance( - {}, '0x1000', 'cat', 'n', 10); - instance.creationTsWasExplicit = true; - instance.addSnapshot(10, 'a'); - instance.wasDeleted(60); - - assert.throws(function() { - instance.getSnapshotAt(1); - }); - - var s10 = instance.getSnapshotAt(10); - assert.equal(s10.args, 'a'); - assert.equal(instance.getSnapshotAt(15), s10); - }); - - test('getSnapshotBeforeFirstSnapshot', function() { - var instance = new tr.model.ObjectInstance( - {}, '0x1000', 'cat', 'n', 10); - var s15 = instance.addSnapshot(15, 'a'); - instance.wasDeleted(40); - - assert.equal(instance.getSnapshotAt(10), s15); - }); - - test('getSnapshotAfterLastSnapshot', function() { - var instance = new tr.model.ObjectInstance( - {}, '0x1000', 'cat', 'n', 10); - var s15 = instance.addSnapshot(15, 'a'); - instance.wasDeleted(40); - - assert.equal(instance.getSnapshotAt(20), s15); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/object_snapshot.html b/chromium/third_party/catapult/tracing/tracing/model/object_snapshot.html deleted file mode 100644 index eb9ca657db3..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/object_snapshot.html +++ /dev/null @@ -1,101 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/extension_registry.html"> -<link rel="import" href="/tracing/model/event.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - /** - * A snapshot of an object instance, at a given moment in time. - * - * Initialization of snapshots and instances is three phased: - * - * 1. Instances and snapshots are constructed. This happens during event - * importing. Little should be done here, because the object's data - * are still being used by the importer to reconstruct object references. - * - * 2. Instances and snapshtos are preinitialized. This happens after implicit - * objects have been found, but before any references have been found and - * switched to direct references. Thus, every snapshot stands on its own. - * This is a good time to do global field renaming and type conversion, - * e.g. recognizing domain-specific types and converting from C++ naming - * convention to JS. - * - * 3. Instances and snapshtos are initialized. At this point, {id_ref: - * '0x1000'} fields have been converted to snapshot references. This is a - * good time to generic initialization steps and argument verification. - * - * @constructor - */ - function ObjectSnapshot(objectInstance, ts, args) { - tr.model.Event.call(this); - this.objectInstance = objectInstance; - this.ts = ts; - this.args = args; - } - - ObjectSnapshot.prototype = { - __proto__: tr.model.Event.prototype, - - /** - * See ObjectSnapshot constructor notes on object initialization. - */ - preInitialize: function() { - }, - - /** - * See ObjectSnapshot constructor notes on object initialization. - */ - initialize: function() { - }, - - /** - * Called when an object reference is resolved as this ObjectSnapshot. - * @param {Object} item The event (async slice, slice or object) containing - * the resolved reference. - * @param {Object} object The object directly containing the reference. - * @param {String} field The field name of the reference in |object|. - */ - referencedAt: function(item, object, field) { - }, - - addBoundsToRange: function(range) { - range.addValue(this.ts); - }, - - get userFriendlyName() { - return 'Snapshot of ' + - this.objectInstance.typeName + ' ' + - this.objectInstance.id + ' @ ' + - tr.v.Unit.byName.timeStampInMs.format(this.ts); - } - }; - - tr.model.EventRegistry.register( - ObjectSnapshot, - { - name: 'objectSnapshot', - pluralName: 'objectSnapshots', - singleViewElementName: 'tr-ui-a-single-object-snapshot-sub-view', - multiViewElementName: 'tr-ui-a-multi-object-sub-view' - }); - - var options = new tr.b.ExtensionRegistryOptions( - tr.b.TYPE_BASED_REGISTRY_MODE); - options.mandatoryBaseClass = ObjectSnapshot; - options.defaultConstructor = ObjectSnapshot; - tr.b.decorateExtensionRegistry(ObjectSnapshot, options); - - return { - ObjectSnapshot: ObjectSnapshot - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/object_snapshot_test.html b/chromium/third_party/catapult/tracing/tracing/model/object_snapshot_test.html deleted file mode 100644 index 67c510248c7..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/object_snapshot_test.html +++ /dev/null @@ -1,40 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/object_instance.html"> -<link rel="import" href="/tracing/model/object_snapshot.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('snapshotTypeRegistry', function() { - function MySnapshot() { - tr.model.ObjectSnapshot.apply(this, arguments); - this.myFoo = this.args.foo; - } - - MySnapshot.prototype = { - __proto__: tr.model.ObjectSnapshot.prototype - }; - - var instance = new tr.model.ObjectInstance( - {}, '0x1000', 'cat', 'MySnapshot', 10); - try { - tr.model.ObjectSnapshot.register( - MySnapshot, - {typeName: 'MySnapshot'}); - var snapshot = instance.addSnapshot(15, {foo: 'bar'}); - assert.instanceOf(snapshot, MySnapshot); - assert.equal(snapshot.myFoo, 'bar'); - } finally { - tr.model.ObjectSnapshot.unregister(MySnapshot); - } - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/power_sample.html b/chromium/third_party/catapult/tracing/tracing/model/power_sample.html deleted file mode 100644 index 62de34ab591..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/power_sample.html +++ /dev/null @@ -1,74 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/event.html"> -<link rel="import" href="/tracing/model/event_registry.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - - var Event = tr.model.Event; - var EventRegistry = tr.model.EventRegistry; - - /** - * A sample that contains a power measurement (in mW). - * - * @constructor - * @extends {Event} - */ - function PowerSample(series, start, power) { - Event.call(this); - - this.series_ = series; - this.start_ = start; - this.power_ = power; - } - - PowerSample.prototype = { - __proto__: Event.prototype, - - get series() { - return this.series_; - }, - - get start() { - return this.start_; - }, - - set start(value) { - this.start_ = value; - }, - - get power() { - return this.power_; - }, - - set power(value) { - this.power_ = value; - }, - - addBoundsToRange: function(range) { - range.addValue(this.start); - } - }; - - EventRegistry.register( - PowerSample, - { - name: 'powerSample', - pluralName: 'powerSamples', - singleViewElementName: 'tr-ui-a-single-power-sample-sub-view', - multiViewElementName: 'tr-ui-a-multi-power-sample-sub-view' - }); - - return { - PowerSample: PowerSample - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/power_sample_test.html b/chromium/third_party/catapult/tracing/tracing/model/power_sample_test.html deleted file mode 100644 index 6625ed4ed59..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/power_sample_test.html +++ /dev/null @@ -1,52 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/power_sample.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - - var PowerSample = tr.model.PowerSample; - - test('powerSample', function() { - var series = new tr.model.PowerSeries(new tr.Model().device); - - var sample1 = new PowerSample(series, 0.0, 1000.0); - var sample2 = new PowerSample(series, 1.0, 2000.0); - - assert.equal(sample1.series, series); - assert.equal(sample1.start, 0.0); - assert.equal(sample1.power, 1000.0); - - assert.equal(sample2.series, series); - assert.equal(sample2.start, 1.0); - assert.equal(sample2.power, 2000.0); - }); - - test('addBoundsToRange', function() { - var series = new tr.model.PowerSeries(new tr.Model().device); - - var sample1 = new PowerSample(series, 0.0, 1000.0); - var sample2 = new PowerSample(series, 1.0, 2000.0); - - var range = new tr.b.Range(); - sample1.addBoundsToRange(range); - - assert.equal(range.min, 0); - assert.equal(range.max, 0); - - sample2.addBoundsToRange(range); - - assert.equal(range.min, 0); - assert.equal(range.max, 1); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/power_series.html b/chromium/third_party/catapult/tracing/tracing/model/power_series.html deleted file mode 100644 index f3a873bab50..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/power_series.html +++ /dev/null @@ -1,126 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/base/sorted_array_utils.html"> -<link rel="import" href="/tracing/model/event_container.html"> -<link rel="import" href="/tracing/model/power_sample.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - - var PowerSample = tr.model.PowerSample; - - /** - * A container holding a time series of power samples. - * - * @constructor - * @extends {EventContainer} - */ - function PowerSeries(device) { - tr.model.EventContainer.call(this); - - this.device_ = device; - this.samples_ = []; - } - - PowerSeries.prototype = { - __proto__: tr.model.EventContainer.prototype, - - get device() { - return this.device_; - }, - - get samples() { - return this.samples_; - }, - - get stableId() { - return this.device_.stableId + '.PowerSeries'; - }, - - /** - * Adds a power sample to the series and returns it. - * - * Note: Samples must be added in chronological order. - */ - addPowerSample: function(ts, val) { - var sample = new PowerSample(this, ts, val); - this.samples_.push(sample); - return sample; - }, - - /** - * Returns the total energy (in Joules) consumed between the specified - * start and end timestamps (in milliseconds). - */ - getEnergyConsumed: function(start, end) { - var measurementRange = tr.b.Range.fromExplicitRange(start, end); - - var energyConsumed = 0; - var startIndex = tr.b.findLowIndexInSortedArray( - this.samples, x => x.start, start) - 1; - var endIndex = tr.b.findLowIndexInSortedArray( - this.samples, x => x.start, end); - - if (startIndex < 0) - startIndex = 0; - - for (var i = startIndex; i < endIndex; i++) { - var sample = this.samples[i]; - var nextSample = this.samples[i + 1]; - - var sampleRange = new tr.b.Range(); - sampleRange.addValue(sample.start); - sampleRange.addValue(nextSample ? nextSample.start : sample.start); - - var timeIntersection = measurementRange.findIntersection(sampleRange); - - // Divide by 1000 to convert milliseconds to seconds. - var durationInSeconds = timeIntersection.duration / 1000; - - energyConsumed += durationInSeconds * sample.power; - } - - return energyConsumed; - }, - - getSamplesWithinRange: function(start, end) { - var startIndex = tr.b.findLowIndexInSortedArray( - this.samples, x => x.start, start); - var endIndex = tr.b.findLowIndexInSortedArray( - this.samples, x => x.start, end); - return this.samples.slice(startIndex, endIndex); - }, - - shiftTimestampsForward: function(amount) { - for (var i = 0; i < this.samples_.length; ++i) - this.samples_[i].start += amount; - }, - - updateBounds: function() { - this.bounds.reset(); - - if (this.samples_.length === 0) - return; - - this.bounds.addValue(this.samples_[0].start); - this.bounds.addValue(this.samples_[this.samples_.length - 1].start); - }, - - childEvents: function*() { - yield * this.samples_; - }, - }; - - return { - PowerSeries: PowerSeries - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/power_series_test.html b/chromium/third_party/catapult/tracing/tracing/model/power_series_test.html deleted file mode 100644 index 034cae8b786..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/power_series_test.html +++ /dev/null @@ -1,150 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/device.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/power_series.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - - var Model = tr.Model; - var PowerSeries = tr.model.PowerSeries; - - test('stableId', function() { - var device = { stableId: 'test' }; - var series = new PowerSeries(device); - - assert.equal(series.stableId, 'test.PowerSeries'); - }); - - test('device', function() { - var device = new tr.model.Device(new Model()); - var series = new PowerSeries(device); - - assert.equal(series.device, device); - }); - - test('addPowerSample', function() { - var series = new PowerSeries(new Model().device); - - assert.equal(series.samples.length, 0); - - var sample1 = series.addPowerSample(0, 1); - var sample2 = series.addPowerSample(1, 2); - - assert.deepEqual(series.samples, [sample1, sample2]); - }); - - test('getEnergyConsumed_oneInterval', function() { - var series = new PowerSeries(new Model().device); - series.addPowerSample(0, 1); - series.addPowerSample(1000, 2); - - assert.equal(series.getEnergyConsumed(0, 1000), 1); - }); - - test('getEnergyConsumed_twoIntervals', function() { - var series = new PowerSeries(new Model().device); - series.addPowerSample(0, 1); - series.addPowerSample(1000, 2); - series.addPowerSample(2000, 2); - - assert.equal(series.getEnergyConsumed(0, 2000), 3); - }); - - test('getEnergyConsumed_oneSample', function() { - var series = new PowerSeries(new Model().device); - series.addPowerSample(1000, 1); - - assert.equal(series.getEnergyConsumed(0, 2000), 0); - }); - - test('getEnergyConsumed_samplesAfterStart', function() { - var series = new PowerSeries(new Model().device); - series.addPowerSample(1000, 1); - series.addPowerSample(2000, 2); - - assert.equal(series.getEnergyConsumed(0, 2000), 1); - }); - - test('getEnergyConsumed_extraSamplesBeforeStart', function() { - var series = new PowerSeries(new Model().device); - series.addPowerSample(0, 10); - series.addPowerSample(1000, 1); - series.addPowerSample(2000, 1); - series.addPowerSample(3000, 1); - - assert.equal(series.getEnergyConsumed(2000, 4000), 1); - }); - - test('getEnergyConsumed_extraSamplesAfterEnd', function() { - var series = new PowerSeries(new Model().device); - series.addPowerSample(0, 1); - series.addPowerSample(1000, 1); - series.addPowerSample(2000, 1); - series.addPowerSample(3000, 10); - - assert.equal(series.getEnergyConsumed(0, 2000), 2); - }); - - test('shiftTimestampsForward', function() { - var series = new PowerSeries(new Model().device); - - series.addPowerSample(0, 1); - series.addPowerSample(1, 2); - - series.shiftTimestampsForward(2); - - assert.equal(series.samples[0].start, 2); - assert.equal(series.samples[1].start, 3); - - series.shiftTimestampsForward(-4); - - assert.equal(series.samples[0].start, -2); - assert.equal(series.samples[1].start, -1); - }); - - - test('updateBounds', function() { - var series = new PowerSeries(new Model().device); - - series.addPowerSample(0, 1); - series.addPowerSample(1, 2); - series.updateBounds(); - - assert.equal(series.bounds.min, 0); - assert.equal(series.bounds.max, 1); - - series.addPowerSample(4, 3); - series.updateBounds(); - - assert.equal(series.bounds.min, 0); - assert.equal(series.bounds.max, 4); - }); - - test('childEvents_empty', function() { - var series = new PowerSeries(new Model().device); - var eventsInSeries = []; - for (var event of series.childEvents()) - eventsInSeries.push(event); - assert.deepEqual(eventsInSeries, []); - }); - - test('childEvents_nonempty', function() { - var series = new PowerSeries(new Model().device); - var sample1 = series.addPowerSample(0, 1); - var sample2 = series.addPowerSample(1, 2); - var eventsInSeries = []; - for (var event of series.childEvents()) - eventsInSeries.push(event); - assert.deepEqual(eventsInSeries, [sample1, sample2]); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/process.html b/chromium/third_party/catapult/tracing/tracing/model/process.html deleted file mode 100644 index 47ed4100427..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/process.html +++ /dev/null @@ -1,160 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/process_base.html"> -<link rel="import" href="/tracing/model/process_memory_dump.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the Process class. - */ -tr.exportTo('tr.model', function() { - var ProcessBase = tr.model.ProcessBase; - var ProcessInstantEvent = tr.model.ProcessInstantEvent; - var Frame = tr.model.Frame; - var ProcessMemoryDump = tr.model.ProcessMemoryDump; - - /** - * The Process represents a single userland process in the - * trace. - * @constructor - */ - function Process(model, pid) { - if (model === undefined) - throw new Error('model must be provided'); - if (pid === undefined) - throw new Error('pid must be provided'); - tr.model.ProcessBase.call(this, model); - this.pid = pid; - this.name = undefined; - this.labels = []; - this.instantEvents = []; - this.memoryDumps = []; - this.frames = []; - this.activities = []; - }; - - /** - * Comparison between processes that orders by pid. - */ - Process.compare = function(x, y) { - var tmp = tr.model.ProcessBase.compare(x, y); - if (tmp) - return tmp; - - tmp = tr.b.comparePossiblyUndefinedValues( - x.name, y.name, - function(x, y) { return x.localeCompare(y); }); - if (tmp) - return tmp; - - tmp = tr.b.compareArrays(x.labels, y.labels, - function(x, y) { return x.localeCompare(y); }); - if (tmp) - return tmp; - - return x.pid - y.pid; - }; - - Process.prototype = { - __proto__: tr.model.ProcessBase.prototype, - - get stableId() { - return this.pid; - }, - - compareTo: function(that) { - return Process.compare(this, that); - }, - - childEvents: function*() { - yield * ProcessBase.prototype.childEvents.call(this); - yield * this.instantEvents; - yield * this.frames; - yield * this.memoryDumps; - }, - - addLabelIfNeeded: function(labelName) { - for (var i = 0; i < this.labels.length; i++) { - if (this.labels[i] === labelName) - return; - } - this.labels.push(labelName); - }, - - get userFriendlyName() { - var res; - if (this.name) - res = this.name + ' (pid ' + this.pid + ')'; - else - res = 'Process ' + this.pid; - if (this.labels.length) - res += ': ' + this.labels.join(', '); - return res; - }, - - get userFriendlyDetails() { - if (this.name) - return this.name + ' (pid ' + this.pid + ')'; - return 'pid: ' + this.pid; - }, - - getSettingsKey: function() { - if (!this.name) - return undefined; - if (!this.labels.length) - return 'processes.' + this.name; - return 'processes.' + this.name + '.' + this.labels.join('.'); - }, - - shiftTimestampsForward: function(amount) { - for (var i = 0; i < this.instantEvents.length; i++) - this.instantEvents[i].start += amount; - - for (var i = 0; i < this.frames.length; i++) - this.frames[i].shiftTimestampsForward(amount); - - for (var i = 0; i < this.memoryDumps.length; i++) - this.memoryDumps[i].shiftTimestampsForward(amount); - - for (var i = 0; i < this.activities.length; i++) - this.activities[i].shiftTimestampsForward(amount); - - tr.model.ProcessBase.prototype - .shiftTimestampsForward.apply(this, arguments); - }, - - updateBounds: function() { - tr.model.ProcessBase.prototype.updateBounds.apply(this); - - for (var i = 0; i < this.frames.length; i++) - this.frames[i].addBoundsToRange(this.bounds); - - for (var i = 0; i < this.memoryDumps.length; i++) - this.memoryDumps[i].addBoundsToRange(this.bounds); - - for (var i = 0; i < this.activities.length; i++) - this.activities[i].addBoundsToRange(this.bounds); - }, - - sortMemoryDumps: function() { - this.memoryDumps.sort(function(x, y) { - return x.start - y.start; - }); - tr.model.ProcessMemoryDump.hookUpMostRecentVmRegionsLinks( - this.memoryDumps); - } - }; - - return { - Process: Process - }; -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/process_base.html b/chromium/third_party/catapult/tracing/tracing/model/process_base.html deleted file mode 100644 index 92aa673090f..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/process_base.html +++ /dev/null @@ -1,236 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/guid.html"> -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/model/counter.html"> -<link rel="import" href="/tracing/model/event_container.html"> -<link rel="import" href="/tracing/model/object_collection.html"> -<link rel="import" href="/tracing/model/thread.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the ProcessBase class. - */ -tr.exportTo('tr.model', function() { - - var Thread = tr.model.Thread; - var Counter = tr.model.Counter; - - /** - * The ProcessBase is a partial base class, upon which Kernel - * and Process are built. - * - * @constructor - * @extends {tr.model.EventContainer} - */ - function ProcessBase(model) { - if (!model) - throw new Error('Must provide a model'); - tr.model.EventContainer.call(this); - this.model = model; - this.threads = {}; - this.counters = {}; - this.objects = new tr.model.ObjectCollection(this); - this.sortIndex = 0; - }; - - ProcessBase.compare = function(x, y) { - return x.sortIndex - y.sortIndex; - }; - - ProcessBase.prototype = { - __proto__: tr.model.EventContainer.prototype, - - get stableId() { - throw new Error('Not implemented'); - }, - - childEventContainers: function*() { - yield * tr.b.dictionaryValues(this.threads); - yield * tr.b.dictionaryValues(this.counters); - yield this.objects; - }, - - iterateAllPersistableObjects: function(cb) { - cb(this); - for (var tid in this.threads) - this.threads[tid].iterateAllPersistableObjects(cb); - }, - - /** - * Gets the number of threads in this process. - */ - get numThreads() { - var n = 0; - for (var p in this.threads) { - n++; - } - return n; - }, - - /** - * Shifts all the timestamps inside this process forward by the amount - * specified. - */ - shiftTimestampsForward: function(amount) { - for (var child of this.childEventContainers()) - child.shiftTimestampsForward(amount); - }, - - /** - * Closes any open slices. - */ - autoCloseOpenSlices: function() { - for (var tid in this.threads) { - var thread = this.threads[tid]; - thread.autoCloseOpenSlices(); - } - }, - - autoDeleteObjects: function(maxTimestamp) { - this.objects.autoDeleteObjects(maxTimestamp); - }, - - /** - * Called by the model after finalizing imports, - * but before joining refs. - */ - preInitializeObjects: function() { - this.objects.preInitializeAllObjects(); - }, - - /** - * Called by the model after joining refs. - */ - initializeObjects: function() { - this.objects.initializeAllObjects(); - }, - - /** - * Merge slices from the kernel with those from userland for each thread. - */ - mergeKernelWithUserland: function() { - for (var tid in this.threads) { - var thread = this.threads[tid]; - thread.mergeKernelWithUserland(); - } - }, - - updateBounds: function() { - this.bounds.reset(); - for (var tid in this.threads) { - this.threads[tid].updateBounds(); - this.bounds.addRange(this.threads[tid].bounds); - } - for (var id in this.counters) { - this.counters[id].updateBounds(); - this.bounds.addRange(this.counters[id].bounds); - } - this.objects.updateBounds(); - this.bounds.addRange(this.objects.bounds); - }, - - addCategoriesToDict: function(categoriesDict) { - for (var tid in this.threads) - this.threads[tid].addCategoriesToDict(categoriesDict); - for (var id in this.counters) - categoriesDict[this.counters[id].category] = true; - this.objects.addCategoriesToDict(categoriesDict); - }, - - findAllThreadsMatching: function(predicate, opt_this) { - var threads = []; - for (var tid in this.threads) { - var thread = this.threads[tid]; - if (predicate.call(opt_this, thread)) - threads.push(thread); - } - return threads; - }, - - /** - * @param {String} The name of the thread to find. - * @return {Array} An array of all the matched threads. - */ - findAllThreadsNamed: function(name) { - var threads = this.findAllThreadsMatching(function(thread) { - if (!thread.name) - return false; - return thread.name === name; - }); - return threads; - }, - - findAtMostOneThreadNamed: function(name) { - var threads = this.findAllThreadsNamed(name); - if (threads.length === 0) - return undefined; - if (threads.length > 1) - throw new Error('Expected no more than one ' + name); - return threads[0]; - }, - - /** - * Removes threads from the process that are fully empty. - */ - pruneEmptyContainers: function() { - var threadsToKeep = {}; - for (var tid in this.threads) { - var thread = this.threads[tid]; - if (!thread.isEmpty) - threadsToKeep[tid] = thread; - } - this.threads = threadsToKeep; - }, - - /** - * @return {TimelineThread} The thread identified by tid on this process, - * or undefined if it doesn't exist. - */ - getThread: function(tid) { - return this.threads[tid]; - }, - - /** - * @return {TimelineThread} The thread identified by tid on this process, - * creating it if it doesn't exist. - */ - getOrCreateThread: function(tid) { - if (!this.threads[tid]) - this.threads[tid] = new Thread(this, tid); - return this.threads[tid]; - }, - - /** - * @return {Counter} The counter on this process with the given - * category/name combination, creating it if it doesn't exist. - */ - getOrCreateCounter: function(cat, name) { - var id = cat + '.' + name; - if (!this.counters[id]) - this.counters[id] = new Counter(this, id, cat, name); - return this.counters[id]; - }, - - getSettingsKey: function() { - throw new Error('Not implemented'); - }, - - createSubSlices: function() { - for (var tid in this.threads) - this.threads[tid].createSubSlices(); - } - }; - - return { - ProcessBase: ProcessBase - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/process_memory_dump.html b/chromium/third_party/catapult/tracing/tracing/model/process_memory_dump.html deleted file mode 100644 index c9d60715703..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/process_memory_dump.html +++ /dev/null @@ -1,246 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/container_memory_dump.html"> -<link rel="import" href="/tracing/model/memory_allocator_dump.html"> -<link rel="import" href="/tracing/model/vm_region.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the ProcessMemoryDump class. - */ -tr.exportTo('tr.model', function() { - - // Names of MemoryAllocatorDump(s) from which tracing overhead should be - // discounted. - var DISCOUNTED_ALLOCATOR_NAMES = ['winheap', 'malloc']; - - // The path to where the tracing overhead dump should be added to the - // winheap/malloc allocator dump tree. - var TRACING_OVERHEAD_PATH = ['allocated_objects', 'tracing_overhead']; - - var SIZE_NUMERIC_NAME = tr.model.MemoryAllocatorDump.SIZE_NUMERIC_NAME; - var RESIDENT_SIZE_NUMERIC_NAME = - tr.model.MemoryAllocatorDump.RESIDENT_SIZE_NUMERIC_NAME; - - function getSizeNumericValue(dump, sizeNumericName) { - var sizeNumeric = dump.numerics[sizeNumericName]; - if (sizeNumeric === undefined) - return 0; - return sizeNumeric.value; - } - - /** - * The ProcessMemoryDump represents a memory dump of a single process. - * @constructor - */ - function ProcessMemoryDump(globalMemoryDump, process, start) { - tr.model.ContainerMemoryDump.call(this, start); - this.process = process; - this.globalMemoryDump = globalMemoryDump; - - // Process memory totals (optional object) with the following fields (also - // optional): - // - residentBytes: Total resident bytes (number) - // - peakResidentBytes: Peak resident bytes (number) - // - arePeakResidentBytesResettable: Flag whether peak resident bytes are - // resettable (boolean) - // - platformSpecific: Map from OS-specific total names (string) to sizes - // (number) - this.totals = undefined; - - this.vmRegions = undefined; - - // Map from allocator names to heap dumps. - this.heapDumps = undefined; - - this.tracingOverheadOwnershipSetUp_ = false; - this.tracingOverheadDiscountedFromVmRegions_ = false; - }; - - ProcessMemoryDump.prototype = { - __proto__: tr.model.ContainerMemoryDump.prototype, - - get userFriendlyName() { - return 'Process memory dump at ' + - tr.v.Unit.byName.timeStampInMs.format(this.start); - }, - - get containerName() { - return this.process.userFriendlyName; - }, - - get processMemoryDumps() { - var dumps = {}; - dumps[this.process.pid] = this; - return dumps; - }, - - get hasOwnVmRegions() { - return this.vmRegions !== undefined; - }, - - setUpTracingOverheadOwnership: function(opt_model) { - // Make sure that calling this method twice won't lead to - // 'double-discounting'. - if (this.tracingOverheadOwnershipSetUp_) - return; - this.tracingOverheadOwnershipSetUp_ = true; - - var tracingDump = this.getMemoryAllocatorDumpByFullName('tracing'); - if (tracingDump === undefined || tracingDump.owns !== undefined) { - // The tracing dump either doesn't exist, or it already owns another - // dump. - return; - } - - if (tracingDump.owns !== undefined) - return; - - // Add an ownership link from tracing to - // malloc/allocated_objects/tracing_overhead or - // winheap/allocated_objects/tracing_overhead. - var hasDiscountedFromAllocatorDumps = DISCOUNTED_ALLOCATOR_NAMES.some( - function(allocatorName) { - // First check if the allocator root exists. - var allocatorDump = this.getMemoryAllocatorDumpByFullName( - allocatorName); - if (allocatorDump === undefined) - return false; // Allocator doesn't exist, try another one. - - var nextPathIndex = 0; - var currentDump = allocatorDump; - var currentFullName = allocatorName; - - // Descend from the root towards tracing_overhead as long as the dumps - // on the path exist. - for (; nextPathIndex < TRACING_OVERHEAD_PATH.length; nextPathIndex++) { - var childFullName = currentFullName + '/' + - TRACING_OVERHEAD_PATH[nextPathIndex]; - var childDump = this.getMemoryAllocatorDumpByFullName( - childFullName); - if (childDump === undefined) - break; - - currentDump = childDump; - currentFullName = childFullName; - } - - // Create the missing descendant dumps on the path from the root - // towards tracing_overhead. - for (; nextPathIndex < TRACING_OVERHEAD_PATH.length; nextPathIndex++) { - var childFullName = currentFullName + '/' + - TRACING_OVERHEAD_PATH[nextPathIndex]; - var childDump = new tr.model.MemoryAllocatorDump( - currentDump.containerMemoryDump, childFullName); - childDump.parent = currentDump; - currentDump.children.push(childDump); - - currentFullName = childFullName; - currentDump = childDump; - } - - // Add the ownership link. - var ownershipLink = - new tr.model.MemoryAllocatorDumpLink(tracingDump, currentDump); - tracingDump.owns = ownershipLink; - currentDump.ownedBy.push(ownershipLink); - return true; - }, this); - - // Force rebuilding the memory allocator dump index (if we've just added - // a new memory allocator dump). - if (hasDiscountedFromAllocatorDumps) - this.forceRebuildingMemoryAllocatorDumpByFullNameIndex(); - }, - - discountTracingOverheadFromVmRegions: function(opt_model) { - // Make sure that calling this method twice won't lead to - // 'double-discounting'. - if (this.tracingOverheadDiscountedFromVmRegions_) - return; - this.tracingOverheadDiscountedFromVmRegions_ = true; - - var tracingDump = this.getMemoryAllocatorDumpByFullName('tracing'); - if (tracingDump === undefined) - return; - - var discountedSize = - getSizeNumericValue(tracingDump, SIZE_NUMERIC_NAME); - var discountedResidentSize = - getSizeNumericValue(tracingDump, RESIDENT_SIZE_NUMERIC_NAME); - - if (discountedSize <= 0 && discountedResidentSize <= 0) - return; - - // Subtract the tracing size from the totals. - if (this.totals !== undefined) { - if (this.totals.residentBytes !== undefined) - this.totals.residentBytes -= discountedResidentSize; - if (this.totals.peakResidentBytes !== undefined) - this.totals.peakResidentBytes -= discountedResidentSize; - } - - // Subtract the tracing size from VM regions. More precisely, subtract - // tracing resident_size from byte stats (private dirty and PSS) and - // tracing size from virtual size by injecting a fake VM region with - // negative values. - if (this.vmRegions !== undefined) { - var hasSizeInBytes = this.vmRegions.sizeInBytes !== undefined; - var hasPrivateDirtyResident = - this.vmRegions.byteStats.privateDirtyResident !== undefined; - var hasProportionalResident = - this.vmRegions.byteStats.proportionalResident !== undefined; - - if ((hasSizeInBytes && discountedSize > 0) || - ((hasPrivateDirtyResident || hasProportionalResident) && - discountedResidentSize > 0)) { - var byteStats = {}; - if (hasPrivateDirtyResident) - byteStats.privateDirtyResident = -discountedResidentSize; - if (hasProportionalResident) - byteStats.proportionalResident = -discountedResidentSize; - this.vmRegions.addRegion(tr.model.VMRegion.fromDict({ - mappedFile: '[discounted tracing overhead]', - sizeInBytes: hasSizeInBytes ? -discountedSize : undefined, - byteStats: byteStats - })); - } - } - } - }; - - ProcessMemoryDump.hookUpMostRecentVmRegionsLinks = function(processDumps) { - var mostRecentVmRegions = undefined; - - processDumps.forEach(function(processDump) { - // Update the most recent VM regions from the current dump. - if (processDump.vmRegions !== undefined) - mostRecentVmRegions = processDump.vmRegions; - - // Set the most recent VM regions of the current dump. - processDump.mostRecentVmRegions = mostRecentVmRegions; - }); - }; - - tr.model.EventRegistry.register( - ProcessMemoryDump, - { - name: 'processMemoryDump', - pluralName: 'processMemoryDumps', - singleViewElementName: 'tr-ui-a-container-memory-dump-sub-view', - multiViewElementName: 'tr-ui-a-container-memory-dump-sub-view' - }); - - return { - ProcessMemoryDump: ProcessMemoryDump - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/process_memory_dump_test.html b/chromium/third_party/catapult/tracing/tracing/model/process_memory_dump_test.html deleted file mode 100644 index 4b1c2a32c71..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/process_memory_dump_test.html +++ /dev/null @@ -1,553 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/global_memory_dump.html"> -<link rel="import" href="/tracing/model/memory_dump_test_utils.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/process_memory_dump.html"> -<link rel="import" href="/tracing/model/vm_region.html"> -<link rel="import" href="/tracing/value/numeric.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var GlobalMemoryDump = tr.model.GlobalMemoryDump; - var ProcessMemoryDump = tr.model.ProcessMemoryDump; - var VMRegion = tr.model.VMRegion; - var VMRegionClassificationNode = tr.model.VMRegionClassificationNode; - var ScalarNumeric = tr.v.ScalarNumeric; - var unitlessNumber_smallerIsBetter = - tr.v.Unit.byName.unitlessNumber_smallerIsBetter; - var newAllocatorDump = tr.model.MemoryDumpTestUtils.newAllocatorDump; - var addChildDump = tr.model.MemoryDumpTestUtils.addChildDump; - var addOwnershipLink = tr.model.MemoryDumpTestUtils.addOwnershipLink; - var checkDumpNumericsAndDiagnostics = - tr.model.MemoryDumpTestUtils.checkDumpNumericsAndDiagnostics; - var checkVMRegions = tr.model.MemoryDumpTestUtils.checkVMRegions; - - function createClassificationNode(opt_sizeInBytes, opt_byteStats) { - var node = new VMRegionClassificationNode(); - if (opt_sizeInBytes !== undefined || opt_byteStats !== undefined) { - node.addRegion(VMRegion.fromDict({ - mappedFile: 'mock.so', - sizeInBytes: opt_sizeInBytes, - byteStats: opt_byteStats - })); - } - return node; - } - - function createProcessMemoryDump(timestamp, model) { - var gmd = new GlobalMemoryDump(model, timestamp); - model.globalMemoryDumps.push(gmd); - var p = model.getOrCreateProcess(123); - var pmd = new ProcessMemoryDump(gmd, p, timestamp + 1); - gmd.processMemoryDumps[123] = pmd; - p.memoryDumps.push(pmd); - return pmd; - } - - function createFinalizedProcessMemoryDump(timestamp, opt_createdCallback) { - return createFinalizedProcessMemoryDumps([timestamp], function(pmds) { - if (opt_createdCallback !== undefined) - opt_createdCallback(pmds[0]); - })[0]; - } - - function createFinalizedProcessMemoryDumps(timestamps, createdCallback) { - var model = tr.c.TestUtils.newModel(function(model) { - var pmds = timestamps.map(function(timestamp) { - return createProcessMemoryDump(timestamp, model); - }); - createdCallback(pmds); - }); - var pmds = model.getProcess(123).memoryDumps; - assert.lengthOf(pmds, timestamps.length); - return pmds; - } - - test('processMemoryDumps', function() { - var pmd = createFinalizedProcessMemoryDump(42); - var pmds = pmd.processMemoryDumps; - assert.lengthOf(Object.keys(pmds), 1); - assert.strictEqual(pmds[123], pmd); - }); - - test('hookUpMostRecentVmRegionsLinks_emptyArray', function() { - var dumps = []; - ProcessMemoryDump.hookUpMostRecentVmRegionsLinks(dumps); - assert.lengthOf(dumps, 0); - }); - - test('hookUpMostRecentVmRegionsLinks_nonEmptyArray', function() { - var m = new tr.Model(); - - // A dump with no VM regions or allocator dumps. - var dump1 = createProcessMemoryDump(1, m); - - // A dump with VM regions and malloc and Oilpan allocator dumps. - var dump2 = createProcessMemoryDump(2, m); - dump2.vmRegions = createClassificationNode(); - dump2.memoryAllocatorDumps = [ - newAllocatorDump(dump2, 'oilpan', { - size: 1024, - objects_count: new ScalarNumeric(unitlessNumber_smallerIsBetter, 7), - inner_size: 768 - }), - newAllocatorDump(dump2, 'v8', { - size: 2048, - objects_count: new ScalarNumeric(unitlessNumber_smallerIsBetter, 15), - inner_size: 1999 - }) - ]; - - // A dump with malloc and V8 allocator dumps. - var dump3 = createProcessMemoryDump(3, m); - dump3.memoryAllocatorDumps = [ - newAllocatorDump(dump3, 'malloc', { - size: 1024, - objects_count: new ScalarNumeric(unitlessNumber_smallerIsBetter, 7), - inner_size: 768 - }), - newAllocatorDump(dump3, 'v8', { - size: 2048, - objects_count: new ScalarNumeric(unitlessNumber_smallerIsBetter, 15), - inner_size: 1999 - }) - ]; - - // A dump with VM regions. - var dump4 = createProcessMemoryDump(4, m); - dump4.vmRegions = createClassificationNode(); - - var dumps = [dump1, dump2, dump3, dump4]; - ProcessMemoryDump.hookUpMostRecentVmRegionsLinks(dumps); - - assert.lengthOf(dumps, 4); - - assert.equal(dumps[0], dump1); - assert.isUndefined(dump1.mostRecentVmRegions); - - assert.equal(dumps[1], dump2); - assert.equal(dump2.mostRecentVmRegions, dump2.vmRegions); - - assert.equal(dumps[2], dump3); - assert.equal(dump3.mostRecentVmRegions, dump2.vmRegions); - - assert.equal(dumps[3], dump4); - assert.equal(dump4.mostRecentVmRegions, dump4.vmRegions); - }); - - test('checkDiscountTracingOverhead_undefinedFields', function() { - var pmd = createFinalizedProcessMemoryDump(42, function(pmd) { - pmd.memoryAllocatorDumps = [ - newAllocatorDump(pmd, 'v8', { size: 2048 }), - newAllocatorDump(pmd, 'tracing', { size: 1024 }) - ]; - }); - - assert.isUndefined(pmd.totals); - assert.isUndefined(pmd.vmRegions); - - var v8Dump = pmd.getMemoryAllocatorDumpByFullName('v8'); - checkDumpNumericsAndDiagnostics(v8Dump, { - 'size': 2048, - 'effective_size': 2048 - }, {}); - - var tracingDump = pmd.getMemoryAllocatorDumpByFullName('tracing'); - checkDumpNumericsAndDiagnostics(tracingDump, { - 'size': 1024, - 'effective_size': 1024 - }, {}); - }); - - test('checkDiscountTracingOverhead_definedFields', function() { - var pmd = createFinalizedProcessMemoryDump(42, function(pmd) { - pmd.totals = { residentBytes: 10240 }; - pmd.vmRegions = createClassificationNode(6000, { - privateDirtyResident: 4096, - proportionalResident: 5120, - swapped: 1536 - }); - - var mallocDump = newAllocatorDump(pmd, 'malloc', { size: 3072 }); - addChildDump(mallocDump, 'allocated_objects', { size: 2560 }); - - var tracingDump = newAllocatorDump( - pmd, 'tracing', { size: 1024, resident_size: 1000 }); - - pmd.memoryAllocatorDumps = [mallocDump, tracingDump]; - }); - - assert.equal(pmd.totals.residentBytes, 9240); - assert.isUndefined(pmd.totals.peakResidentBytes); - - var vmRegions = pmd.vmRegions; - assert.strictEqual(vmRegions.sizeInBytes, 4976); - assert.deepEqual(vmRegions.byteStats, { - privateDirtyResident: 3096, - proportionalResident: 4120, - swapped: 1536 - }); - - checkVMRegions(vmRegions, [ - { - mappedFile: 'mock.so', - sizeInBytes: 6000, - byteStats: { - privateDirtyResident: 4096, - proportionalResident: 5120, - swapped: 1536 - } - }, - { - mappedFile: '[discounted tracing overhead]', - sizeInBytes: -1024, - byteStats: { - privateDirtyResident: -1000, - proportionalResident: -1000 - } - } - ]); - - var mallocDump = pmd.getMemoryAllocatorDumpByFullName('malloc'); - checkDumpNumericsAndDiagnostics(mallocDump, { - 'size': 3072, - 'effective_size': 2048 - }, {}); - assert.lengthOf( - mallocDump.children, 2 /* 'allocated_objects' and '<unspecified>' */); - - var allocatedObjectsDump = pmd.getMemoryAllocatorDumpByFullName( - 'malloc/allocated_objects'); - checkDumpNumericsAndDiagnostics(allocatedObjectsDump, { - 'size': 2560, - 'effective_size': 1536 - }, {}); - assert.lengthOf( - allocatedObjectsDump.children, - 2 /* 'tracing_overhead' and '<unspecified>' */); - - var discountDump = pmd.getMemoryAllocatorDumpByFullName( - 'malloc/allocated_objects/tracing_overhead'); - assert.strictEqual(discountDump.parent, allocatedObjectsDump); - assert.include(allocatedObjectsDump.children, discountDump); - checkDumpNumericsAndDiagnostics(discountDump, { - 'size': 1024, - 'effective_size': 0 - }, {}); - - var tracingDump = pmd.getMemoryAllocatorDumpByFullName('tracing'); - checkDumpNumericsAndDiagnostics(tracingDump, { - 'size': 1024, - 'effective_size': 1024, - 'resident_size': 1000 - }, {}); - assert.strictEqual(tracingDump.owns.target, discountDump); - }); - - test('checkDiscountTracingOverhead_winheap', function() { - var pmd = createFinalizedProcessMemoryDump(42, function(pmd) { - pmd.memoryAllocatorDumps = [ - newAllocatorDump(pmd, 'tracing', { size: 2048 }), - newAllocatorDump(pmd, 'winheap', { size: 5120 }) - ]; - }); - - assert.isUndefined(pmd.totals); - assert.isUndefined(pmd.vmRegions); - - var winheapDump = pmd.getMemoryAllocatorDumpByFullName('winheap'); - checkDumpNumericsAndDiagnostics(winheapDump, { - 'size': 5120, - 'effective_size': 3072 - }, {}); - assert.lengthOf(winheapDump.children, - 2 /* 'allocated_objects' and '<unspecified>' */); - - var allocatedObjectsDump = pmd.getMemoryAllocatorDumpByFullName( - 'winheap/allocated_objects'); - checkDumpNumericsAndDiagnostics(allocatedObjectsDump, { - 'size': 2048, - 'effective_size': 0 - }, {}); - assert.lengthOf( - allocatedObjectsDump.children, 1 /* 'tracing_overhead' */); - - var discountDump = pmd.getMemoryAllocatorDumpByFullName( - 'winheap/allocated_objects/tracing_overhead'); - assert.strictEqual(discountDump.parent, allocatedObjectsDump); - assert.include(allocatedObjectsDump.children, discountDump); - checkDumpNumericsAndDiagnostics(discountDump, { - 'size': 2048, - 'effective_size': 0 - }, {}); - - var tracingDump = pmd.getMemoryAllocatorDumpByFullName('tracing'); - checkDumpNumericsAndDiagnostics(tracingDump, { - 'size': 2048, - 'effective_size': 2048 - }, {}); - assert.strictEqual(tracingDump.owns.target, discountDump); - }); - - test('checkDiscountTracingOverhead_withMostRecentVmRegionsLinks', function() { - var pmds = createFinalizedProcessMemoryDumps([42, 90], function(pmds) { - pmds[0].totals = { residentBytes: 1000, peakResidentBytes: 2000 }; - pmds[0].vmRegions = createClassificationNode(6000, { - privateDirtyResident: 4096 - }); - pmds[0].memoryAllocatorDumps = [ - newAllocatorDump(pmds[0], 'tracing', { size: 300, resident_size: 100 }) - ]; - - pmds[1].totals = { peakResidentBytes: 3000 }; - pmds[1].memoryAllocatorDumps = [ - newAllocatorDump(pmds[0], 'tracing', { resident_size: 200 }) - ]; - }); - - // First PMD: Both total resident and private dirty resident size should be - // reduced by 100. Virtual size should be reduced by 300. - assert.strictEqual(pmds[0].totals.residentBytes, 900); - assert.strictEqual(pmds[0].totals.peakResidentBytes, 1900); - assert.strictEqual(pmds[0].vmRegions.sizeInBytes, 5700); - assert.deepEqual(pmds[0].vmRegions.byteStats, { - privateDirtyResident: 3996 - }); - checkVMRegions(pmds[0].vmRegions, [ - { - mappedFile: 'mock.so', - sizeInBytes: 6000, - byteStats: { - privateDirtyResident: 4096, - } - }, - { - mappedFile: '[discounted tracing overhead]', - sizeInBytes: -300, - byteStats: { - privateDirtyResident: -100 - } - } - ]); - assert.strictEqual(pmds[0].mostRecentVmRegions, pmds[0].vmRegions); - - // Second PMD: Total resident size should be reduced by 200, whereas private - // dirty resident size should be reduced by 100 (because it comes from - // the VM regions in the first dump). Similarly, virtual size should be - // reduced by 300. - assert.isUndefined(pmds[1].totals.residentBytes); - assert.equal(pmds[1].totals.peakResidentBytes, 2800); - assert.isUndefined(pmds[1].vmRegions); - assert.strictEqual(pmds[1].mostRecentVmRegions, pmds[0].vmRegions); - }); - - test('checkDiscountTracingOverhead_allDiscountedVmRegionFields', function() { - var pmd = createFinalizedProcessMemoryDump(42, function(pmd) { - pmd.vmRegions = createClassificationNode(10000, { - privateDirtyResident: 4096, - proportionalResident: 8192, - swapped: 1536 - }); - pmd.memoryAllocatorDumps = [ - newAllocatorDump(pmd, 'tracing', { size: 1000, resident_size: 1024 }) - ]; - }); - - var vmRegions = pmd.vmRegions; - assert.strictEqual(vmRegions.sizeInBytes, 9000); - assert.deepEqual(vmRegions.byteStats, { - privateDirtyResident: 3072, - proportionalResident: 7168, - swapped: 1536 - }); - checkVMRegions(vmRegions, [ - { - mappedFile: 'mock.so', - sizeInBytes: 10000, - byteStats: { - privateDirtyResident: 4096, - proportionalResident: 8192, - swapped: 1536 - } - }, - { - mappedFile: '[discounted tracing overhead]', - sizeInBytes: -1000, - byteStats: { - privateDirtyResident: -1024, - proportionalResident: -1024 - } - } - ]); - }); - - test('checkDiscountTracingOverhead_twoDiscountedVmRegionField', function() { - var pmd = createFinalizedProcessMemoryDump(42, function(pmd) { - pmd.vmRegions = createClassificationNode(10000, { - privateDirtyResident: 4096, - swapped: 1536 - }); - pmd.memoryAllocatorDumps = [ - newAllocatorDump(pmd, 'tracing', { size: 1000, resident_size: 1024 }) - ]; - }); - - var vmRegions = pmd.vmRegions; - assert.strictEqual(vmRegions.sizeInBytes, 9000); - assert.deepEqual(vmRegions.byteStats, { - privateDirtyResident: 3072, - swapped: 1536 - }); - checkVMRegions(vmRegions, [ - { - mappedFile: 'mock.so', - sizeInBytes: 10000, - byteStats: { - privateDirtyResident: 4096, - swapped: 1536 - } - }, - { - mappedFile: '[discounted tracing overhead]', - sizeInBytes: -1000, - byteStats: { - privateDirtyResident: -1024 - } - } - ]); - }); - - test('checkDiscountTracingOverhead_oneDiscountedVmRegionField', function() { - var pmd = createFinalizedProcessMemoryDump(42, function(pmd) { - pmd.vmRegions = createClassificationNode(10000); - pmd.memoryAllocatorDumps = [ - newAllocatorDump(pmd, 'tracing', { size: 1000, resident_size: 1024 }) - ]; - }); - - var vmRegions = pmd.vmRegions; - assert.strictEqual(vmRegions.sizeInBytes, 9000); - assert.deepEqual(vmRegions.byteStats, {}); - checkVMRegions(vmRegions, [ - { - mappedFile: 'mock.so', - sizeInBytes: 10000 - }, - { - mappedFile: '[discounted tracing overhead]', - sizeInBytes: -1000 - } - ]); - }); - - test('checkDiscountTracingOverhead_noDiscountedVmRegionFields', function() { - var pmd = createFinalizedProcessMemoryDump(42, function(pmd) { - pmd.vmRegions = createClassificationNode(undefined, { - swapped: 1536 - }); - pmd.memoryAllocatorDumps = [ - newAllocatorDump(pmd, 'tracing', { size: 1000, resident_size: 1024 }) - ]; - }); - - var vmRegions = pmd.vmRegions; - assert.isUndefined(vmRegions.sizeInBytes); - assert.deepEqual(vmRegions.byteStats, { - swapped: 1536 - }); - checkVMRegions(vmRegions, [ - { - mappedFile: 'mock.so', - byteStats: { - swapped: 1536 - } - } - ]); - }); - - test('checkDiscountTracingOverhead_existingLink', function() { - var pmd = createFinalizedProcessMemoryDump(42, function(pmd) { - pmd.totals = { residentBytes: 10240 }; - - pmd.vmRegions = createClassificationNode(6000, { - privateDirtyResident: 4096, - swapped: 1536, - proportionalResident: 5120 - }); - - var mallocDump = newAllocatorDump(pmd, 'malloc', { size: 3072 }); - var tracingDump = newAllocatorDump(pmd, 'tracing', - { size: 1024, resident_size: 1000 }); - var ownedDump = newAllocatorDump(pmd, 'owned'); - - // The code for discounting tracing overhead should *not* override an - // existing ownership. - addOwnershipLink(tracingDump, ownedDump); - - pmd.memoryAllocatorDumps = [mallocDump, tracingDump, ownedDump]; - }); - - assert.strictEqual(pmd.totals.residentBytes, 9240); - assert.isUndefined(pmd.totals.peakResidentBytes); - - var vmRegions = pmd.vmRegions; - assert.strictEqual(vmRegions.sizeInBytes, 4976); - assert.deepEqual(vmRegions.byteStats, { - privateDirtyResident: 3096, - proportionalResident: 4120, - swapped: 1536 - }); - checkVMRegions(vmRegions, [ - { - mappedFile: 'mock.so', - sizeInBytes: 6000, - byteStats: { - privateDirtyResident: 4096, - proportionalResident: 5120, - swapped: 1536 - } - }, - { - mappedFile: '[discounted tracing overhead]', - sizeInBytes: -1024, - byteStats: { - privateDirtyResident: -1000, - proportionalResident: -1000 - } - } - ]); - - var mallocDump = pmd.getMemoryAllocatorDumpByFullName('malloc'); - checkDumpNumericsAndDiagnostics(mallocDump, { - 'size': 3072, - 'effective_size': 3072 - }, {}); - assert.lengthOf(mallocDump.children, 0); - - var ownedDump = pmd.getMemoryAllocatorDumpByFullName('owned'); - checkDumpNumericsAndDiagnostics(ownedDump, { - 'size': 1024, - 'effective_size': 0 - }, {}); - assert.lengthOf(ownedDump.children, 0); - - var tracingDump = pmd.getMemoryAllocatorDumpByFullName('tracing'); - checkDumpNumericsAndDiagnostics(tracingDump, { - 'size': 1024, - 'effective_size': 1024, - 'resident_size': 1000 - }, {}); - assert.strictEqual(tracingDump.owns.target, ownedDump); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/process_test.html b/chromium/third_party/catapult/tracing/tracing/model/process_test.html deleted file mode 100644 index 46c2ca802a3..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/process_test.html +++ /dev/null @@ -1,112 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/frame.html"> -<link rel="import" href="/tracing/model/global_memory_dump.html"> -<link rel="import" href="/tracing/model/instant_event.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/process.html"> -<link rel="import" href="/tracing/model/thread_slice.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('getOrCreateCounter', function() { - var model = new tr.Model(); - var process = new tr.model.Process(model, 7); - var ctrBar = process.getOrCreateCounter('foo', 'bar'); - var ctrBar2 = process.getOrCreateCounter('foo', 'bar'); - assert.equal(ctrBar2, ctrBar); - }); - - test('shiftTimestampsForward', function() { - var model = new tr.Model(); - var process = new tr.model.Process(model, 7); - var ctr = process.getOrCreateCounter('foo', 'bar'); - var thread = process.getOrCreateThread(1); - - var instantEvent = new tr.model.InstantEvent('cat', 'event1', 1, 100); - process.instantEvents.push(instantEvent); - - var slice = new tr.model.ThreadSlice('', 'a', 0, 1, {}, 4); - var frame = - new tr.model.Frame([slice], [{thread: thread, start: 100, end: 200}]); - process.frames.push(frame); - - var memoryDump = new tr.model.GlobalMemoryDump(model, 100); - process.memoryDumps.push(memoryDump); - - var shiftCount = 0; - thread.shiftTimestampsForward = function(ts) { - if (ts == 0.32) - shiftCount++; - }; - ctr.shiftTimestampsForward = function(ts) { - if (ts == 0.32) - shiftCount++; - }; - - process.shiftTimestampsForward(0.32); - assert.equal(shiftCount, 2); - assert.equal(instantEvent.start, 100.32); - assert.equal(frame.start, 100.32); - assert.equal(frame.end, 200.32); - assert.equal(memoryDump.start, 100.32); - }); - - test('compareOnPID', function() { - var model = new tr.Model(); - var p1 = new tr.model.Process(model, 1); - p1.name = 'Renderer'; - - var model = new tr.Model(); - var p2 = new tr.model.Process(model, 2); - p2.name = 'Renderer'; - - assert.isBelow(p1.compareTo(p2), 0); - }); - - test('compareOnSortIndex', function() { - var model = new tr.Model(); - var p1 = new tr.model.Process(model, 1); - p1.name = 'Renderer'; - p1.sortIndex = 1; - - var p2 = new tr.model.Process(model, 2); - p2.name = 'Renderer'; - - assert.isAbove(p1.compareTo(p2), 0); - }); - - test('compareOnName', function() { - var model = new tr.Model(); - var p1 = new tr.model.Process(model, 1); - p1.name = 'Browser'; - - var p2 = new tr.model.Process(model, 2); - p2.name = 'Renderer'; - - assert.isBelow(p1.compareTo(p2), 0); - }); - - test('compareOnLabels', function() { - var model = new tr.Model(); - var p1 = new tr.model.Process(model, 1); - p1.name = 'Renderer'; - p1.labels = ['a']; - - var p2 = new tr.model.Process(model, 2); - p2.name = 'Renderer'; - p2.labels = ['b']; - - assert.isBelow(p1.compareTo(p2), 0); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/proxy_selectable_item.html b/chromium/third_party/catapult/tracing/tracing/model/proxy_selectable_item.html deleted file mode 100644 index e9f3d92cfa4..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/proxy_selectable_item.html +++ /dev/null @@ -1,44 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/selectable_item.html"> -<link rel="import" href="/tracing/model/selection_state.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - var SelectableItem = tr.model.SelectableItem; - var SelectionState = tr.model.SelectionState; - - /** - * A ProxySelectableItem is a selectable item which is not a model item itself - * but instead acts as a proxy for a model item. - * - * @constructor - * @extends {SelectableItem} - */ - function ProxySelectableItem(modelItem) { - SelectableItem.call(this, modelItem); - }; - - ProxySelectableItem.prototype = { - __proto__: SelectableItem.prototype, - - get selectionState() { - var modelItem = this.modelItem_; - if (modelItem === undefined) - return SelectionState.NONE; - return modelItem.selectionState; - } - }; - - return { - ProxySelectableItem: ProxySelectableItem - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/proxy_selectable_item_test.html b/chromium/third_party/catapult/tracing/tracing/model/proxy_selectable_item_test.html deleted file mode 100644 index 8b5710b2d72..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/proxy_selectable_item_test.html +++ /dev/null @@ -1,39 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/proxy_selectable_item.html"> -<link rel="import" href="/tracing/model/selection_state.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var ProxySelectableItem = tr.model.ProxySelectableItem; - var SelectionState = tr.model.SelectionState; - - test('checkSelectionState_undefinedModelItem', function() { - var proxyItem = new ProxySelectableItem(undefined); - assert.isFalse(proxyItem.selected); - assert.equal(proxyItem.selectionState, SelectionState.NONE); - }); - - test('checkSelectionState_definedModelItem', function() { - // Start with a selected model event. - var modelItem = {selectionState: SelectionState.SELECTED}; - var proxyItem = new ProxySelectableItem(modelItem); - assert.isTrue(proxyItem.selected); - assert.equal(proxyItem.selectionState, SelectionState.SELECTED); - - // Change the selection state of the model event to highlighted. - modelItem.selectionState = SelectionState.HIGHLIGHTED; - assert.isFalse(proxyItem.selected); - assert.equal(proxyItem.selectionState, SelectionState.HIGHLIGHTED); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/rect_annotation.html b/chromium/third_party/catapult/tracing/tracing/model/rect_annotation.html deleted file mode 100644 index a87f7667ee1..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/rect_annotation.html +++ /dev/null @@ -1,66 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/location.html"> -<link rel="import" href="/tracing/model/annotation.html"> -<link rel="import" href="/tracing/ui/annotations/rect_annotation_view.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - - function RectAnnotation(start, end) { - tr.model.Annotation.apply(this, arguments); - - this.startLocation_ = start; // Location of top-left corner. - this.endLocation_ = end; // Location of bottom-right corner. - this.fillStyle = 'rgba(255, 180, 0, 0.3)'; - } - - RectAnnotation.fromDict = function(dict) { - var args = dict.args; - var startLoc = - new tr.model.Location(args.start.xWorld, args.start.yComponents); - var endLoc = - new tr.model.Location(args.end.xWorld, args.end.yComponents); - return new tr.model.RectAnnotation(startLoc, endLoc); - } - - RectAnnotation.prototype = { - __proto__: tr.model.Annotation.prototype, - - get startLocation() { - return this.startLocation_; - }, - - get endLocation() { - return this.endLocation_; - }, - - toDict: function() { - return { - typeName: 'rect', - args: { - start: this.startLocation.toDict(), - end: this.endLocation.toDict() - } - }; - }, - - createView_: function(viewport) { - return new tr.ui.annotations.RectAnnotationView(viewport, this); - } - }; - - tr.model.Annotation.register(RectAnnotation, {typeName: 'rect'}); - - return { - RectAnnotation: RectAnnotation - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/sample.html b/chromium/third_party/catapult/tracing/tracing/model/sample.html deleted file mode 100644 index a0936a3a8ed..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/sample.html +++ /dev/null @@ -1,70 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/timed_event.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the Sample class. - */ -tr.exportTo('tr.model', function() { - /** - * A Sample represents a sample taken at an instant in time, plus its stack - * frame and parameters associated with that sample. - * - * @constructor - */ - function Sample(cpu, thread, title, start, leafStackFrame, - opt_weight, opt_args) { - tr.model.TimedEvent.call(this, start); - - this.title = title; - this.cpu = cpu; - this.thread = thread; - this.leafStackFrame = leafStackFrame; - this.weight = opt_weight; - this.args = opt_args || {}; - } - - Sample.prototype = { - __proto__: tr.model.TimedEvent.prototype, - - get colorId() { - return this.leafStackFrame.colorId; - }, - - get stackTrace() { - return this.leafStackFrame.stackTrace; - }, - - getUserFriendlyStackTrace: function() { - return this.leafStackFrame.getUserFriendlyStackTrace(); - }, - - get userFriendlyName() { - return 'Sample at ' + tr.v.Unit.byName.timeStampInMs.format(this.start); - } - }; - - tr.model.EventRegistry.register( - Sample, - { - name: 'sample', - pluralName: 'samples', - singleViewElementName: 'tr-ui-a-single-sample-sub-view', - multiViewElementName: 'tr-ui-a-multi-sample-sub-view' - }); - - return { - Sample: Sample - }; -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/sample_test.html b/chromium/third_party/catapult/tracing/tracing/model/sample_test.html deleted file mode 100644 index 392b55b8475..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/sample_test.html +++ /dev/null @@ -1,35 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/model.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Sample = tr.model.Sample; - var StackFrame = tr.model.StackFrame; - var Thread = tr.model.Thread; - - test('sampleStackTrace', function() { - var thread = tr.c.TestUtils.newFakeThread(); - - var model = new tr.Model(); - var fABC = tr.c.TestUtils.newStackTrace(model, ['a', 'b', 'c']); - - var s = new Sample(undefined, thread, 'instructions_retired', - 10, fABC, 10); - var stackTrace = s.stackTrace; - var stackTraceNames = stackTrace.map(function(f) { return f.title; }); - assert.deepEqual( - stackTraceNames, - ['c', 'b', 'a']); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/scoped_id.html b/chromium/third_party/catapult/tracing/tracing/model/scoped_id.html deleted file mode 100644 index 652d6f0a7d3..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/scoped_id.html +++ /dev/null @@ -1,35 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> -<link rel="import" href="/tracing/model/constants.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - function ScopedId(scope, id) { - if (scope === undefined) { - throw new Error('Scope should be defined. Use \'' + - tr.model.OBJECT_DEFAULT_SCOPE + - '\' as the default scope.'); - } - this.scope = scope; - this.id = id; - } - - ScopedId.prototype = { - toString: function() { - return '{scope: ' + this.scope + ', id: ' + this.id + '}'; - } - }; - - return { - ScopedId: ScopedId - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/selectable_item.html b/chromium/third_party/catapult/tracing/tracing/model/selectable_item.html deleted file mode 100644 index 25ee56dd2d5..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/selectable_item.html +++ /dev/null @@ -1,59 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/selection_state.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the SelectableItem class. - */ -tr.exportTo('tr.model', function() { - var SelectionState = tr.model.SelectionState; - - /** - * A SelectableItem is the abstract base class for any non-container data that - * has an associated model item in the trace model (possibly itself). - * - * Subclasses must provide a selectionState property (or getter). - * - * @constructor - */ - function SelectableItem(modelItem) { - this.modelItem_ = modelItem; - } - - SelectableItem.prototype = { - get modelItem() { - return this.modelItem_; - }, - - get selected() { - return this.selectionState === SelectionState.SELECTED; - }, - - addToSelection: function(selection) { - var modelItem = this.modelItem_; - if (!modelItem) - return; - selection.push(modelItem); - }, - - addToTrackMap: function(eventToTrackMap, track) { - var modelItem = this.modelItem_; - if (!modelItem) - return; - eventToTrackMap.addEvent(modelItem, track); - } - }; - - return { - SelectableItem: SelectableItem - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/selectable_item_test.html b/chromium/third_party/catapult/tracing/tracing/model/selectable_item_test.html deleted file mode 100644 index c808f3bee23..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/selectable_item_test.html +++ /dev/null @@ -1,80 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/event.html"> -<link rel="import" href="/tracing/model/selectable_item.html"> -<link rel="import" href="/tracing/model/selection_state.html"> -<link rel="import" href="/tracing/ui/tracks/event_to_track_map.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Event = tr.model.Event; - var EventToTrackMap = tr.ui.tracks.EventToTrackMap; - var SelectableItem = tr.model.SelectableItem; - var SelectionState = tr.model.SelectionState; - - test('checkModelItem', function() { - var selectableItem1 = new SelectableItem(undefined); - assert.isUndefined(selectableItem1.modelItem); - - var event = new Event(); - var selectableItem2 = new SelectableItem(event); - assert.equal(selectableItem2.modelItem, event); - }); - - test('checkSelected', function() { - var selectableItem = new SelectableItem(undefined); - - selectableItem.selectionState = SelectionState.NONE; - assert.isFalse(selectableItem.selected); - - selectableItem.selectionState = SelectionState.SELECTED; - assert.isTrue(selectableItem.selected); - - selectableItem.selectionState = SelectionState.HIGHLIGHTED; - assert.isFalse(selectableItem.selected); - }); - - test('checkAddToSelection_undefinedModelItem', function() { - var selectableItem = new SelectableItem(undefined); - var selection = []; - selectableItem.addToSelection(selection); - assert.lengthOf(selection, 0); - }); - - test('checkAddToSelection_definedModelItem', function() { - var event = new Event(); - var selectableItem = new SelectableItem(event); - var selection = []; - selectableItem.addToSelection(selection); - assert.lengthOf(selection, 1); - assert.equal(selection[0], event); - }); - - test('checkAddToTrackMap_undefinedModelItem', function() { - var selectableItem = new SelectableItem(undefined); - var eventToTrackMap = new EventToTrackMap(); - var track = {}; - selectableItem.addToTrackMap(eventToTrackMap, track); - assert.lengthOf(Object.keys(eventToTrackMap), 0); - }); - - test('checkAddToTrackMap_definedModelItem', function() { - var event = new Event(); - var selectableItem = new SelectableItem(event); - var eventToTrackMap = new EventToTrackMap(); - var track = {}; - selectableItem.addToTrackMap(eventToTrackMap, track); - assert.lengthOf(Object.keys(eventToTrackMap), 1); - assert.equal(eventToTrackMap[event.guid], track); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/selection_state.html b/chromium/third_party/catapult/tracing/tracing/model/selection_state.html deleted file mode 100644 index c49abfde4a5..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/selection_state.html +++ /dev/null @@ -1,72 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> -<link rel="import" href="/tracing/base/color_scheme.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the SelectionState class. - */ -tr.exportTo('tr.model', function() { - var ColorScheme = tr.b.ColorScheme; - - /** - * Describes the level of visual highlighting to apply to an event when shown. - * - * color_scheme.html defines N variations off of a base color palette, - * one for each selection state, all concatenated into one flat array. To - * pick the final colorId for a given variations, the SelectionState is - * multiplied by the number of base colors. - * - * Thus, the values here must be kept in sync with color_scheme's palette - * layout. - */ - var SelectionState = { - NONE: 0, - - // Legacy names. - SELECTED: ColorScheme.properties.brightenedOffsets[0], - HIGHLIGHTED: ColorScheme.properties.brightenedOffsets[1], - DIMMED: ColorScheme.properties.dimmedOffsets[0], - - // Modern names. - BRIGHTENED0: ColorScheme.properties.brightenedOffsets[0], - BRIGHTENED1: ColorScheme.properties.brightenedOffsets[1], - BRIGHTENED2: ColorScheme.properties.brightenedOffsets[2], - - DIMMED0: ColorScheme.properties.dimmedOffsets[0], - DIMMED1: ColorScheme.properties.dimmedOffsets[1], - DIMMED2: ColorScheme.properties.dimmedOffsets[2] - }; - - var brighteningLevels = [ - SelectionState.NONE, - SelectionState.BRIGHTENED0, - SelectionState.BRIGHTENED1, - SelectionState.BRIGHTENED2 - ]; - SelectionState.getFromBrighteningLevel = function(level) { - return brighteningLevels[level]; - } - - var dimmingLevels = [ - SelectionState.DIMMED0, - SelectionState.DIMMED1, - SelectionState.DIMMED2 - ]; - SelectionState.getFromDimmingLevel = function(level) { - return dimmingLevels[level]; - } - - return { - SelectionState: SelectionState - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/slice.html b/chromium/third_party/catapult/tracing/tracing/model/slice.html deleted file mode 100644 index 7c53deb305d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/slice.html +++ /dev/null @@ -1,297 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/timed_event.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the Slice class. - */ -tr.exportTo('tr.model', function() { - /** - * A Slice represents an interval of time plus parameters associated - * with that interval. - * - * @constructor - */ - function Slice(category, title, colorId, start, args, opt_duration, - opt_cpuStart, opt_cpuDuration, opt_argsStripped, - opt_bind_id) { - tr.model.TimedEvent.call(this, start); - - this.category = category || ''; - this.title = title; - this.colorId = colorId; - this.args = args; - this.startStackFrame = undefined; - this.endStackFrame = undefined; - this.didNotFinish = false; - this.inFlowEvents = []; - this.outFlowEvents = []; - this.subSlices = []; - this.selfTime = undefined; - this.cpuSelfTime = undefined; - this.important = false; - this.parentContainer = undefined; - this.argsStripped = false; - - this.bind_id_ = opt_bind_id; - - // parentSlice and isTopLevel will be set by SliceGroup. - this.parentSlice = undefined; - this.isTopLevel = false; - // After SliceGroup processes Slices, isTopLevel should be equivalent to - // !parentSlice. - - if (opt_duration !== undefined) - this.duration = opt_duration; - - if (opt_cpuStart !== undefined) - this.cpuStart = opt_cpuStart; - - if (opt_cpuDuration !== undefined) - this.cpuDuration = opt_cpuDuration; - - if (opt_argsStripped !== undefined) - this.argsStripped = true; - } - - Slice.prototype = { - __proto__: tr.model.TimedEvent.prototype, - - - get analysisTypeName() { - return this.title; - }, - - get userFriendlyName() { - return 'Slice ' + this.title + ' at ' + - tr.v.Unit.byName.timeStampInMs.format(this.start); - }, - - get stableId() { - var parentSliceGroup = this.parentContainer.sliceGroup; - return parentSliceGroup.stableId + '.' + - parentSliceGroup.slices.indexOf(this); - }, - - findDescendentSlice: function(targetTitle) { - if (!this.subSlices) - return undefined; - - for (var i = 0; i < this.subSlices.length; i++) { - if (this.subSlices[i].title == targetTitle) - return this.subSlices[i]; - var slice = this.subSlices[i].findDescendentSlice(targetTitle); - if (slice) return slice; - } - return undefined; - }, - - get mostTopLevelSlice() { - var curSlice = this; - while (curSlice.parentSlice) - curSlice = curSlice.parentSlice; - - return curSlice; - }, - - getProcess: function() { - var thread = this.parentContainer; - if (thread && thread.getProcess) - return thread.getProcess(); - return undefined; - }, - - get model() { - var process = this.getProcess(); - if (process !== undefined) - return this.getProcess().model; - return undefined; - }, - - /** - * Finds all topmost slices relative to this slice. - * - * Slices may have multiple direct descendants which satisfy - * |eventPredicate|, and in this case, all of them are topmost as long as - * this slice does not satisfy the predicate. - * - * For instance, suppose we are passing a predicate that checks whether - * events titles begin with 'C'. - * C1.findTopmostSlicesRelativeToThisSlice() returns C1 in this example: - * [ C1 ] - * [ C2 ] - * - * and D.findTopmostSlicesRelativeToThisSlice() returns C1 and C2 in this - * example: - * [ D ] - * [C1] [C2] - */ - findTopmostSlicesRelativeToThisSlice: function*(eventPredicate) { - if (eventPredicate(this)) { - yield this; - return; - } - for (var s of this.subSlices) - yield * s.findTopmostSlicesRelativeToThisSlice(eventPredicate); - }, - - /** - * Obtains all subsequent slices of this slice. - * - * Subsequent slices are slices that get executed after a particular - * slice, i.e., all the functions that are called after the current one. - * - * For instance, E.iterateAllSubsequentSlices() in the following example: - * [ A ] - * [ B][ D ][ G ] - * [C] [E][F] [H] - * will pass F, G, then H to the provided callback. - * - * The reason we need subsequent slices of a particular slice is that - * when there is flow event goes into, e.g., E, we only want to highlight - * E's subsequent slices to indicate the execution order. - * - * The idea to calculate the subsequent slices of slice E is to view - * the slice group as a tree where the top-level slice A is the root node. - * The preorder depth-first-search (DFS) order is naturally equivalent - * to the function call order. We just need to perform a DFS, and start - * recording the slices after we see the occurance of E. - */ - iterateAllSubsequentSlices: function(callback, opt_this) { - var parentStack = []; - var started = false; - - // get the root node and push it to the DFS stack - var topmostSlice = this.mostTopLevelSlice; - parentStack.push(topmostSlice); - - // Using the stack to perform DFS - while (parentStack.length !== 0) { - var curSlice = parentStack.pop(); - - if (started) - callback.call(opt_this, curSlice); - else - started = (curSlice.guid === this.guid); - - for (var i = curSlice.subSlices.length - 1; i >= 0; i--) { - parentStack.push(curSlice.subSlices[i]); - } - } - }, - - get subsequentSlices() { - var res = []; - - this.iterateAllSubsequentSlices(function(subseqSlice) { - res.push(subseqSlice); - }); - - return res; - }, - - /** - * Obtains the parents of a slice, from the most immediate to the root. - * - * For instance, E.iterateAllAncestors() in the following example: - * [ A ] - * [ B][ D ][ G ] - * [C] [E][F] [H] - * will pass D, then A to the provided callback, in the order from the - * leaves to the root. - */ - iterateAllAncestors: function(callback, opt_this) { - var curSlice = this; - - while (curSlice.parentSlice) { - curSlice = curSlice.parentSlice; - callback.call(opt_this, curSlice); - } - }, - - get ancestorSlices() { - var res = []; - - this.iterateAllAncestors(function(ancestor) { - res.push(ancestor); - }); - - return res; - }, - - iterateEntireHierarchy: function(callback, opt_this) { - var mostTopLevelSlice = this.mostTopLevelSlice; - callback.call(opt_this, mostTopLevelSlice); - mostTopLevelSlice.iterateAllSubsequentSlices(callback, opt_this); - }, - - get entireHierarchy() { - var res = []; - - this.iterateEntireHierarchy(function(slice) { - res.push(slice); - }); - - return res; - }, - - /** - * Returns this slice, and its ancestor and subsequent slices. - * - * For instance, E.ancestorAndSubsequentSlices in the following example: - * [ A ] - * [ B][ D ][ G ] - * [C] [E][F] [H] - * will return E, D, A, F, G, and H, where E is itself, D and A are - * E's ancestors, and F, G, and H are subsequent slices of E - */ - get ancestorAndSubsequentSlices() { - var res = []; - - res.push(this); - - this.iterateAllAncestors(function(aSlice) { - res.push(aSlice); - }); - - this.iterateAllSubsequentSlices(function(sSlice) { - res.push(sSlice); - }); - - return res; - }, - - iterateAllDescendents: function(callback, opt_this) { - this.subSlices.forEach(callback, opt_this); - this.subSlices.forEach(function(subSlice) { - subSlice.iterateAllDescendents(callback, opt_this); - }, opt_this); - }, - - get descendentSlices() { - var res = []; - - this.iterateAllDescendents(function(des) { - res.push(des); - }); - - return res; - } - - }; - - return { - Slice: Slice - }; -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/slice_group.html b/chromium/third_party/catapult/tracing/tracing/model/slice_group.html deleted file mode 100644 index 9c14e8bf54e..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/slice_group.html +++ /dev/null @@ -1,662 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/color_scheme.html"> -<link rel="import" href="/tracing/base/guid.html"> -<link rel="import" href="/tracing/base/sorted_array_utils.html"> -<link rel="import" href="/tracing/core/filter.html"> -<link rel="import" href="/tracing/model/event_container.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the SliceGroup class. - */ -tr.exportTo('tr.model', function() { - var ColorScheme = tr.b.ColorScheme; - var Slice = tr.model.Slice; - - function getSliceLo(s) { - return s.start; - } - - function getSliceHi(s) { - return s.end; - } - - /** - * A group of Slices, plus code to create them from B/E events, as - * well as arrange them into subRows. - * - * Do not mutate the slices array directly. Modify it only by - * SliceGroup mutation methods. - * - * @constructor - * @param {function(new:Slice, category, title, colorId, start, args)=} - * opt_sliceConstructor The constructor to use when creating slices. - * @extends {tr.model.EventContainer} - */ - function SliceGroup(parentContainer, opt_sliceConstructor, opt_name) { - tr.model.EventContainer.call(this); - - this.parentContainer_ = parentContainer; - - var sliceConstructor = opt_sliceConstructor || Slice; - this.sliceConstructor = sliceConstructor; - - this.openPartialSlices_ = []; - - this.slices = []; - this.topLevelSlices = []; - this.haveTopLevelSlicesBeenBuilt = false; - this.name_ = opt_name; - - if (this.model === undefined) - throw new Error('SliceGroup must have model defined.'); - } - - SliceGroup.prototype = { - __proto__: tr.model.EventContainer.prototype, - - get parentContainer() { - return this.parentContainer_; - }, - - get model() { - return this.parentContainer_.model; - }, - - get stableId() { - return this.parentContainer_.stableId + '.SliceGroup'; - }, - - getSettingsKey: function() { - if (!this.name_) - return undefined; - var parentKey = this.parentContainer_.getSettingsKey(); - if (!parentKey) - return undefined; - return parentKey + '.' + this.name; - }, - - /** - * @return {Number} The number of slices in this group. - */ - get length() { - return this.slices.length; - }, - - /** - * Helper function that pushes the provided slice onto the slices array. - * @param {Slice} slice The slice to be added to the slices array. - */ - pushSlice: function(slice) { - this.haveTopLevelSlicesBeenBuilt = false; - slice.parentContainer = this.parentContainer_; - this.slices.push(slice); - return slice; - }, - - /** - * Helper function that pushes the provided slices onto the slices array. - * @param {Array.<Slice>} slices An array of slices to be added. - */ - pushSlices: function(slices) { - this.haveTopLevelSlicesBeenBuilt = false; - slices.forEach(function(slice) { - slice.parentContainer = this.parentContainer_; - this.slices.push(slice); - }, this); - }, - - /** - * Opens a new slice in the group's slices. - * - * Calls to beginSlice and - * endSlice must be made with non-monotonically-decreasing timestamps. - * - * @param {String} category Category name of the slice to add. - * @param {String} title Title of the slice to add. - * @param {Number} ts The timetsamp of the slice, in milliseconds. - * @param {Object.<string, Object>=} opt_args Arguments associated with - * the slice. - * @param {Number=} opt_colorId The color of the slice, defined by - * its palette id (see base/color_scheme.html). - */ - beginSlice: function(category, title, ts, opt_args, opt_tts, - opt_argsStripped, opt_colorId) { - if (this.openPartialSlices_.length) { - var prevSlice = this.openPartialSlices_[ - this.openPartialSlices_.length - 1]; - if (ts < prevSlice.start) - throw new Error('Slices must be added in increasing timestamp order'); - } - - var colorId = opt_colorId || - ColorScheme.getColorIdForGeneralPurposeString(title); - var slice = new this.sliceConstructor(category, title, colorId, ts, - opt_args ? opt_args : {}, null, - opt_tts, undefined, - opt_argsStripped); - this.openPartialSlices_.push(slice); - slice.didNotFinish = true; - this.pushSlice(slice); - - return slice; - }, - - isTimestampValidForBeginOrEnd: function(ts) { - if (!this.openPartialSlices_.length) - return true; - var top = this.openPartialSlices_[this.openPartialSlices_.length - 1]; - return ts >= top.start; - }, - - /** - * @return {Number} The number of beginSlices for which an endSlice has not - * been issued. - */ - get openSliceCount() { - return this.openPartialSlices_.length; - }, - - get mostRecentlyOpenedPartialSlice() { - if (!this.openPartialSlices_.length) - return undefined; - return this.openPartialSlices_[this.openPartialSlices_.length - 1]; - }, - - /** - * Ends the last begun slice in this group and pushes it onto the slice - * array. - * - * @param {Number} ts Timestamp when the slice ended - * @param {Number=} opt_colorId The color of the slice, defined by - * its palette id (see base/color_scheme.html). - * @return {Slice} slice. - */ - endSlice: function(ts, opt_tts, opt_colorId) { - if (!this.openSliceCount) - throw new Error('endSlice called without an open slice'); - - var slice = this.openPartialSlices_[this.openSliceCount - 1]; - this.openPartialSlices_.splice(this.openSliceCount - 1, 1); - if (ts < slice.start) - throw new Error('Slice ' + slice.title + - ' end time is before its start.'); - - slice.duration = ts - slice.start; - slice.didNotFinish = false; - slice.colorId = opt_colorId || slice.colorId; - - if (opt_tts && slice.cpuStart !== undefined) - slice.cpuDuration = opt_tts - slice.cpuStart; - - return slice; - }, - - /** - * Push a complete event as a Slice into the slice list. - * The timestamp can be in any order. - * - * @param {String} category Category name of the slice to add. - * @param {String} title Title of the slice to add. - * @param {Number} ts The timetsamp of the slice, in milliseconds. - * @param {Number} duration The duration of the slice, in milliseconds. - * @param {Object.<string, Object>=} opt_args Arguments associated with - * the slice. - * @param {Number=} opt_colorId The color of the slice, as defined by - * its palette id (see base/color_scheme.html). - */ - pushCompleteSlice: function(category, title, ts, duration, tts, - cpuDuration, opt_args, opt_argsStripped, - opt_colorId, opt_bind_id) { - var colorId = opt_colorId || - ColorScheme.getColorIdForGeneralPurposeString(title); - var slice = new this.sliceConstructor(category, title, colorId, ts, - opt_args ? opt_args : {}, - duration, tts, cpuDuration, - opt_argsStripped, opt_bind_id); - if (duration === undefined) - slice.didNotFinish = true; - this.pushSlice(slice); - return slice; - }, - - /** - * Closes any open slices. - * @param {Number=} opt_maxTimestamp The end time to use for the closed - * slices. If not provided, - * the max timestamp for this slice is provided. - */ - autoCloseOpenSlices: function() { - this.updateBounds(); - var maxTimestamp = this.bounds.max; - for (var sI = 0; sI < this.slices.length; sI++) { - var slice = this.slices[sI]; - if (slice.didNotFinish) - slice.duration = maxTimestamp - slice.start; - } - this.openPartialSlices_ = []; - }, - - /** - * Shifts all the timestamps inside this group forward by the amount - * specified. - */ - shiftTimestampsForward: function(amount) { - for (var sI = 0; sI < this.slices.length; sI++) { - var slice = this.slices[sI]; - slice.start = (slice.start + amount); - } - }, - - /** - * Updates the bounds for this group based on the slices it contains. - */ - updateBounds: function() { - this.bounds.reset(); - for (var i = 0; i < this.slices.length; i++) { - this.bounds.addValue(this.slices[i].start); - this.bounds.addValue(this.slices[i].end); - } - }, - - copySlice: function(slice) { - var newSlice = new this.sliceConstructor(slice.category, slice.title, - slice.colorId, slice.start, - slice.args, slice.duration, slice.cpuStart, slice.cpuDuration); - newSlice.didNotFinish = slice.didNotFinish; - return newSlice; - }, - - findTopmostSlicesInThisContainer: function*(eventPredicate, opt_this) { - if (!this.haveTopLevelSlicesBeenBuilt) - throw new Error('Nope'); - - for (var s of this.topLevelSlices) - yield * s.findTopmostSlicesRelativeToThisSlice(eventPredicate); - }, - - childEvents: function*() { - yield * this.slices; - }, - - childEventContainers: function*() { - }, - - getSlicesOfName: function(title) { - var slices = []; - for (var i = 0; i < this.slices.length; i++) { - if (this.slices[i].title == title) { - slices.push(this.slices[i]); - } - } - return slices; - }, - - iterSlicesInTimeRange: function(callback, start, end) { - var ret = []; - tr.b.iterateOverIntersectingIntervals( - this.topLevelSlices, - function(s) { return s.start; }, - function(s) { return s.duration; }, - start, - end, - function(topLevelSlice) { - callback(topLevelSlice); - topLevelSlice.iterateAllDescendents(callback); - }); - return ret; - }, - - findFirstSlice: function() { - if (!this.haveTopLevelSlicesBeenBuilt) - throw new Error('Nope'); - if (0 === this.slices.length) - return undefined; - return this.slices[0]; - }, - - findSliceAtTs: function(ts) { - if (!this.haveTopLevelSlicesBeenBuilt) - throw new Error('Nope'); - var i = tr.b.findIndexInSortedClosedIntervals( - this.topLevelSlices, - getSliceLo, getSliceHi, - ts); - if (i == -1 || i == this.topLevelSlices.length) - return undefined; - - var curSlice = this.topLevelSlices[i]; - - // Now recurse on slice looking for subSlice of given ts. - while (true) { - var i = tr.b.findIndexInSortedClosedIntervals( - curSlice.subSlices, - getSliceLo, getSliceHi, - ts); - if (i == -1 || i == curSlice.subSlices.length) - return curSlice; - curSlice = curSlice.subSlices[i]; - } - }, - - findNextSliceAfter: function(ts, refGuid) { - var i = tr.b.findLowIndexInSortedArray( - this.slices, getSliceLo, ts); - if (i === this.slices.length) - return undefined; - for (; i < this.slices.length; i++) { - var slice = this.slices[i]; - if (slice.start > ts) - return slice; - if (slice.guid <= refGuid) - continue; - return slice; - } - return undefined; - }, - - /** - * Construct subSlices for this group. - * Populate the group topLevelSlices, parent slices get a subSlices[], - * a selfThreadTime and a selfTime, child slices get a parentSlice - * reference. - */ - createSubSlices: function() { - this.haveTopLevelSlicesBeenBuilt = true; - this.createSubSlicesImpl_(); - if (this.parentContainer.timeSlices) - this.addCpuTimeToSubslices_(this.parentContainer.timeSlices); - this.slices.forEach(function(slice) { - var selfTime = slice.duration; - for (var i = 0; i < slice.subSlices.length; i++) - selfTime -= slice.subSlices[i].duration; - slice.selfTime = selfTime; - - if (slice.cpuDuration === undefined) - return; - - var cpuSelfTime = slice.cpuDuration; - for (var i = 0; i < slice.subSlices.length; i++) { - if (slice.subSlices[i].cpuDuration !== undefined) - cpuSelfTime -= slice.subSlices[i].cpuDuration; - } - slice.cpuSelfTime = cpuSelfTime; - }); - }, - createSubSlicesImpl_: function() { - var precisionUnit = this.model.intrinsicTimeUnit; - - function addSliceIfBounds(root, child) { - // Because we know that the start time of child is >= the start time - // of all other slices seen so far, we can just check the last slice - // of each row for bounding. - if (root.bounds(child, precisionUnit)) { - if (root.subSlices && root.subSlices.length > 0) { - if (addSliceIfBounds(root.subSlices[root.subSlices.length - 1], - child)) - return true; - } - child.parentSlice = root; - if (root.subSlices === undefined) - root.subSlices = []; - root.subSlices.push(child); - return true; - } - return false; - } - - if (!this.slices.length) - return; - - var ops = []; - for (var i = 0; i < this.slices.length; i++) { - if (this.slices[i].subSlices) - this.slices[i].subSlices.splice(0, - this.slices[i].subSlices.length); - ops.push(i); - } - - var originalSlices = this.slices; - ops.sort(function(ix, iy) { - var x = originalSlices[ix]; - var y = originalSlices[iy]; - if (x.start != y.start) - return x.start - y.start; - - // Elements get inserted into the slices array in order of when the - // slices start. Because slices must be properly nested, we break - // start-time ties by assuming that the elements appearing earlier - // in the slices array (and thus ending earlier) start earlier. - return ix - iy; - }); - - var slices = new Array(this.slices.length); - for (var i = 0; i < ops.length; i++) { - slices[i] = originalSlices[ops[i]]; - } - - // Actually build the subrows. - var rootSlice = slices[0]; - this.topLevelSlices = []; - this.topLevelSlices.push(rootSlice); - rootSlice.isTopLevel = true; - for (var i = 1; i < slices.length; i++) { - var slice = slices[i]; - if (!addSliceIfBounds(rootSlice, slice)) { - rootSlice = slice; - rootSlice.isTopLevel = true; - this.topLevelSlices.push(rootSlice); - } - } - - // Keep the slices in sorted form. - this.slices = slices; - }, - addCpuTimeToSubslices_: function(timeSlices) { - var SCHEDULING_STATE = tr.model.SCHEDULING_STATE; - var sliceIdx = 0; - timeSlices.forEach(function(timeSlice) { - if (timeSlice.schedulingState == SCHEDULING_STATE.RUNNING) { - while (sliceIdx < this.topLevelSlices.length) { - if (this.addCpuTimeToSubslice_(this.topLevelSlices[sliceIdx], - timeSlice)) { - // The current top-level slice and children are fully - // accounted for, proceed to next top-level slice. - sliceIdx++; - } else { - // The current top-level runs beyond the time slice, break out - // so we can potentially add more time slices to it - break; - } - } - } - }, this); - }, - /* Add run-time of this timeSlice to the passed in slice - * and all of it's children (recursively). - * Returns whether the slice ends before or at the end of the - * time slice, signaling we are done with this slice. - */ - addCpuTimeToSubslice_: function(slice, timeSlice) { - // Make sure they overlap - if (slice.start > timeSlice.end || slice.end < timeSlice.start) - return slice.end <= timeSlice.end; - - // Compute actual overlap - var duration = timeSlice.duration; - if (slice.start > timeSlice.start) - duration -= slice.start - timeSlice.start; - if (timeSlice.end > slice.end) - duration -= timeSlice.end - slice.end; - - if (slice.cpuDuration) { - slice.cpuDuration += duration; - } else { - slice.cpuDuration = duration; - } - - for (var i = 0; i < slice.subSlices.length; i++) { - this.addCpuTimeToSubslice_(slice.subSlices[i], timeSlice); - } - - return slice.end <= timeSlice.end; - } - }; - - /** - * Merge two slice groups. - * - * If the two groups do not nest properly some of the slices of groupB will - * be split to accomodate the improper nesting. This is done to accomodate - * combined kernel and userland call stacks on Android. Because userland - * tracing is done by writing to the trace_marker file, the kernel calls - * that get invoked as part of that write may not be properly nested with - * the userland call trace. For example the following sequence may occur: - * - * kernel enter sys_write (the write to trace_marker) - * user enter some_function - * kernel exit sys_write - * ... - * kernel enter sys_write (the write to trace_marker) - * user exit some_function - * kernel exit sys_write - * - * This is handled by splitting the sys_write call into two slices as - * follows: - * - * | sys_write | some_function | sys_write (cont.) | - * | sys_write (cont.) | | sys_write | - * - * The colorId of both parts of the split slices are kept the same, and the - * " (cont.)" suffix is appended to the later parts of a split slice. - * - * The two input SliceGroups are not modified by this, and the merged - * SliceGroup will contain a copy of each of the input groups' slices (those - * copies may be split). - */ - SliceGroup.merge = function(groupA, groupB) { - // This is implemented by traversing the two slice groups in reverse - // order. The slices in each group are sorted by ascending end-time, so - // we must do the traversal from back to front in order to maintain the - // sorting. - // - // We traverse the two groups simultaneously, merging as we go. At each - // iteration we choose the group from which to take the next slice based - // on which group's next slice has the greater end-time. During this - // traversal we maintain a stack of currently "open" slices for each input - // group. A slice is considered "open" from the time it gets reached in - // our input group traversal to the time we reach an slice in this - // traversal with an end-time before the start time of the "open" slice. - // - // Each time a slice from groupA is opened or closed (events corresponding - // to the end-time and start-time of the input slice, respectively) we - // split all of the currently open slices from groupB. - - if (groupA.openPartialSlices_.length > 0) - throw new Error('groupA has open partial slices'); - - if (groupB.openPartialSlices_.length > 0) - throw new Error('groupB has open partial slices'); - - if (groupA.parentContainer != groupB.parentContainer) - throw new Error('Different parent threads. Cannot merge'); - - if (groupA.sliceConstructor != groupB.sliceConstructor) - throw new Error('Different slice constructors. Cannot merge'); - - var result = new SliceGroup(groupA.parentContainer, - groupA.sliceConstructor, - groupA.name_); - - var slicesA = groupA.slices; - var slicesB = groupB.slices; - var idxA = 0; - var idxB = 0; - var openA = []; - var openB = []; - - var splitOpenSlices = function(when) { - for (var i = 0; i < openB.length; i++) { - var oldSlice = openB[i]; - var oldEnd = oldSlice.end; - if (when < oldSlice.start || oldEnd < when) { - throw new Error('slice should not be split'); - } - - var newSlice = result.copySlice(oldSlice); - newSlice.start = when; - newSlice.duration = oldEnd - when; - if (newSlice.title.indexOf(' (cont.)') == -1) - newSlice.title += ' (cont.)'; - oldSlice.duration = when - oldSlice.start; - openB[i] = newSlice; - result.pushSlice(newSlice); - } - }; - - var closeOpenSlices = function(upTo) { - while (openA.length > 0 || openB.length > 0) { - var nextA = openA[openA.length - 1]; - var nextB = openB[openB.length - 1]; - var endA = nextA && nextA.end; - var endB = nextB && nextB.end; - - if ((endA === undefined || endA > upTo) && - (endB === undefined || endB > upTo)) { - return; - } - - if (endB === undefined || endA < endB) { - splitOpenSlices(endA); - openA.pop(); - } else { - openB.pop(); - } - } - }; - - while (idxA < slicesA.length || idxB < slicesB.length) { - var sA = slicesA[idxA]; - var sB = slicesB[idxB]; - var nextSlice, isFromB; - - if (sA === undefined || (sB !== undefined && sA.start > sB.start)) { - nextSlice = result.copySlice(sB); - isFromB = true; - idxB++; - } else { - nextSlice = result.copySlice(sA); - isFromB = false; - idxA++; - } - - closeOpenSlices(nextSlice.start); - - result.pushSlice(nextSlice); - - if (isFromB) { - openB.push(nextSlice); - } else { - splitOpenSlices(nextSlice.start); - openA.push(nextSlice); - } - } - - closeOpenSlices(); - - return result; - }; - - return { - SliceGroup: SliceGroup - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/slice_group_test.html b/chromium/third_party/catapult/tracing/tracing/model/slice_group_test.html deleted file mode 100644 index 8ae66bc41d1..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/slice_group_test.html +++ /dev/null @@ -1,881 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/model.html"> -<link rel="import" href="/tracing/model/slice_group.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Slice = tr.model.Slice; - var SliceGroup = tr.model.SliceGroup; - var newSliceEx = tr.c.TestUtils.newSliceEx; - var newThreadSlice = tr.c.TestUtils.newThreadSlice; - var newModel = tr.c.TestUtils.newModel; - var newFakeThread = tr.c.TestUtils.newFakeThread; - - test('basicBeginEnd', function() { - var group = new SliceGroup(newFakeThread()); - assert.equal(group.openSliceCount, 0); - var sliceA = group.beginSlice('', 'a', 1, {a: 1}); - assert.equal(group.openSliceCount, 1); - assert.equal(sliceA.title, 'a'); - assert.equal(sliceA.start, 1); - assert.equal(sliceA.args.a, 1); - - var sliceB = group.endSlice(3); - assert.equal(sliceA, sliceB); - assert.equal(sliceB.duration, 2); - }); - - test('subSlicesBuilderBasic', function() { - var group = new SliceGroup(newFakeThread()); - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, duration: 2})); - var sB = group.pushSlice(newSliceEx({title: 'b', start: 3, duration: 1})); - - group.createSubSlices(); - - assert.equal(group.topLevelSlices.length, 2); - assert.deepEqual(group.topLevelSlices, [sA, sB]); - assert.equal(group.findSliceAtTs(0), undefined); - assert.equal(group.findSliceAtTs(1), sA); - assert.equal(group.findSliceAtTs(3), sA); - assert.equal(group.findSliceAtTs(3.1), sB); - assert.equal(group.findSliceAtTs(4), sB); - assert.equal(group.findSliceAtTs(5), undefined); - }); - - test('subSlicesBuilderBasic2', function() { - var group = new SliceGroup(newFakeThread()); - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, duration: 4})); - var sB = group.pushSlice(newSliceEx({title: 'b', start: 3, duration: 1})); - - group.createSubSlices(); - - assert.equal(group.topLevelSlices.length, 1); - assert.deepEqual(group.topLevelSlices, [sA]); - - assert.equal(sA.subSlices.length, 1); - assert.deepEqual(sA.subSlices, [sB]); - assert.equal(sA.selfTime, 3); - - assert.equal(sA, sB.parentSlice); - assert.isTrue(sA.isTopLevel); - assert.isFalse(sB.isTopLevel); - }); - - test('subSlicesBuilderNestedExactly', function() { - var group = new SliceGroup(newFakeThread()); - var sB = group.pushSlice(newSliceEx({title: 'b', start: 1, duration: 4})); - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, duration: 4})); - - group.createSubSlices(); - - assert.equal(group.topLevelSlices.length, 1); - assert.deepEqual(group.topLevelSlices, [sB]); - - assert.equal(sB.subSlices.length, 1); - assert.deepEqual(sB.subSlices, [sA]); - assert.equal(sB.selfTime, 0); - - assert.equal(sB, sA.parentSlice); - assert.isTrue(sB.isTopLevel); - assert.isFalse(sA.isTopLevel); - - assert.equal(group.findSliceAtTs(0), undefined); - assert.equal(group.findSliceAtTs(1), sA); - assert.equal(group.findSliceAtTs(2), sA); - assert.equal(group.findSliceAtTs(5), sA); - assert.equal(group.findSliceAtTs(6), undefined); - }); - - test('subSlicesBuilderInstantEvents', function() { - var group = new SliceGroup(newFakeThread()); - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, duration: 0})); - var sB = group.pushSlice(newSliceEx({title: 'b', start: 2, duration: 0})); - - group.createSubSlices(); - - assert.equal(group.topLevelSlices.length, 2); - assert.deepEqual(group.topLevelSlices, [sA, sB]); - assert.equal(group.findSliceAtTs(1), sA); - assert.equal(group.findSliceAtTs(1.5), undefined); - assert.equal(group.findSliceAtTs(2), sB); - }); - - test('subSlicesBuilderTwoInstantEvents', function() { - var group = new SliceGroup(newFakeThread()); - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, duration: 0})); - var sB = group.pushSlice(newSliceEx({title: 'b', start: 1, duration: 0})); - - group.createSubSlices(); - - assert.equal(group.topLevelSlices.length, 1); - assert.deepEqual(group.topLevelSlices, [sA]); - - assert.equal(sA.subSlices.length, 1); - assert.deepEqual(sA.subSlices, [sB]); - assert.equal(sA.selfTime, 0); - - assert.equal(sA, sB.parentSlice); - assert.isTrue(sA.isTopLevel); - assert.isFalse(sB.isTopLevel); - assert.equal(group.findSliceAtTs(1), sB); - assert.equal(group.findSliceAtTs(1.0001), undefined); - }); - - test('subSlicesBuilderOutOfOrderAddition', function() { - var group = new SliceGroup(newFakeThread()); - - // Pattern being tested: - // [ a ][ b ] - // Where insertion is done backward. - var sB = group.pushSlice(newSliceEx({title: 'b', start: 3, duration: 1})); - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, duration: 2})); - - group.createSubSlices(); - - assert.equal(group.topLevelSlices.length, 2); - assert.deepEqual(group.topLevelSlices, [sA, sB]); - assert.equal(group.findSliceAtTs(3), sA); - }); - - test('subRowBuilderOutOfOrderAddition2', function() { - var group = new SliceGroup(newFakeThread()); - - // Pattern being tested: - // [ a ] - // [ b ] - // Where insertion is done backward. - var sB = group.pushSlice(newSliceEx({title: 'b', start: 3, duration: 1})); - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, duration: 5})); - - group.createSubSlices(); - - assert.equal(group.topLevelSlices.length, 1); - assert.deepEqual(group.topLevelSlices, [sA]); - - assert.equal(sA.subSlices.length, 1); - assert.deepEqual(sA.subSlices, [sB]); - assert.equal(sA.selfTime, 4); - - assert.equal(sA, sB.parentSlice); - assert.isTrue(sA.isTopLevel); - assert.isFalse(sB.isTopLevel); - assert.equal(group.findSliceAtTs(1.5), sA); - assert.equal(group.findSliceAtTs(3), sB); - assert.equal(group.findSliceAtTs(3.5), sB); - assert.equal(group.findSliceAtTs(4), sB); - assert.equal(group.findSliceAtTs(4.5), sA); - }); - - test('subSlicesBuilderOnNestedZeroLength', function() { - var group = new SliceGroup(newFakeThread()); - - // Pattern being tested: - // [ a ] - // [ b1 ] []<- b2 where b2.duration = 0 and b2.end == a.end. - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, duration: 3})); - var sB1 = group.pushSlice(newSliceEx({title: 'b1', start: 1, duration: 2})); - var sB2 = group.pushSlice(newSliceEx({title: 'b2', start: 4, duration: 0})); - - group.createSubSlices(); - - assert.equal(group.topLevelSlices.length, 1); - assert.deepEqual(group.topLevelSlices, [sA]); - - assert.equal(sA.subSlices.length, 2); - assert.deepEqual(sA.subSlices, [sB1, sB2]); - assert.equal(sA.selfTime, 1); - - assert.equal(sA, sB1.parentSlice); - assert.equal(sA, sB2.parentSlice); - assert.equal(group.findSliceAtTs(1), sB1); - assert.equal(group.findSliceAtTs(4), sB2); - }); - - test('subSlicesBuilderOnGroup1', function() { - var group = new SliceGroup(newFakeThread()); - - // Pattern being tested: - // [ a ] [ c ] - // [ b ] - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, duration: 3})); - var sB = group.pushSlice(newSliceEx({title: 'b', start: 1.5, duration: 1})); - var sC = group.pushSlice(newSliceEx({title: 'c', start: 5, duration: 0})); - - group.createSubSlices(); - - assert.equal(group.topLevelSlices.length, 2); - assert.deepEqual(group.topLevelSlices, [sA, sC]); - - assert.equal(sA.subSlices.length, 1); - assert.deepEqual(sA.subSlices, [sB]); - assert.equal(sA.selfTime, 2); - - assert.equal(sA, sB.parentSlice); - assert.equal(group.findSliceAtTs(1), sA); - assert.equal(group.findSliceAtTs(2), sB); - assert.equal(group.findSliceAtTs(3), sA); - assert.equal(group.findSliceAtTs(4.5), undefined); - assert.equal(group.findSliceAtTs(5), sC); - }); - - test('subSlicesBuilderOnGroup2', function() { - var group = new SliceGroup(newFakeThread()); - - // Pattern being tested: - // [ a ] [ d ] - // [ b ] - // [ c ] - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, duration: 3})); - var sB = group.pushSlice(newSliceEx({title: 'b', start: 1.5, duration: 1})); - var sC = group.pushSlice(newSliceEx( - {title: 'c', start: 1.75, duration: 0.5})); - var sD = group.pushSlice(newSliceEx( - {title: 'd', start: 5, duration: 0.25})); - - group.createSubSlices(); - - assert.equal(group.topLevelSlices.length, 2); - assert.deepEqual(group.topLevelSlices, [sA, sD]); - - assert.equal(sA.subSlices.length, 1); - assert.deepEqual(sA.subSlices, [sB]); - assert.equal(sA.selfTime, 2); - - assert.equal(sA, sB.parentSlice); - assert.equal(sB.subSlices.length, 1); - assert.deepEqual(sB.subSlices, [sC]); - assert.equal(sB.selfTime, 0.5); - - assert.equal(sB, sC.parentSlice); - assert.equal(group.findSliceAtTs(2), sC); - }); - - test('findFirstSlice', function() { - var group = new SliceGroup(newFakeThread()); - // Pattern being tested: - // [ a ] [ d ] - // [b] [ c ] where b is dur=0 - var sC = group.pushSlice(newSliceEx({title: 'c', start: 2, end: 3})); - var sD = group.pushSlice(newSliceEx({title: 'd', start: 5, end: 6})); - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, end: 4})); - var sB = group.pushSlice(newSliceEx({title: 'b', start: 1, end: 1})); - - assert.throws(group.findFirstSlice); - - group.createSubSlices(); - - assert.equal(group.findFirstSlice(), sA); - }); - - test('findNextSliceAfterBasic', function() { - var group = new SliceGroup(newFakeThread()); - // Pattern being tested: - // [ a ] [ d ] - // [b] [ c ] where b is dur=0 - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, end: 4})); - var sB = group.pushSlice(newSliceEx({title: 'b', start: 1, end: 1})); - var sC = group.pushSlice(newSliceEx({title: 'c', start: 2, end: 3})); - var sD = group.pushSlice(newSliceEx({title: 'd', start: 5, end: 6})); - - group.createSubSlices(); - - assert.equal(group.findNextSliceAfter(0, 0), sA); - assert.equal(group.findNextSliceAfter(1, sA.guid), sB); - assert.equal(group.findNextSliceAfter(1, sB.guid), sC); - assert.equal(group.findNextSliceAfter(2, sC.guid), sD); - assert.equal(group.findNextSliceAfter(6, 0), undefined); - }); - - test('subSlicesBuilderTolerateFPInaccuracy', function() { - var group = new SliceGroup(newFakeThread()); - - // Pattern being tested: - // [ a ] - // [ b ] where b.end contains a tiny FP calculation error. - var sA = group.pushSlice(newSliceEx({title: 'a', start: 1, duration: 3})); - var sB = group.pushSlice(newSliceEx( - {title: 'b', start: 1, duration: 3.0000000001})); - - group.createSubSlices(); - - assert.equal(group.topLevelSlices.length, 1); - assert.deepEqual(group.topLevelSlices, [sA]); - - assert.equal(sA.subSlices.length, 1); - assert.deepEqual(sA.subSlices, [sB]); - assert.equal(sA, sB.parentSlice); - assert.equal(group.findSliceAtTs(1), sB); - assert.equal(group.findSliceAtTs(3), sB); - }); - - test('basicMerge', function() { - function TestSlice( - cat, title, colorId, start, args, opt_duration, - opt_cpuStart, opt_cpuDuration) { - Slice.call(this, cat, title, colorId, start, args, opt_duration, - opt_cpuStart, opt_cpuDuration); - } - TestSlice.prototype = { - __proto__: Slice.prototype - }; - - var thread = newFakeThread(); - var a = new SliceGroup(thread, TestSlice); - var b = new SliceGroup(thread, TestSlice); - a.beginSlice('', 'one', 1); - a.endSlice(2); - b.beginSlice('', 'two', 3); - b.endSlice(5); - - var m = SliceGroup.merge(a, b); - assert.equal(m.slices.length, 2); - - assert.equal(m.slices[0].title, 'one'); - assert.equal(m.slices[0].start, 1); - assert.equal(m.slices[0].duration, 1); - - assert.equal(m.slices[1].title, 'two'); - assert.equal(m.slices[1].start, 3); - assert.equal(m.slices[1].duration, 2); - - // ensure constructor merged correctly - assert.equal(m.sliceConstructor, TestSlice); - }); - - test('nestedMerge', function() { - var thread = newFakeThread(); - var a = new SliceGroup(thread); - var b = new SliceGroup(thread); - a.beginSlice('', 'one', 1); - a.endSlice(4); - b.beginSlice('', 'two', 2); - b.endSlice(3); - - var m = SliceGroup.merge(a, b); - assert.equal(m.slices.length, 2); - - assert.equal(m.slices[0].title, 'one'); - assert.equal(m.slices[0].start, 1); - assert.equal(m.slices[0].duration, 3); - - assert.equal(m.slices[1].title, 'two'); - assert.equal(m.slices[1].start, 2); - assert.equal(m.slices[1].duration, 1); - }); - - test('startSplitMerge', function() { - var thread = newFakeThread(); - var a = new SliceGroup(thread); - var b = new SliceGroup(thread); - a.beginSlice('', 'one', 2); - a.endSlice(4); - b.beginSlice('', 'two', 1); - b.endSlice(3); - - var m = SliceGroup.merge(a, b); - assert.equal(m.slices.length, 3); - - assert.equal(m.slices[0].title, 'two'); - assert.equal(m.slices[0].start, 1); - assert.equal(m.slices[0].duration, 1); - - assert.equal(m.slices[1].title, 'one'); - assert.equal(m.slices[1].start, 2); - assert.equal(m.slices[1].duration, 2); - - assert.equal(m.slices[2].title, 'two (cont.)'); - assert.equal(m.slices[2].start, 2); - assert.equal(m.slices[2].duration, 1); - }); - - test('startSplitTwoMerge', function() { - var thread = newFakeThread(); - var a = new SliceGroup(thread); - var b = new SliceGroup(thread); - a.beginSlice('', 'one', 3); - a.endSlice(6); - b.beginSlice('', 'two', 1); - b.beginSlice('', 'three', 2); - b.endSlice(4); - b.endSlice(5); - - var m = SliceGroup.merge(a, b); - assert.equal(m.slices.length, 5); - - assert.equal(m.slices[0].title, 'two'); - assert.equal(m.slices[0].start, 1); - assert.equal(m.slices[0].duration, 2); - - assert.equal(m.slices[1].title, 'three'); - assert.equal(m.slices[1].start, 2); - assert.equal(m.slices[1].duration, 1); - - assert.equal(m.slices[2].title, 'one'); - assert.equal(m.slices[2].start, 3); - assert.equal(m.slices[2].duration, 3); - - assert.equal(m.slices[3].title, 'two (cont.)'); - assert.equal(m.slices[3].start, 3); - assert.equal(m.slices[3].duration, 2); - - assert.equal(m.slices[4].title, 'three (cont.)'); - assert.equal(m.slices[4].start, 3); - assert.equal(m.slices[4].duration, 1); - }); - - test('startSplitTwiceMerge', function() { - var thread = newFakeThread(); - var a = new SliceGroup(thread); - var b = new SliceGroup(thread); - a.beginSlice('', 'one', 2); - a.beginSlice('', 'two', 3); - a.endSlice(5); - a.endSlice(6); - b.beginSlice('', 'three', 1); - b.endSlice(4); - - var m = SliceGroup.merge(a, b); - assert.equal(m.slices.length, 5); - - assert.equal(m.slices[0].title, 'three'); - assert.equal(m.slices[0].start, 1); - assert.equal(m.slices[0].duration, 1); - - assert.equal(m.slices[1].title, 'one'); - assert.equal(m.slices[1].start, 2); - assert.equal(m.slices[1].duration, 4); - - assert.equal(m.slices[2].title, 'three (cont.)'); - assert.equal(m.slices[2].start, 2); - assert.equal(m.slices[2].duration, 1); - - assert.equal(m.slices[3].title, 'two'); - assert.equal(m.slices[3].start, 3); - assert.equal(m.slices[3].duration, 2); - - assert.equal(m.slices[4].title, 'three (cont.)'); - assert.equal(m.slices[4].start, 3); - assert.equal(m.slices[4].duration, 1); - }); - - test('endSplitMerge', function() { - var thread = newFakeThread(); - var a = new SliceGroup(thread); - var b = new SliceGroup(thread); - a.beginSlice('', 'one', 1); - a.endSlice(3); - b.beginSlice('', 'two', 2); - b.endSlice(4); - - var m = SliceGroup.merge(a, b); - assert.equal(m.slices.length, 3); - - assert.equal(m.slices[0].title, 'one'); - assert.equal(m.slices[0].start, 1); - assert.equal(m.slices[0].duration, 2); - - assert.equal(m.slices[1].title, 'two'); - assert.equal(m.slices[1].start, 2); - assert.equal(m.slices[1].duration, 1); - - assert.equal(m.slices[2].title, 'two (cont.)'); - assert.equal(m.slices[2].start, 3); - assert.equal(m.slices[2].duration, 1); - }); - - test('endSplitTwoMerge', function() { - var thread = newFakeThread(); - var a = new SliceGroup(thread); - var b = new SliceGroup(thread); - a.beginSlice('', 'one', 1); - a.endSlice(4); - b.beginSlice('', 'two', 2); - b.beginSlice('', 'three', 3); - b.endSlice(5); - b.endSlice(6); - - var m = SliceGroup.merge(a, b); - assert.equal(m.slices.length, 5); - - assert.equal(m.slices[0].title, 'one'); - assert.equal(m.slices[0].start, 1); - assert.equal(m.slices[0].duration, 3); - - assert.equal(m.slices[1].title, 'two'); - assert.equal(m.slices[1].start, 2); - assert.equal(m.slices[1].duration, 2); - - assert.equal(m.slices[2].title, 'three'); - assert.equal(m.slices[2].start, 3); - assert.equal(m.slices[2].duration, 1); - - assert.equal(m.slices[3].title, 'two (cont.)'); - assert.equal(m.slices[3].start, 4); - assert.equal(m.slices[3].duration, 2); - - assert.equal(m.slices[4].title, 'three (cont.)'); - assert.equal(m.slices[4].start, 4); - assert.equal(m.slices[4].duration, 1); - }); - - test('endSplitTwiceMerge', function() { - var thread = newFakeThread(); - var a = new SliceGroup(thread); - var b = new SliceGroup(thread); - a.beginSlice('', 'one', 1); - a.beginSlice('', 'two', 2); - a.endSlice(4); - a.endSlice(5); - b.beginSlice('', 'three', 3); - b.endSlice(6); - - var m = SliceGroup.merge(a, b); - assert.equal(m.slices.length, 5); - - assert.equal(m.slices[0].title, 'one'); - assert.equal(m.slices[0].start, 1); - assert.equal(m.slices[0].duration, 4); - - assert.equal(m.slices[1].title, 'two'); - assert.equal(m.slices[1].start, 2); - assert.equal(m.slices[1].duration, 2); - - assert.equal(m.slices[2].title, 'three'); - assert.equal(m.slices[2].start, 3); - assert.equal(m.slices[2].duration, 1); - - assert.equal(m.slices[3].title, 'three (cont.)'); - assert.equal(m.slices[3].start, 4); - assert.equal(m.slices[3].duration, 1); - - assert.equal(m.slices[4].title, 'three (cont.)'); - assert.equal(m.slices[4].start, 5); - assert.equal(m.slices[4].duration, 1); - }); - - // Input: - // A: | one | | two | - // - // B: | three | - // - // Output: - // | one | three | two | - // | three | | three | - test('splitTwiceMerge', function() { - var thread = newFakeThread(); - var a = new SliceGroup(thread); - var b = new SliceGroup(thread); - a.beginSlice('', 'one', 1); - a.endSlice(3); - a.beginSlice('', 'two', 4); - a.endSlice(6); - b.beginSlice('', 'three', 2); - b.endSlice(5); - - var m = SliceGroup.merge(a, b); - assert.equal(m.slices.length, 5); - - assert.equal(m.slices[0].title, 'one'); - assert.equal(m.slices[0].start, 1); - assert.equal(m.slices[0].duration, 2); - - assert.equal(m.slices[1].title, 'three'); - assert.equal(m.slices[1].start, 2); - assert.equal(m.slices[1].duration, 1); - - assert.equal(m.slices[2].title, 'three (cont.)'); - assert.equal(m.slices[2].start, 3); - assert.equal(m.slices[2].duration, 1); - - assert.equal(m.slices[3].title, 'two'); - assert.equal(m.slices[3].start, 4); - assert.equal(m.slices[3].duration, 2); - - assert.equal(m.slices[4].title, 'three (cont.)'); - assert.equal(m.slices[4].start, 4); - assert.equal(m.slices[4].duration, 1); - }); - - test('bounds', function() { - var group = new SliceGroup(newFakeThread()); - group.updateBounds(); - assert.isUndefined(group.bounds.min); - assert.isUndefined(group.bounds.max); - - group.pushSlice(newSliceEx({start: 1, duration: 3})); - group.pushSlice(newSliceEx({start: 7, duration: 2})); - group.updateBounds(); - assert.equal(group.bounds.min, 1); - assert.equal(group.bounds.max, 9); - }); - - test('boundsWithPartial', function() { - var group = new SliceGroup(newFakeThread()); - group.beginSlice('', 'a', 7); - group.updateBounds(); - assert.equal(group.bounds.min, 7); - assert.equal(group.bounds.max, 7); - }); - - test('boundsWithTwoPartials', function() { - var group = new SliceGroup(newFakeThread()); - group.beginSlice('', 'a', 0); - group.beginSlice('', 'a', 1); - group.updateBounds(); - assert.equal(group.bounds.min, 0); - assert.equal(group.bounds.max, 1); - }); - - test('boundsWithBothPartialAndRegular', function() { - var group = new SliceGroup(newFakeThread()); - group.updateBounds(); - assert.isUndefined(group.bounds.min); - assert.isUndefined(group.bounds.max); - - group.pushSlice(newSliceEx({start: 1, duration: 3})); - group.beginSlice('', 'a', 7); - group.updateBounds(); - assert.equal(group.bounds.min, 1); - assert.equal(group.bounds.max, 7); - }); - - test('autocloserBasic', function() { - var group = new SliceGroup(newFakeThread()); - assert.equal(0, group.openSliceCount); - - group.pushSlice(newSliceEx({title: 'a', start: 1, duration: 0.5})); - - group.beginSlice('', 'b', 2); - group.beginSlice('', 'c', 2.5); - group.endSlice(3); - - group.autoCloseOpenSlices(); - group.updateBounds(); - - assert.equal(group.bounds.min, 1); - assert.equal(group.bounds.max, 3); - assert.equal(group.slices.length, 3); - - assert.equal(group.slices[0].title, 'a'); - assert.isFalse(group.slices[0].didNotFinish); - - assert.equal(group.slices[1].title, 'b'); - assert.isTrue(group.slices[1].didNotFinish); - assert.equal(group.slices[1].duration, 1); - - assert.equal(group.slices[2].title, 'c'); - assert.isFalse(group.slices[2].didNotFinish); - }); - - test('autocloserWithSubTasks', function() { - var group = new SliceGroup(newFakeThread()); - assert.equal(0, group.openSliceCount); - - group.beginSlice('', 'a', 1); - group.beginSlice('', 'b1', 2); - group.endSlice(3); - group.beginSlice('', 'b2', 3); - - group.autoCloseOpenSlices(); - assert.equal(group.slices.length, 3); - - assert.equal(group.slices[0].title, 'a'); - assert.isTrue(group.slices[0].didNotFinish); - assert.equal(group.slices[0].duration, 2); - - assert.equal(group.slices[1].title, 'b1'); - assert.isFalse(group.slices[1].didNotFinish); - assert.equal(group.slices[1].duration, 1); - - assert.equal(group.slices[2].title, 'b2'); - assert.isTrue(group.slices[2].didNotFinish); - assert.equal(group.slices[2].duration, 0); - }); - - test('autocloseCompleteSlice', function() { - var group = new SliceGroup(newFakeThread()); - - group.pushCompleteSlice('', 'a', 1, undefined); - group.pushCompleteSlice('', 'b', 2, 3); - - group.autoCloseOpenSlices(); - assert.equal(group.slices.length, 2); - - assert.equal(group.slices[0].title, 'a'); - assert.isTrue(group.slices[0].didNotFinish); - assert.equal(group.slices[0].duration, 4); - - assert.equal(group.slices[1].title, 'b'); - assert.isFalse(group.slices[1].didNotFinish); - assert.equal(group.slices[1].duration, 3); - }); - - test('sliceGroupStableId', function() { - var model = new tr.Model(); - var process = model.getOrCreateProcess(123); - var thread = process.getOrCreateThread(456); - var group = new SliceGroup(thread); - - assert.equal(process.stableId, 123); - assert.equal(thread.stableId, '123.456'); - assert.equal(group.stableId, '123.456.SliceGroup'); - }); - - test('getSlicesOfName', function() { - var group = new SliceGroup(newFakeThread()); - var expected = []; - - for (var i = 0; i < 10; i++) { - var aSlice = newSliceEx({title: 'a', start: i, duration: i + 1}); - group.pushSlice(aSlice); - group.pushSlice(newSliceEx({title: 'b', start: i + 1, duration: i + 2})); - expected.push(aSlice); - } - - assert.deepEqual(group.getSlicesOfName('a'), expected); - }); - - test('iterSlicesInTimeRange', function() { - var group = new SliceGroup(newFakeThread()); - var expected = []; - - for (var i = 0; i < 10; i++) { - var slice = newSliceEx({title: 'a', start: i, duration: 1}); - group.pushSlice(slice); - if (4 <= i && i <= 7) - expected.push(slice); - } - group.createSubSlices(); - - var observed = []; - group.iterSlicesInTimeRange(function(slice) { observed.push(slice); }, - 4.5, 7.5); - assert.deepEqual(observed, expected); - }); - - test('computeCpuDurationNoOverlap', function() { - var model = new tr.Model(); - var SCHEDULING_STATE = tr.model.SCHEDULING_STATE; - var process = model.getOrCreateProcess(123); - var t = process.getOrCreateThread(456); - t.timeSlices = [newThreadSlice(t, SCHEDULING_STATE.RUNNING, 20, 20), - newThreadSlice(t, SCHEDULING_STATE.SLEEPING, 40, 10), - newThreadSlice(t, SCHEDULING_STATE.RUNNING, 50, 10)]; - var group = new SliceGroup(t); - group.pushSlice(newSliceEx({title: 'draw', start: 0, duration: 20})); - group.pushSlice(newSliceEx({title: 'render', start: 60, duration: 20})); - group.createSubSlices(); - assert.equal(group.slices[0].cpuDuration, 0); - assert.equal(group.slices[1].cpuDuration, 0); - }); - - test('computeCpuDurationPartialOverlap', function() { - var model = new tr.Model(); - var SCHEDULING_STATE = tr.model.SCHEDULING_STATE; - var process = model.getOrCreateProcess(123); - var t = process.getOrCreateThread(456); - t.timeSlices = [newThreadSlice(t, SCHEDULING_STATE.RUNNING, 20, 20), - newThreadSlice(t, SCHEDULING_STATE.SLEEPING, 40, 10), - newThreadSlice(t, SCHEDULING_STATE.RUNNING, 50, 10)]; - var group = new SliceGroup(t); - group.pushSlice(newSliceEx({title: 'draw', start: 10, duration: 30})); - group.pushSlice(newSliceEx({title: 'render', start: 50, duration: 20})); - group.createSubSlices(); - assert.equal(group.slices[0].cpuDuration, 20); - assert.equal(group.slices[1].cpuDuration, 10); - }); - - test('computeCpuDurationFullOverlap', function() { - var model = new tr.Model(); - var SCHEDULING_STATE = tr.model.SCHEDULING_STATE; - var process = model.getOrCreateProcess(123); - var t = process.getOrCreateThread(456); - t.timeSlices = [newThreadSlice(t, SCHEDULING_STATE.RUNNING, 20, 20), - newThreadSlice(t, SCHEDULING_STATE.SLEEPING, 40, 10), - newThreadSlice(t, SCHEDULING_STATE.RUNNING, 50, 20)]; - var group = new SliceGroup(t); - group.pushSlice(newSliceEx({title: 'draw', start: 20, duration: 30})); - group.pushSlice(newSliceEx({title: 'render', start: 50, duration: 20})); - group.createSubSlices(); - assert.equal(group.slices[0].cpuDuration, 20); - assert.equal(group.slices[1].cpuDuration, 20); - }); - - test('computeCpuSelfDurationWithSubslices', function() { - var model = new tr.Model(); - var SCHEDULING_STATE = tr.model.SCHEDULING_STATE; - var process = model.getOrCreateProcess(123); - var t = process.getOrCreateThread(456); - t.timeSlices = [newThreadSlice(t, SCHEDULING_STATE.RUNNING, 20, 20), - newThreadSlice(t, SCHEDULING_STATE.SLEEPING, 40, 10), - newThreadSlice(t, SCHEDULING_STATE.RUNNING, 50, 20)]; - var group = new SliceGroup(t); - group.pushSlice(newSliceEx({title: 'draw', start: 20, duration: 30})); - group.pushSlice(newSliceEx({title: 'render', start: 21, duration: 8})); - group.pushSlice(newSliceEx({title: 'flush', start: 29, duration: 11})); - group.createSubSlices(); - assert.equal(group.slices[0].cpuDuration, 20); - assert.equal(group.slices[0].cpuSelfTime, 1); - assert.equal(group.slices[1].cpuDuration, 8); - assert.equal(group.slices[1].cpuSelfTime, 8); - assert.equal(group.slices[2].cpuDuration, 11); - assert.equal(group.slices[2].cpuSelfTime, 11); - }); - - test('computeCpuDurationSmallTimeslices', function() { - var model = new tr.Model(); - var SCHEDULING_STATE = tr.model.SCHEDULING_STATE; - var process = model.getOrCreateProcess(123); - var t = process.getOrCreateThread(456); - t.timeSlices = [newThreadSlice(t, SCHEDULING_STATE.RUNNING, 20, 1), - newThreadSlice(t, SCHEDULING_STATE.SLEEPING, 21, 1), - newThreadSlice(t, SCHEDULING_STATE.RUNNING, 22, 1), - newThreadSlice(t, SCHEDULING_STATE.SLEEPING, 23, 1), - newThreadSlice(t, SCHEDULING_STATE.RUNNING, 24, 1), - newThreadSlice(t, SCHEDULING_STATE.SLEEPING, 25, 1), - newThreadSlice(t, SCHEDULING_STATE.RUNNING, 26, 1), - newThreadSlice(t, SCHEDULING_STATE.SLEEPING, 27, 1), - newThreadSlice(t, SCHEDULING_STATE.RUNNING, 28, 1), - newThreadSlice(t, SCHEDULING_STATE.SLEEPING, 29, 1), - newThreadSlice(t, SCHEDULING_STATE.RUNNING, 30, 1)]; - var group = new SliceGroup(t); - group.pushSlice(newSliceEx( - {title: 'draw', start: 20, duration: 11})); // 20,[22,24,26,28],30 - group.pushSlice(newSliceEx( - {title: 'render', start: 22, duration: 8})); // 22,[24, 26, 28] - group.pushSlice(newSliceEx( - {title: 'flush', start: 24, duration: 6})); // 24, 26, 28 - group.createSubSlices(); - assert.equal(group.slices[0].cpuDuration, 6); - assert.equal(group.slices[0].cpuSelfTime, 2); - assert.equal(group.slices[1].cpuDuration, 4); - assert.equal(group.slices[1].cpuSelfTime, 1); - assert.equal(group.slices[2].cpuDuration, 3); - assert.equal(group.slices[2].cpuSelfTime, 3); - }); - - test('sliceParentContainerSetAtPush', function() { - var m = newModel(function(m) { - m.process = m.getOrCreateProcess(123); - m.thread = m.process.getOrCreateThread(456); - m.group = new SliceGroup(m.thread); - - m.sA = m.group.pushSlice(newSliceEx( - { title: 'sA', start: 0.0, duration: 10.0 })); - - m.group.createSubSlices(); - }); - - assert.deepEqual(m.sA.parentContainer, m.thread); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/slice_test.html b/chromium/third_party/catapult/tracing/tracing/model/slice_test.html deleted file mode 100644 index a80c080b7e0..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/slice_test.html +++ /dev/null @@ -1,219 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/slice_group.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Slice = tr.model.Slice; - var SliceGroup = tr.model.SliceGroup; - var newSliceEx = tr.c.TestUtils.newSliceEx; - var newFakeThread = tr.c.TestUtils.newFakeThread; - - test('findDescendentSlice', function() { - var group = new SliceGroup(newFakeThread()); - - var sA = group.pushSlice(newSliceEx( - { title: 'sA', start: 0.0, duration: 10.0 })); - var sB = group.pushSlice(newSliceEx( - { title: 'sB', start: 0.0, duration: 4.0 })); - var sC = group.pushSlice(newSliceEx( - { title: 'sC', start: 0.0, duration: 2.0 })); - - group.createSubSlices(); - - assert.deepEqual(sB, sA.findDescendentSlice('sB')); - assert.deepEqual(sC, sA.findDescendentSlice('sC')); - assert.isUndefined(sA.findDescendentSlice('sD')); - }); - - test('findTopmostSlicesRelativeToThisSliceBaseCase', function() { - var PREDICATE = slice => slice.title.startsWith('sC'); - - var group = new SliceGroup(newFakeThread()); - - var sC1 = group.pushSlice(newSliceEx( - { title: 'sC1', start: 0.0, duration: 10.0 })); - var sC2 = group.pushSlice(newSliceEx( - { title: 'sC2', start: 0.0, duration: 4.0 })); - - group.createSubSlices(); - - var foundSlices = []; - for (var slice of sC1.findTopmostSlicesRelativeToThisSlice(PREDICATE)) - foundSlices.push(slice); - - assert.deepEqual([sC1], foundSlices); - }); - - test('findTopmostSlicesRelativeToThisSliceRecursive', function() { - var PREDICATE = slice => slice.title.startsWith('sC'); - - var group = new SliceGroup(newFakeThread()); - - var sD = group.pushSlice(newSliceEx( - { title: 'sD', start: 0.0, duration: 10.0 })); - var sC1 = group.pushSlice(newSliceEx( - { title: 'sC1', start: 0.0, duration: 4.0 })); - var sC2 = group.pushSlice(newSliceEx( - { title: 'sC2', start: 6.0, duration: 3.0 })); - - group.createSubSlices(); - - var foundSlices = []; - for (var slice of sD.findTopmostSlicesRelativeToThisSlice(PREDICATE)) - foundSlices.push(slice); - assert.deepEqual([sC1, sC2], foundSlices); - }); - - test('iterateAllDescendents', function() { - var group = new SliceGroup(newFakeThread()); - - var sA = group.pushSlice(newSliceEx( - { title: 'sA', start: 0.0, duration: 10.0 })); - var sB = group.pushSlice(newSliceEx( - { title: 'sB', start: 0.0, duration: 4.0 })); - var sC = group.pushSlice(newSliceEx( - { title: 'sC', start: 0.0, duration: 2.0 })); - - group.createSubSlices(); - - assert.deepEqual(sA.descendentSlices, [sB, sC]); - assert.deepEqual(sC.descendentSlices, []); - }); - - test('mostTopLevelSlice', function() { - var group = new SliceGroup(newFakeThread()); - - var sA = group.pushSlice(newSliceEx( - { title: 'sA', start: 0.0, duration: 10.0 })); - var sB = group.pushSlice(newSliceEx( - { title: 'sB', start: 0.0, duration: 4.0 })); - var sC = group.pushSlice(newSliceEx( - { title: 'sC', start: 0.0, duration: 2.0 })); - - group.createSubSlices(); - - assert.equal(sA.mostTopLevelSlice, sA); - assert.equal(sB.mostTopLevelSlice, sA); - assert.equal(sC.mostTopLevelSlice, sA); - }); - - test('iterateAllAncestors', function() { - var group = new SliceGroup(newFakeThread()); - - var sA = group.pushSlice(newSliceEx( - { title: 'sA', start: 0.0, duration: 10.0 })); - var sB = group.pushSlice(newSliceEx( - { title: 'sB', start: 0.0, duration: 4.0 })); - var sC = group.pushSlice(newSliceEx( - { title: 'sC', start: 0.0, duration: 2.0 })); - - group.createSubSlices(); - - // Note that we iterate ancestors from the leaves to the root - assert.deepEqual(sC.ancestorSlices, [sB, sA]); - assert.deepEqual(sA.ancestorSlices, []); - }); - - test('iterateAllSubsequentSlices', function() { - var group = new SliceGroup(newFakeThread()); - - // [ A ] - // [ B ][ D ][F] - // [C] [E] - - var sA = group.pushSlice(newSliceEx( - { title: 'sA', start: 0.0, duration: 10.0 })); - var sB = group.pushSlice(newSliceEx( - { title: 'sB', start: 0.0, duration: 4.0 })); - var sC = group.pushSlice(newSliceEx( - { title: 'sC', start: 0.0, duration: 2.0 })); - var sD = group.pushSlice(newSliceEx( - { title: 'sD', start: 5.0, duration: 2.0 })); - var sE = group.pushSlice(newSliceEx( - { title: 'sE', start: 5.0, duration: 1.0 })); - var sF = group.pushSlice(newSliceEx( - { title: 'sF', start: 8.0, duration: 2.0 })); - - group.createSubSlices(); - - assert.deepEqual(sA.subsequentSlices, [sB, sC, sD, sE, sF]); - assert.deepEqual(sD.subsequentSlices, [sE, sF]); - assert.deepEqual(sF.subsequentSlices, []); - }); - - test('ancestorAndSubsequentSlices', function() { - var group = new SliceGroup(newFakeThread()); - - // [ A ] - // [ B ][ D ][F] - // [C] [E] - - var sA = group.pushSlice(newSliceEx( - { title: 'sA', start: 0.0, duration: 10.0 })); - var sB = group.pushSlice(newSliceEx( - { title: 'sB', start: 0.0, duration: 4.0 })); - var sC = group.pushSlice(newSliceEx( - { title: 'sC', start: 0.0, duration: 2.0 })); - var sD = group.pushSlice(newSliceEx( - { title: 'sD', start: 5.0, duration: 2.0 })); - var sE = group.pushSlice(newSliceEx( - { title: 'sE', start: 5.0, duration: 1.0 })); - var sF = group.pushSlice(newSliceEx( - { title: 'sF', start: 8.0, duration: 2.0 })); - - group.createSubSlices(); - - assert.deepEqual(sD.ancestorAndSubsequentSlices, [sD, sA, sE, sF]); - }); - - test('entireHierarchy', function() { - var group = new SliceGroup(newFakeThread()); - - // [ A ] - // [ B ][ D ][F] - // [C] [E] - - var sA = group.pushSlice(newSliceEx( - { title: 'sA', start: 0.0, duration: 10.0 })); - var sB = group.pushSlice(newSliceEx( - { title: 'sB', start: 0.0, duration: 4.0 })); - var sC = group.pushSlice(newSliceEx( - { title: 'sC', start: 0.0, duration: 2.0 })); - var sD = group.pushSlice(newSliceEx( - { title: 'sD', start: 5.0, duration: 2.0 })); - var sE = group.pushSlice(newSliceEx( - { title: 'sE', start: 5.0, duration: 1.0 })); - var sF = group.pushSlice(newSliceEx( - { title: 'sF', start: 8.0, duration: 2.0 })); - - group.createSubSlices(); - - assert.deepEqual(sD.entireHierarchy, [sA, sB, sC, sD, sE, sF]); - }); - - test('stableId', function() { - var thread = newFakeThread(); - var group = thread.sliceGroup; - - var sA = group.pushSlice(newSliceEx( - { title: 'sA', start: 0.0, duration: 10.0 })); - var sB = group.pushSlice(newSliceEx( - { title: 'sB', start: 10.0, duration: 20.0 })); - var sC = group.pushSlice(newSliceEx( - { title: 'sC', start: 20.0, duration: 30.0 })); - - assert.equal(group.stableId + '.0', sA.stableId); - assert.equal(group.stableId + '.1', sB.stableId); - assert.equal(group.stableId + '.2', sC.stableId); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/source_info/js_source_info.html b/chromium/third_party/catapult/tracing/tracing/model/source_info/js_source_info.html deleted file mode 100644 index bb4370e2c63..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/source_info/js_source_info.html +++ /dev/null @@ -1,55 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/source_info/source_info.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model.source_info', function() { - function JSSourceInfo(file, line, column, isNative, scriptId, state) { - tr.model.source_info.SourceInfo.call(this, file, line, column); - - this.isNative_ = isNative; - this.scriptId_ = scriptId; - this.state_ = state; - } - - JSSourceInfo.prototype = { - __proto__: tr.model.source_info.SourceInfo.prototype, - - get state() { - return this.state_; - }, - - get isNative() { - return this.isNative_; - }, - - get scriptId() { - return this.scriptId_; - }, - - toString: function() { - var str = this.isNative_ ? '[native v8] ' : ''; - return str + - tr.model.source_info.SourceInfo.prototype.toString.call(this); - } - }; - - return { - JSSourceInfo: JSSourceInfo, - JSSourceState: { - COMPILED: 'compiled', - OPTIMIZABLE: 'optimizable', - OPTIMIZED: 'optimized', - UNKNOWN: 'unknown' - } - }; -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/source_info/source_info.html b/chromium/third_party/catapult/tracing/tracing/model/source_info/source_info.html deleted file mode 100644 index 19e36dfc1d8..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/source_info/source_info.html +++ /dev/null @@ -1,58 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model.source_info', function() { - function SourceInfo(file, opt_line, opt_column) { - this.file_ = file; - this.line_ = opt_line || -1; - this.column_ = opt_column || -1; - } - - SourceInfo.prototype = { - get file() { - return this.file_; - }, - - get line() { - return this.line_; - }, - - get column() { - return this.column_; - }, - - get domain() { - if (!this.file_) - return undefined; - var domain = this.file_.match(/(.*:\/\/[^:\/]*)/i); - return domain ? domain[1] : undefined; - }, - - toString: function() { - var str = ''; - - if (this.file_) - str += this.file_; - if (this.line_ > 0) - str += ':' + this.line_; - if (this.column_ > 0) - str += ':' + this.column_; - return str; - } - }; - - return { - SourceInfo: SourceInfo - }; -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/source_info/source_info_test.html b/chromium/third_party/catapult/tracing/tracing/model/source_info/source_info_test.html deleted file mode 100644 index 344dba0fb54..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/source_info/source_info_test.html +++ /dev/null @@ -1,27 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/source_info/source_info.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('domain', function() { - var urlDomains = { - 'http://www.google.com': 'http://www.google.com', - 'http://www.google.com/bla': 'http://www.google.com', - 'http://www.google.com:1234': 'http://www.google.com', - 'bad url': undefined - }; - for (var url in urlDomains) { - var sourceInfo = new tr.model.source_info.SourceInfo(url); - assert.equal(urlDomains[url], sourceInfo.domain); - } - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/stack_frame.html b/chromium/third_party/catapult/tracing/tracing/model/stack_frame.html deleted file mode 100644 index 50f3126a1e5..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/stack_frame.html +++ /dev/null @@ -1,103 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/base.html"> -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - function StackFrame(parentFrame, id, title, colorId, opt_sourceInfo) { - if (id === undefined) - throw new Error('id must be given'); - this.parentFrame_ = parentFrame; - this.id = id; - this.title_ = title; - this.colorId = colorId; - this.children = []; - this.sourceInfo_ = opt_sourceInfo; - - if (this.parentFrame_) - this.parentFrame_.addChild(this); - } - - StackFrame.prototype = { - get parentFrame() { - return this.parentFrame_; - }, - - get title() { - if (this.sourceInfo_) { - var src = this.sourceInfo_.toString(); - return this.title_ + (src === '' ? '' : ' ' + src); - } - return this.title_; - }, - - /** - * Attempts to find the domain of the origin of the script either from this - * stack trace or from its ancestors. - */ - get domain() { - var result = 'unknown'; - if (this.sourceInfo_ && this.sourceInfo_.domain) - result = this.sourceInfo_.domain; - if (result === 'unknown' && this.parentFrame) - result = this.parentFrame.domain; - return result; - }, - - get sourceInfo() { - return this.sourceInfo_; - }, - - set parentFrame(parentFrame) { - if (this.parentFrame_) - this.parentFrame_.removeChild(this); - this.parentFrame_ = parentFrame; - if (this.parentFrame_) - this.parentFrame_.addChild(this); - }, - - addChild: function(child) { - this.children.push(child); - }, - - removeChild: function(child) { - var i = this.children.indexOf(child.id); - if (i == -1) - throw new Error('omg'); - this.children.splice(i, 1); - }, - - removeAllChildren: function() { - for (var i = 0; i < this.children.length; i++) - this.children[i].parentFrame_ = undefined; - this.children.splice(0, this.children.length); - }, - - /** - * Returns stackFrames where the most specific frame is first. - */ - get stackTrace() { - var stack = []; - var cur = this; - while (cur) { - stack.push(cur); - cur = cur.parentFrame; - } - return stack; - }, - - getUserFriendlyStackTrace: function() { - return this.stackTrace.map(function(x) { return x.title; }); - } - }; - - return { - StackFrame: StackFrame - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/stack_frame_test.html b/chromium/third_party/catapult/tracing/tracing/model/stack_frame_test.html deleted file mode 100644 index 1fee75ace26..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/stack_frame_test.html +++ /dev/null @@ -1,29 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/source_info/source_info.html"> -<link rel="import" href="/tracing/model/stack_frame.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('domain', function() { - var stackFrame1 = new tr.model.StackFrame(undefined, 1, '1', 1); - assert.equal('unknown', stackFrame1.domain); - - var sourceInfo = new tr.model.source_info.SourceInfo( - 'http://www.google.com:1234'); - var stackFrame2 = new tr.model.StackFrame( - stackFrame1, 2, '2', 2, sourceInfo); - assert.equal('http://www.google.com', stackFrame2.domain); - - var stackFrame3 = new tr.model.StackFrame(stackFrame2, 3, '3', 3); - assert.equal('http://www.google.com', stackFrame3.domain); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/thread.html b/chromium/third_party/catapult/tracing/tracing/model/thread.html deleted file mode 100644 index c11aeb13d1d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/thread.html +++ /dev/null @@ -1,334 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/guid.html"> -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/model/async_slice_group.html"> -<link rel="import" href="/tracing/model/event_container.html"> -<link rel="import" href="/tracing/model/slice_group.html"> -<link rel="import" href="/tracing/model/thread_slice.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the Thread class. - */ -tr.exportTo('tr.model', function() { - var AsyncSlice = tr.model.AsyncSlice; - var AsyncSliceGroup = tr.model.AsyncSliceGroup; - var Slice = tr.model.Slice; - var SliceGroup = tr.model.SliceGroup; - var ThreadSlice = tr.model.ThreadSlice; - var ThreadTimeSlice = tr.model.ThreadTimeSlice; - - /** - * A Thread stores all the trace events collected for a particular - * thread. We organize the synchronous slices on a thread by "subrows," where - * subrow 0 has all the root slices, subrow 1 those nested 1 deep, and so on. - * The asynchronous slices are stored in an AsyncSliceGroup object. - * - * The slices stored on a Thread should be instances of - * ThreadSlice. - * - * @constructor - * @extends {tr.model.EventContainer} - */ - function Thread(parent, tid) { - if (!parent) - throw new Error('Parent must be provided.'); - - tr.model.EventContainer.call(this); - this.parent = parent; - this.sortIndex = 0; - this.tid = tid; - this.name = undefined; - this.samples_ = undefined; // Set during createSubSlices - - var that = this; - - this.sliceGroup = new SliceGroup(this, ThreadSlice, 'slices'); - this.timeSlices = undefined; - this.kernelSliceGroup = new SliceGroup( - this, ThreadSlice, 'kernel-slices'); - this.asyncSliceGroup = new AsyncSliceGroup(this, 'async-slices'); - } - - Thread.prototype = { - __proto__: tr.model.EventContainer.prototype, - - get model() { - return this.parent.model; - }, - - get stableId() { - return this.parent.stableId + '.' + this.tid; - }, - - compareTo: function(that) { - return Thread.compare(this, that); - }, - - childEventContainers: function*() { - if (this.sliceGroup.length) - yield this.sliceGroup; - if (this.kernelSliceGroup.length) - yield this.kernelSliceGroup; - if (this.asyncSliceGroup.length) - yield this.asyncSliceGroup; - }, - - childEvents: function*() { - if (this.timeSlices) - yield * this.timeSlices; - }, - - iterateAllPersistableObjects: function(cb) { - cb(this); - if (this.sliceGroup.length) - cb(this.sliceGroup); - this.asyncSliceGroup.viewSubGroups.forEach(cb); - }, - - /** - * Shifts all the timestamps inside this thread forward by the amount - * specified. - */ - shiftTimestampsForward: function(amount) { - this.sliceGroup.shiftTimestampsForward(amount); - - if (this.timeSlices) { - for (var i = 0; i < this.timeSlices.length; i++) { - var slice = this.timeSlices[i]; - slice.start += amount; - } - } - - this.kernelSliceGroup.shiftTimestampsForward(amount); - this.asyncSliceGroup.shiftTimestampsForward(amount); - }, - - /** - * Determines whether this thread is empty. If true, it usually implies - * that it should be pruned from the model. - */ - get isEmpty() { - if (this.sliceGroup.length) - return false; - if (this.sliceGroup.openSliceCount) - return false; - if (this.timeSlices && this.timeSlices.length) - return false; - if (this.kernelSliceGroup.length) - return false; - if (this.asyncSliceGroup.length) - return false; - if (this.samples_.length) - return false; - return true; - }, - - /** - * Updates the bounds based on the - * current objects associated with the thread. - */ - updateBounds: function() { - this.bounds.reset(); - - this.sliceGroup.updateBounds(); - this.bounds.addRange(this.sliceGroup.bounds); - - this.kernelSliceGroup.updateBounds(); - this.bounds.addRange(this.kernelSliceGroup.bounds); - - this.asyncSliceGroup.updateBounds(); - this.bounds.addRange(this.asyncSliceGroup.bounds); - - if (this.timeSlices && this.timeSlices.length) { - this.bounds.addValue(this.timeSlices[0].start); - this.bounds.addValue( - this.timeSlices[this.timeSlices.length - 1].end); - } - - if (this.samples_ && this.samples_.length) { - this.bounds.addValue(this.samples_[0].start); - this.bounds.addValue( - this.samples_[this.samples_.length - 1].end); - } - }, - - addCategoriesToDict: function(categoriesDict) { - for (var i = 0; i < this.sliceGroup.length; i++) - categoriesDict[this.sliceGroup.slices[i].category] = true; - for (var i = 0; i < this.kernelSliceGroup.length; i++) - categoriesDict[this.kernelSliceGroup.slices[i].category] = true; - for (var i = 0; i < this.asyncSliceGroup.length; i++) - categoriesDict[this.asyncSliceGroup.slices[i].category] = true; - if (this.samples_) { - for (var i = 0; i < this.samples_.length; i++) - categoriesDict[this.samples_[i].category] = true; - } - }, - - autoCloseOpenSlices: function() { - this.sliceGroup.autoCloseOpenSlices(); - this.kernelSliceGroup.autoCloseOpenSlices(); - }, - - mergeKernelWithUserland: function() { - if (this.kernelSliceGroup.length > 0) { - var newSlices = SliceGroup.merge( - this.sliceGroup, this.kernelSliceGroup); - this.sliceGroup.slices = newSlices.slices; - this.kernelSliceGroup = new SliceGroup(this); - this.updateBounds(); - } - }, - - createSubSlices: function() { - this.sliceGroup.createSubSlices(); - this.samples_ = this.parent.model.samples.filter(function(sample) { - return sample.thread == this; - }, this); - }, - - /** - * @return {String} A user-friendly name for this thread. - */ - get userFriendlyName() { - return this.name || this.tid; - }, - - /** - * @return {String} User friendly details about this thread. - */ - get userFriendlyDetails() { - return 'tid: ' + this.tid + - (this.name ? ', name: ' + this.name : ''); - }, - - getSettingsKey: function() { - if (!this.name) - return undefined; - var parentKey = this.parent.getSettingsKey(); - if (!parentKey) - return undefined; - return parentKey + '.' + this.name; - }, - - getProcess: function() { - return this.parent; - }, - - /* - * Returns the index of the slice in the timeSlices array, or undefined. - */ - indexOfTimeSlice: function(timeSlice) { - var i = tr.b.findLowIndexInSortedArray( - this.timeSlices, - function(slice) { return slice.start; }, - timeSlice.start); - if (this.timeSlices[i] !== timeSlice) - return undefined; - return i; - }, - - /* - * Returns an object with the CPU number used as keys, - * and the value of each key object is the amount of milliseconds spent - * running on this CPU. - * Additionally, stats.total contains the total time - * spent running on all CPUs. - */ - getCpuStatsForRange: function(range) { - var stats = {}; - stats.total = 0; - - if (!this.timeSlices) - return stats; - - function addStatsForSlice(threadTimeSlice) { - var freqRange = tr.b.Range.fromExplicitRange(threadTimeSlice.start, - threadTimeSlice.end); - var intersection = freqRange.findIntersection(range); - - if (threadTimeSlice.schedulingState == - tr.model.SCHEDULING_STATE.RUNNING) { - var cpu = threadTimeSlice.cpuOnWhichThreadWasRunning; - if (!(cpu.cpuNumber in stats)) - stats[cpu.cpuNumber] = 0; - - stats[cpu.cpuNumber] += intersection.duration; - stats.total += intersection.duration; - } - } - - tr.b.iterateOverIntersectingIntervals(this.timeSlices, - function(x) { return x.start; }, - function(x) { return x.end; }, - range.min, - range.max, - addStatsForSlice); - return stats; - }, - - getSchedulingStatsForRange: function(start, end) { - var stats = {}; - - if (!this.timeSlices) return stats; - - function addStatsForSlice(threadTimeSlice) { - var overlapStart = Math.max(threadTimeSlice.start, start); - var overlapEnd = Math.min(threadTimeSlice.end, end); - var schedulingState = threadTimeSlice.schedulingState; - - if (!(schedulingState in stats)) - stats[schedulingState] = 0; - stats[schedulingState] += overlapEnd - overlapStart; - } - - tr.b.iterateOverIntersectingIntervals(this.timeSlices, - function(x) { return x.start; }, - function(x) { return x.end; }, - start, - end, - addStatsForSlice); - return stats; - }, - - get samples() { - return this.samples_; - } - }; - - /** - * Comparison between threads that orders first by parent.compareTo, - * then by names, then by tid. - */ - Thread.compare = function(x, y) { - var tmp = x.parent.compareTo(y.parent); - if (tmp) - return tmp; - - tmp = x.sortIndex - y.sortIndex; - if (tmp) - return tmp; - - tmp = tr.b.comparePossiblyUndefinedValues( - x.name, y.name, - function(x, y) { return x.localeCompare(y); }); - if (tmp) - return tmp; - - return x.tid - y.tid; - }; - - return { - Thread: Thread - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/thread_slice.html b/chromium/third_party/catapult/tracing/tracing/model/thread_slice.html deleted file mode 100644 index d1c8edcb313..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/thread_slice.html +++ /dev/null @@ -1,71 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/slice.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the Thread class. - */ -tr.exportTo('tr.model', function() { - var Slice = tr.model.Slice; - - /** - * A ThreadSlice represents an interval of time on a thread resource - * with associated nesting slice information. - * - * ThreadSlices are typically associated with a specific trace event pair on a - * specific thread. - * For example, - * TRACE_EVENT_BEGIN1("x","myArg", 7) at time=0.1ms - * TRACE_EVENT_END0() at time=0.3ms - * This results in a single slice from 0.1 with duration 0.2 on a - * specific thread. - * - * @constructor - */ - function ThreadSlice(cat, title, colorId, start, args, opt_duration, - opt_cpuStart, opt_cpuDuration, opt_argsStripped, - opt_bind_id) { - Slice.call(this, cat, title, colorId, start, args, opt_duration, - opt_cpuStart, opt_cpuDuration, opt_argsStripped, opt_bind_id); - // Do not modify this directly. - // subSlices is configured by SliceGroup.rebuildSubRows_. - this.subSlices = []; - } - - ThreadSlice.prototype = { - __proto__: Slice.prototype, - - get overlappingSamples() { - var samples = new tr.model.EventSet(); - if (!this.parentContainer || !this.parentContainer.samples) - return samples; - this.parentContainer.samples.forEach(function(sample) { - if (this.start <= sample.start && sample.start <= this.end) - samples.push(sample); - }, this); - return samples; - } - }; - - tr.model.EventRegistry.register( - ThreadSlice, - { - name: 'slice', - pluralName: 'slices', - singleViewElementName: 'tr-ui-a-single-thread-slice-sub-view', - multiViewElementName: 'tr-ui-a-multi-thread-slice-sub-view' - }); - - return { - ThreadSlice: ThreadSlice - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/thread_slice_test.html b/chromium/third_party/catapult/tracing/tracing/model/thread_slice_test.html deleted file mode 100644 index d621859a4ee..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/thread_slice_test.html +++ /dev/null @@ -1,40 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/thread_slice.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var ThreadSlice = tr.model.ThreadSlice; - var newSliceEx = tr.c.TestUtils.newSliceEx; - var newFakeThread = tr.c.TestUtils.newFakeThread; - - test('getOverlappingSamples', function() { - var model = tr.c.TestUtils.newModel(function(m) { - m.p1 = m.getOrCreateProcess(1); - m.t2 = m.p1.getOrCreateThread(2); - m.samples.push( - new tr.model.Sample(null, m.t1, 'a_1', 1), - new tr.model.Sample(null, m.t1, 'a_2', 2), - new tr.model.Sample(null, m.t1, 'a_3', 3), - new tr.model.Sample(null, m.t1, 'b', 5) - ); - }); - var threadSlice = newSliceEx({title: 'a', start: 0, end: 4, - type: tr.model.ThreadSlice}); - threadSlice.parentContainer = model; - var samplesIter = threadSlice.overlappingSamples[Symbol.iterator](); - assert.equal(samplesIter.next().value.title, 'a_1'); - assert.equal(samplesIter.next().value.title, 'a_2'); - assert.equal(samplesIter.next().value.title, 'a_3'); - assert.equal(samplesIter.next().done, true); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/thread_test.html b/chromium/third_party/catapult/tracing/tracing/model/thread_test.html deleted file mode 100644 index fc88dda7501..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/thread_test.html +++ /dev/null @@ -1,183 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/model.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var ThreadSlice = tr.model.ThreadSlice; - var Process = tr.model.Process; - var Thread = tr.model.Thread; - var newSliceEx = tr.c.TestUtils.newSliceEx; - var newAsyncSlice = tr.c.TestUtils.newAsyncSlice; - var newThreadSlice = tr.c.TestUtils.newThreadSlice; - var SCHEDULING_STATE = tr.model.SCHEDULING_STATE; - - test('threadBounds_Empty', function() { - var model = new tr.Model(); - var t = new Thread(new Process(model, 7), 1); - t.updateBounds(); - assert.isUndefined(t.bounds.min); - assert.isUndefined(t.bounds.max); - }); - - test('threadBounds_SubRow', function() { - var model = new tr.Model(); - var t = new Thread(new Process(model, 7), 1); - t.sliceGroup.pushSlice(new ThreadSlice('', 'a', 0, 1, {}, 3)); - t.updateBounds(); - assert.equal(t.bounds.min, 1); - assert.equal(t.bounds.max, 4); - }); - - test('threadBounds_AsyncSliceGroup', function() { - var model = new tr.Model(); - var t = new Thread(new Process(model, 7), 1); - t.sliceGroup.pushSlice(new ThreadSlice('', 'a', 0, 1, {}, 3)); - t.asyncSliceGroup.push(newAsyncSlice(0.1, 5, t, t)); - t.updateBounds(); - assert.equal(t.bounds.min, 0.1); - assert.equal(t.bounds.max, 5.1); - }); - - test('threadBounds_Cpu', function() { - var model = new tr.Model(); - var t = new Thread(new Process(model, 7), 1); - t.timeSlices = [newSliceEx({title: 'x', start: 0, duration: 1})]; - t.updateBounds(); - assert.equal(t.bounds.min, 0); - assert.equal(t.bounds.max, 1); - }); - - test('shiftTimestampsForwardWithCpu', function() { - var model = new tr.Model(); - var t = new Thread(new Process(model, 7), 1); - t.sliceGroup.pushSlice(new ThreadSlice('', 'a', 0, 0, {}, 3)); - t.asyncSliceGroup.push(newAsyncSlice(0, 5, t, t)); - t.timeSlices = [newSliceEx({title: 'x', start: 0, duration: 1})]; - - var shiftCount = 0; - t.asyncSliceGroup.shiftTimestampsForward = function(ts) { - if (ts == 0.32) - shiftCount++; - }; - - t.shiftTimestampsForward(0.32); - - assert.equal(shiftCount, 1); - assert.equal(t.sliceGroup.slices[0].start, 0.32); - assert.equal(t.timeSlices[0].start, 0.32); - }); - - test('shiftTimestampsForwardWithoutCpu', function() { - var model = new tr.Model(); - var t = new Thread(new Process(model, 7), 1); - t.sliceGroup.pushSlice(new ThreadSlice('', 'a', 0, 0, {}, 3)); - t.asyncSliceGroup.push(newAsyncSlice(0, 5, t, t)); - - var shiftCount = 0; - t.asyncSliceGroup.shiftTimestampsForward = function(ts) { - if (ts == 0.32) - shiftCount++; - }; - - t.shiftTimestampsForward(0.32); - - assert.equal(shiftCount, 1); - assert.equal(t.sliceGroup.slices[0].start, 0.32); - }); - - test('getSchedulingStatsForRange', function() { - var scheduledThread = undefined; - var unscheduledThread = undefined; - var model = tr.c.TestUtils.newModel(function(model) { - unscheduledThread = model.getOrCreateProcess(1).getOrCreateThread(1); - unscheduledThread.sliceGroup.pushSlice(newSliceEx( - {title: 'work', start: 0, duration: 20})); - - scheduledThread = model.getOrCreateProcess(2).getOrCreateThread(2); - scheduledThread.sliceGroup.pushSlice(newSliceEx( - {title: 'work', start: 0, duration: 20})); - scheduledThread.timeSlices = [ - newThreadSlice(scheduledThread, SCHEDULING_STATE.RUNNING, 0, 3), - newThreadSlice(scheduledThread, SCHEDULING_STATE.RUNNABLE, 3, 5), - newThreadSlice(scheduledThread, SCHEDULING_STATE.RUNNING, 8, 2), - newThreadSlice(scheduledThread, SCHEDULING_STATE.SLEEPING, 10, 10) - ]; - }); - - // thread without scheduling states - var stats = unscheduledThread.getSchedulingStatsForRange(0, 20); - assert.deepEqual(stats, {}); - - // no scheduling info - var stats = scheduledThread.getSchedulingStatsForRange(50, 100); - assert.deepEqual(stats, {}); - - // simple query - var stats = scheduledThread.getSchedulingStatsForRange(0, 3); - var expected = {}; - expected[SCHEDULING_STATE.RUNNING] = 3; - assert.deepEqual(stats, expected); - - // aggregation - var stats = scheduledThread.getSchedulingStatsForRange(0, 20); - var expected = {}; - expected[SCHEDULING_STATE.RUNNING] = 5; - expected[SCHEDULING_STATE.RUNNABLE] = 5; - expected[SCHEDULING_STATE.SLEEPING] = 10; - assert.deepEqual(stats, expected); - }); - - test('getCpuStatsForRange', function() { - var model = tr.c.TestUtils.newModel(function(model) { - var cpu0 = model.kernel.getOrCreateCpu(0); - var cpu1 = model.kernel.getOrCreateCpu(1); - var thread = model.getOrCreateProcess(1).getOrCreateThread(1); - thread.timeSlices = [ - newThreadSlice(thread, SCHEDULING_STATE.RUNNING, 0, 3, cpu0), - newThreadSlice(thread, SCHEDULING_STATE.RUNNING, 8, 2, cpu1), - newThreadSlice(thread, SCHEDULING_STATE.RUNNING, 20, 5, cpu1) - ]; - var range = tr.b.Range.fromExplicitRange(1, 22); - var stats = thread.getCpuStatsForRange(range); - assert.deepEqual(stats, { - 0: 2, - 1: 4, - total: 6 - }); - }); - }); - - test('getCpuStatsForRange_excludesNotRunningThreads', function() { - var model = tr.c.TestUtils.newModel(function(model) { - var cpu0 = model.kernel.getOrCreateCpu(0); - var cpu1 = model.kernel.getOrCreateCpu(1); - var thread = model.getOrCreateProcess(1).getOrCreateThread(1); - thread.timeSlices = [ - newThreadSlice(thread, SCHEDULING_STATE.RUNNING, 0, 8, cpu0), - newThreadSlice(thread, SCHEDULING_STATE.RUNNABLE, 8, 3), - newThreadSlice(thread, SCHEDULING_STATE.RUNNING, 11, 4, cpu1), - newThreadSlice(thread, SCHEDULING_STATE.SLEEPING, 15, 10), - newThreadSlice(thread, SCHEDULING_STATE.RUNNING, 25, 10, cpu1) - ]; - var range = tr.b.Range.fromExplicitRange(1, 26); - var stats = thread.getCpuStatsForRange(range); - assert.deepEqual(stats, { - 0: 7, - 1: 5, - total: 12 - }); - }); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/thread_time_slice.html b/chromium/third_party/catapult/tracing/tracing/model/thread_time_slice.html deleted file mode 100644 index e63a136d05d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/thread_time_slice.html +++ /dev/null @@ -1,161 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/model/slice.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - var Slice = tr.model.Slice; - - - var SCHEDULING_STATE = { - DEBUG: 'Debug', - EXIT_DEAD: 'Exit Dead', - RUNNABLE: 'Runnable', - RUNNING: 'Running', - SLEEPING: 'Sleeping', - STOPPED: 'Stopped', - TASK_DEAD: 'Task Dead', - UNINTR_SLEEP: 'Uninterruptible Sleep', - UNINTR_SLEEP_WAKE_KILL: 'Uninterruptible Sleep | WakeKill', - UNINTR_SLEEP_WAKING: 'Uninterruptible Sleep | Waking', - UNINTR_SLEEP_IO: 'Uninterruptible Sleep - Block I/O', - UNINTR_SLEEP_WAKE_KILL_IO: 'Uninterruptible Sleep | WakeKill - Block I/O', - UNINTR_SLEEP_WAKING_IO: 'Uninterruptible Sleep | Waking - Block I/O', - UNKNOWN: 'UNKNOWN', - WAKE_KILL: 'Wakekill', - WAKING: 'Waking', - ZOMBIE: 'Zombie' - }; - - /** - * A ThreadTimeSlice is a slice of time on a specific thread where that thread - * was running on a specific CPU, or in a specific sleep state. - * - * As a thread switches moves through its life, it sometimes goes to sleep and - * can't run. Other times, its runnable but isn't actually assigned to a CPU. - * Finally, sometimes it gets put on a CPU to actually execute. Each of these - * states is represented by a ThreadTimeSlice: - * - * Sleeping or runnable: cpuOnWhichThreadWasRunning is undefined - * Running: cpuOnWhichThreadWasRunning is set. - * - * @constructor - */ - function ThreadTimeSlice(thread, schedulingState, cat, - start, args, opt_duration) { - Slice.call(this, cat, schedulingState, - this.getColorForState_(schedulingState), - start, args, opt_duration); - this.thread = thread; - this.schedulingState = schedulingState; - this.cpuOnWhichThreadWasRunning = undefined; - } - - ThreadTimeSlice.prototype = { - __proto__: Slice.prototype, - - getColorForState_: function(state) { - var getColorIdForReservedName = - tr.b.ColorScheme.getColorIdForReservedName; - - switch (state) { - case SCHEDULING_STATE.RUNNABLE: - return getColorIdForReservedName('thread_state_runnable'); - case SCHEDULING_STATE.RUNNING: - return getColorIdForReservedName('thread_state_running'); - case SCHEDULING_STATE.SLEEPING: - return getColorIdForReservedName('thread_state_sleeping'); - case SCHEDULING_STATE.DEBUG: - case SCHEDULING_STATE.EXIT_DEAD: - case SCHEDULING_STATE.STOPPED: - case SCHEDULING_STATE.TASK_DEAD: - case SCHEDULING_STATE.UNINTR_SLEEP: - case SCHEDULING_STATE.UNINTR_SLEEP_WAKE_KILL: - case SCHEDULING_STATE.UNINTR_SLEEP_WAKING: - case SCHEDULING_STATE.UNKNOWN: - case SCHEDULING_STATE.WAKE_KILL: - case SCHEDULING_STATE.WAKING: - case SCHEDULING_STATE.ZOMBIE: - return getColorIdForReservedName('thread_state_uninterruptible'); - case SCHEDULING_STATE.UNINTR_SLEEP_IO: - case SCHEDULING_STATE.UNINTR_SLEEP_WAKE_KILL_IO: - case SCHEDULING_STATE.UNINTR_SLEEP_WAKING_IO: - return getColorIdForReservedName('thread_state_iowait'); - default: - return getColorIdForReservedName('thread_state_unknown'); - } - }, - - get analysisTypeName() { - return 'tr.ui.analysis.ThreadTimeSlice'; - }, - - getAssociatedCpuSlice: function() { - if (!this.cpuOnWhichThreadWasRunning) - return undefined; - var cpuSlices = this.cpuOnWhichThreadWasRunning.slices; - for (var i = 0; i < cpuSlices.length; i++) { - var cpuSlice = cpuSlices[i]; - if (cpuSlice.start !== this.start) - continue; - if (cpuSlice.duration !== this.duration) - continue; - return cpuSlice; - } - return undefined; - }, - - getCpuSliceThatTookCpu: function() { - if (this.cpuOnWhichThreadWasRunning) - return undefined; - var curIndex = this.thread.indexOfTimeSlice(this); - var cpuSliceWhenLastRunning; - while (curIndex >= 0) { - var curSlice = this.thread.timeSlices[curIndex]; - if (!curSlice.cpuOnWhichThreadWasRunning) { - curIndex--; - continue; - } - cpuSliceWhenLastRunning = curSlice.getAssociatedCpuSlice(); - break; - } - if (!cpuSliceWhenLastRunning) - return undefined; - - var cpu = cpuSliceWhenLastRunning.cpu; - var indexOfSliceOnCpuWhenLastRunning = - cpu.indexOf(cpuSliceWhenLastRunning); - var nextRunningSlice = cpu.slices[indexOfSliceOnCpuWhenLastRunning + 1]; - if (!nextRunningSlice) - return undefined; - if (Math.abs(nextRunningSlice.start - cpuSliceWhenLastRunning.end) < - 0.00001) - return nextRunningSlice; - return undefined; - } - }; - - tr.model.EventRegistry.register( - ThreadTimeSlice, - { - name: 'threadTimeSlice', - pluralName: 'threadTimeSlices', - singleViewElementName: 'tr-ui-a-single-thread-time-slice-sub-view', - multiViewElementName: 'tr-ui-a-multi-thread-time-slice-sub-view' - }); - - - return { - ThreadTimeSlice: ThreadTimeSlice, - SCHEDULING_STATE: SCHEDULING_STATE - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/time_to_object_instance_map.html b/chromium/third_party/catapult/tracing/tracing/model/time_to_object_instance_map.html deleted file mode 100644 index bd30fc102bc..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/time_to_object_instance_map.html +++ /dev/null @@ -1,193 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/base/sorted_array_utils.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides the TimeToObjectInstanceMap class. - */ -tr.exportTo('tr.model', function() { - /** - * Tracks all the instances associated with a given ID over its lifetime. - * - * A scoped id can be used multiple times throughout a trace, referring to - * different objects at different times. This data structure does the - * bookkeeping to figure out what ObjectInstance is referred to at a given - * timestamp. - * - * @constructor - */ - function TimeToObjectInstanceMap( - createObjectInstanceFunction, parent, scopedId) { - this.createObjectInstanceFunction_ = createObjectInstanceFunction; - this.parent = parent; - this.scopedId = scopedId; - this.instances = []; - } - - TimeToObjectInstanceMap.prototype = { - idWasCreated: function(category, name, ts) { - if (this.instances.length == 0) { - this.instances.push(this.createObjectInstanceFunction_( - this.parent, this.scopedId, category, name, ts)); - this.instances[0].creationTsWasExplicit = true; - return this.instances[0]; - } - - var lastInstance = this.instances[this.instances.length - 1]; - if (ts < lastInstance.deletionTs) { - throw new Error('Mutation of the TimeToObjectInstanceMap must be ' + - 'done in ascending timestamp order.'); - } - lastInstance = this.createObjectInstanceFunction_( - this.parent, this.scopedId, category, name, ts); - lastInstance.creationTsWasExplicit = true; - this.instances.push(lastInstance); - return lastInstance; - }, - - addSnapshot: function(category, name, ts, args, opt_baseTypeName) { - if (this.instances.length == 0) { - this.instances.push(this.createObjectInstanceFunction_( - this.parent, this.scopedId, category, name, ts, opt_baseTypeName)); - } - - var i = tr.b.findIndexInSortedIntervals( - this.instances, - function(inst) { return inst.creationTs; }, - function(inst) { return inst.deletionTs - inst.creationTs; }, - ts); - - var instance; - if (i < 0) { - instance = this.instances[0]; - if (ts > instance.deletionTs || - instance.creationTsWasExplicit) { - throw new Error( - 'At the provided timestamp, no instance was still alive'); - } - - if (instance.snapshots.length != 0) { - throw new Error( - 'Cannot shift creationTs forward, ' + - 'snapshots have been added. First snap was at ts=' + - instance.snapshots[0].ts + ' and creationTs was ' + - instance.creationTs); - } - instance.creationTs = ts; - } else if (i >= this.instances.length) { - instance = this.instances[this.instances.length - 1]; - if (ts >= instance.deletionTs) { - // The snap is added after our oldest and deleted instance. This means - // that this is a new implicit instance. - instance = this.createObjectInstanceFunction_( - this.parent, this.scopedId, category, name, ts, opt_baseTypeName); - this.instances.push(instance); - } else { - // If the ts is before the last objects deletion time, then the caller - // is trying to add a snapshot when there may have been an instance - // alive. In that case, try to move an instance's creationTs to - // include this ts, provided that it has an implicit creationTs. - - // Search backward from the right for an instance that was definitely - // deleted before this ts. Any time an instance is found that has a - // moveable creationTs - var lastValidIndex; - for (var i = this.instances.length - 1; i >= 0; i--) { - var tmp = this.instances[i]; - if (ts >= tmp.deletionTs) - break; - if (tmp.creationTsWasExplicit == false && tmp.snapshots.length == 0) - lastValidIndex = i; - } - if (lastValidIndex === undefined) { - throw new Error( - 'Cannot add snapshot. No instance was alive that was mutable.'); - } - instance = this.instances[lastValidIndex]; - instance.creationTs = ts; - } - } else { - instance = this.instances[i]; - } - - return instance.addSnapshot(ts, args, name, opt_baseTypeName); - }, - - get lastInstance() { - if (this.instances.length == 0) - return undefined; - return this.instances[this.instances.length - 1]; - }, - - idWasDeleted: function(category, name, ts) { - if (this.instances.length == 0) { - this.instances.push(this.createObjectInstanceFunction_( - this.parent, this.scopedId, category, name, ts)); - } - var lastInstance = this.instances[this.instances.length - 1]; - if (ts < lastInstance.creationTs) - throw new Error('Cannot delete an id before it was created'); - if (lastInstance.deletionTs == Number.MAX_VALUE) { - lastInstance.wasDeleted(ts); - return lastInstance; - } - - if (ts < lastInstance.deletionTs) - throw new Error('id was already deleted earlier.'); - - // A new instance was deleted with no snapshots in-between. - // Create an instance then kill it. - lastInstance = this.createObjectInstanceFunction_( - this.parent, this.scopedId, category, name, ts); - this.instances.push(lastInstance); - lastInstance.wasDeleted(ts); - return lastInstance; - }, - - getInstanceAt: function(ts) { - var i = tr.b.findIndexInSortedIntervals( - this.instances, - function(inst) { return inst.creationTs; }, - function(inst) { return inst.deletionTs - inst.creationTs; }, - ts); - if (i < 0) { - if (this.instances[0].creationTsWasExplicit) - return undefined; - return this.instances[0]; - } else if (i >= this.instances.length) { - return undefined; - } - return this.instances[i]; - }, - - logToConsole: function() { - for (var i = 0; i < this.instances.length; i++) { - var instance = this.instances[i]; - var cEF = ''; - var dEF = ''; - if (instance.creationTsWasExplicit) - cEF = '(explicitC)'; - if (instance.deletionTsWasExplicit) - dEF = '(explicit)'; - console.log(instance.creationTs, cEF, - instance.deletionTs, dEF, - instance.category, - instance.name, - instance.snapshots.length + ' snapshots'); - } - } - }; - - return { - TimeToObjectInstanceMap: TimeToObjectInstanceMap - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/time_to_object_instance_map_test.html b/chromium/third_party/catapult/tracing/tracing/model/time_to_object_instance_map_test.html deleted file mode 100644 index bcda0a2ea3b..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/time_to_object_instance_map_test.html +++ /dev/null @@ -1,163 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/time_to_object_instance_map.html"> -<link rel="import" href="/tracing/model/object_instance.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var createObjectInstance = function(parent, id, category, name, creationTs) { - return new tr.model.ObjectInstance( - parent, id, category, name, creationTs); - }; - - test('timeToObjectInstanceMap', function() { - var m = new tr.model.TimeToObjectInstanceMap( - createObjectInstance, {}, 7); - m.addSnapshot('cat', 'name', 10, 'a1'); - m.addSnapshot('cat', 'name', 20, 'a2'); - m.idWasDeleted('cat', 'name', 30); - m.addSnapshot('cat', 'name', 40, 'b'); - - assert.equal(m.instances.length, 2); - - var i0 = m.getInstanceAt(0); - var i10 = m.getInstanceAt(10); - assert.equal(i0, i10); - - assert.isDefined(i10); - assert.equal(i10.snapshots.length, 2); - assert.equal(i10.snapshots[0].args, 'a1'); - assert.equal(i10.snapshots[1].args, 'a2'); - - assert.equal(i10.deletionTs, 30); - - var i15 = m.getInstanceAt(15); - assert.equal(i15, i10); - - var i20 = m.getInstanceAt(20); - assert.equal(i20, i10); - - var i30 = m.getInstanceAt(30); - assert.isUndefined(i30); - - var i35 = m.getInstanceAt(35); - assert.isUndefined(i35); - - var i40 = m.getInstanceAt(40); - assert.isDefined(i40); - assert.notEqual(i40, i10); - assert.equal(i40.snapshots.length, 1); - assert.equal(i40.creationTs, 40); - assert.equal(i40.deletionTs, Number.MAX_VALUE); - - var i41 = m.getInstanceAt(41); - assert.equal(i40, i41); - }); - - test('timeToObjectInstanceMapsBoundsLogic', function() { - var m = new tr.model.TimeToObjectInstanceMap( - createObjectInstance, {}, 7); - m.addSnapshot('cat', 'name', 10, 'a1'); - m.addSnapshot('cat', 'name', 20, 'a2'); - m.idWasDeleted('cat', 'name', 30); - m.addSnapshot('cat', 'name', 40, 'b'); - m.addSnapshot('cat', 'name', 41, 'b'); - - m.instances.forEach(function(i) { i.updateBounds(); }); - - var iA = m.getInstanceAt(10); - assert.equal(iA.bounds.min, 10); - assert.equal(iA.bounds.max, 30); - - var iB = m.getInstanceAt(40); - assert.equal(iB.bounds.min, 40); - assert.equal(iB.bounds.max, 41); - }); - - test('earlySnapshot', function() { - var m = new tr.model.TimeToObjectInstanceMap( - createObjectInstance, {}, 7); - var i10 = m.idWasCreated('cat', 'name', 10, 'a1'); - m.idWasDeleted('cat', 'name', 20); - - assert.throws(function() { - m.addSnapshot('cat', 'name', 5, 'a1'); - }); - assert.equal(i10.creationTs, 10); - assert.equal(i10.deletionTs, 20); - }); - - test('earlySnapshotWithImplicitCreate', function() { - var m = new tr.model.TimeToObjectInstanceMap( - createObjectInstance, {}, 7); - var i10 = m.idWasDeleted('cat', 'name', 20); - m.addSnapshot('cat', 'name', 5, 'a1'); - assert.equal(i10.creationTs, 5); - assert.equal(i10.deletionTs, 20); - }); - - test('getInstanceBeforeCreationImplicitCreate', function() { - var m = new tr.model.TimeToObjectInstanceMap( - createObjectInstance, {}, 7); - var i10 = m.idWasCreated('cat', 'name', 10, 'a1'); - m.idWasDeleted('cat', 'name', 20); - assert.isUndefined(m.getInstanceAt(5)); - }); - - test('getInstanceBeforeCreationImplicitCreateWithSnapshot', function() { - var m = new tr.model.TimeToObjectInstanceMap( - createObjectInstance, {}, 7); - var s5 = m.addSnapshot('cat', 'name', 5, 'a1'); - var i10 = m.idWasDeleted('cat', 'name', 20); - assert.equal(m.getInstanceAt(5), i10); - }); - - test('successiveDeletions', function() { - var m = new tr.model.TimeToObjectInstanceMap( - createObjectInstance, {}, 7); - var i20 = m.idWasDeleted('cat', 'name', 20); - var i30 = m.idWasDeleted('cat', 'name', 30); - var i40 = m.idWasDeleted('cat', 'name', 40); - assert.equal(i20.creationTs, 20); - assert.isFalse(i20.creationTsWasExplicit); - assert.equal(i20.deletionTs, 20); - assert.isTrue(i20.deletionTsWasExplicit); - - assert.equal(i30.creationTs, 30); - assert.isFalse(i30.creationTsWasExplicit); - assert.equal(i30.deletionTs, 30); - assert.isTrue(i30.deletionTsWasExplicit); - - - assert.equal(i40.creationTs, 40); - assert.isFalse(i40.creationTsWasExplicit); - assert.equal(i40.deletionTs, 40); - assert.isTrue(i40.deletionTsWasExplicit); - }); - - test('snapshotAfterDeletion', function() { - var m = new tr.model.TimeToObjectInstanceMap( - createObjectInstance, {}, 7); - var i10 = m.idWasCreated('cat', 'name', 10, 'a1'); - m.idWasDeleted('cat', 'name', 20); - - var s25 = m.addSnapshot('cat', 'name', 25, 'a1'); - var i25 = s25.objectInstance; - - assert.equal(i10.creationTs, 10); - assert.equal(i10.deletionTs, 20); - assert.notEqual(i25, i10); - assert.equal(i25.creationTs, 25); - assert.equal(i25.deletionTs, Number.MAX_VALUE); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/timed_event.html b/chromium/third_party/catapult/tracing/tracing/model/timed_event.html deleted file mode 100644 index 381a8a2f455..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/timed_event.html +++ /dev/null @@ -1,61 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2013 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/guid.html"> -<link rel="import" href="/tracing/model/event.html"> -<link rel="import" href="/tracing/value/time_display_mode.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - /** - * TimedEvent is a base type for any entity in the trace model with a specific - * start and duration. - * - * @constructor - */ - function TimedEvent(start) { - tr.model.Event.call(this); - this.start = start; - this.duration = 0; - this.cpuStart = undefined; - this.cpuDuration = undefined; - // The set of contexts this event belongs to (order is unimportant). This - // array should never be modified. - this.contexts = Object.freeze([]); - } - - TimedEvent.prototype = { - __proto__: tr.model.Event.prototype, - - get end() { - return this.start + this.duration; - }, - - addBoundsToRange: function(range) { - range.addValue(this.start); - range.addValue(this.end); - }, - - // Returns true if 'that' TimedEvent is fully contained within 'this' timed - // event. - bounds: function(that, opt_precisionUnit) { - if (opt_precisionUnit === undefined) - opt_precisionUnit = tr.v.TimeDisplayModes.ms; - - var startsBefore = opt_precisionUnit.roundedLess(that.start, this.start); - var endsAfter = opt_precisionUnit.roundedLess(this.end, that.end); - return !startsBefore && !endsAfter; - } - }; - - return { - TimedEvent: TimedEvent - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/timed_event_test.html b/chromium/third_party/catapult/tracing/tracing/model/timed_event_test.html deleted file mode 100644 index 4beba912298..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/timed_event_test.html +++ /dev/null @@ -1,45 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/timed_event.html"> -<link rel="import" href="/tracing/value/time_display_mode.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('bounds_startPrecision', function() { - var unit = tr.v.TimeDisplayModes; - - var outer = new tr.model.TimedEvent(10.0001); - outer.duration = 0.9999; - var inner = new tr.model.TimedEvent(10.0000); - inner.duration = 1.0000; - - assert.isTrue(outer.bounds(inner)); - assert.isTrue(outer.bounds(inner, unit.ms)); - - assert.isFalse(outer.bounds(inner, unit.ns)); - }); - - test('bounds_endPrecision', function() { - var unit = tr.v.TimeDisplayModes; - - var outer = new tr.model.TimedEvent(10.0000); - outer.duration = 0.9999; - var inner = new tr.model.TimedEvent(10.0000); - inner.duration = 1.0000; - - assert.isTrue(outer.bounds(inner)); - assert.isTrue(outer.bounds(inner, unit.ms)); - - assert.isFalse(outer.bounds(inner, unit.ns)); - }); -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/user_model/animation_expectation.html b/chromium/third_party/catapult/tracing/tracing/model/user_model/animation_expectation.html deleted file mode 100644 index 9d73f060d92..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/user_model/animation_expectation.html +++ /dev/null @@ -1,49 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/user_model/user_expectation.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model.um', function() { - function AnimationExpectation( - parentModel, initiatorTitle, start, duration) { - tr.model.um.UserExpectation.call( - this, parentModel, initiatorTitle, start, duration); - this.frameEvents_ = undefined; - } - - AnimationExpectation.prototype = { - __proto__: tr.model.um.UserExpectation.prototype, - constructor: AnimationExpectation, - - get frameEvents() { - if (this.frameEvents_) - return this.frameEvents_; - - this.frameEvents_ = new tr.model.EventSet(); - - this.associatedEvents.forEach(function(event) { - if (event.title === tr.model.helpers.IMPL_RENDERING_STATS) - this.frameEvents_.push(event); - }, this); - - return this.frameEvents_; - } - }; - - tr.model.um.UserExpectation.register(AnimationExpectation, { - stageTitle: 'Animation', - colorId: tr.b.ColorScheme.getColorIdForReservedName('rail_animation') - }); - - return { - AnimationExpectation: AnimationExpectation - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/user_model/idle_expectation.html b/chromium/third_party/catapult/tracing/tracing/model/user_model/idle_expectation.html deleted file mode 100644 index 80c22c0483b..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/user_model/idle_expectation.html +++ /dev/null @@ -1,34 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/user_model/user_expectation.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model.um', function() { - function IdleExpectation(parentModel, start, duration) { - var initiatorTitle = ''; - tr.model.um.UserExpectation.call( - this, parentModel, initiatorTitle, start, duration); - } - - IdleExpectation.prototype = { - __proto__: tr.model.um.UserExpectation.prototype, - constructor: IdleExpectation - }; - - tr.model.um.UserExpectation.register(IdleExpectation, { - stageTitle: 'Idle', - colorId: tr.b.ColorScheme.getColorIdForReservedName('rail_idle') - }); - - return { - IdleExpectation: IdleExpectation - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/user_model/load_expectation.html b/chromium/third_party/catapult/tracing/tracing/model/user_model/load_expectation.html deleted file mode 100644 index a4ec0113fab..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/user_model/load_expectation.html +++ /dev/null @@ -1,69 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/user_model/user_expectation.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model.um', function() { - var LOAD_SUBTYPE_NAMES = { - SUCCESSFUL: 'Successful', - FAILED: 'Failed', - }; - - var DOES_LOAD_SUBTYPE_NAME_EXIST = {}; - for (var key in LOAD_SUBTYPE_NAMES) { - DOES_LOAD_SUBTYPE_NAME_EXIST[LOAD_SUBTYPE_NAMES[key]] = true;; - } - - function LoadExpectation(parentModel, initiatorTitle, start, duration) { - if (!DOES_LOAD_SUBTYPE_NAME_EXIST[initiatorTitle]) - throw new Error(initiatorTitle + ' is not in LOAD_SUBTYPE_NAMES'); - - tr.model.um.UserExpectation.call( - this, parentModel, initiatorTitle, start, duration); - - // |renderProcess| is the renderer process that contains the loading - // RenderFrame. - this.renderProcess = undefined; - - // |renderMainThread| is the CrRendererMain thread in the |renderProcess| - // that contains the loading RenderFrame. - this.renderMainThread = undefined; - - // |routingId| identifies the loading RenderFrame within the renderer - // process. - this.routingId = undefined; - - // |parentRoutingId| identifies the RenderFrame that created and contains - // the loading RenderFrame. - this.parentRoutingId = undefined; - - // |loadFinishedEvent|, if present, signals that this is a main frame. - this.loadFinishedEvent = undefined; - - // Startup LoadIRs do not have renderProcess, routingId, or - // parentRoutingId. Maybe RenderLoadIR should be a separate class? - } - - LoadExpectation.prototype = { - __proto__: tr.model.um.UserExpectation.prototype, - constructor: LoadExpectation - }; - - tr.model.um.UserExpectation.register(LoadExpectation, { - stageTitle: 'Load', - colorId: tr.b.ColorScheme.getColorIdForReservedName('rail_load') - }); - - return { - LOAD_SUBTYPE_NAMES: LOAD_SUBTYPE_NAMES, - LoadExpectation: LoadExpectation - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/user_model/response_expectation.html b/chromium/third_party/catapult/tracing/tracing/model/user_model/response_expectation.html deleted file mode 100644 index 9608467cfa4..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/user_model/response_expectation.html +++ /dev/null @@ -1,35 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/user_model/user_expectation.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model.um', function() { - function ResponseExpectation( - parentModel, initiatorTitle, start, duration, opt_isAnimationBegin) { - tr.model.um.UserExpectation.call( - this, parentModel, initiatorTitle, start, duration); - this.isAnimationBegin = opt_isAnimationBegin || false; - } - - ResponseExpectation.prototype = { - __proto__: tr.model.um.UserExpectation.prototype, - constructor: ResponseExpectation - }; - - tr.model.um.UserExpectation.register(ResponseExpectation, { - stageTitle: 'Response', - colorId: tr.b.ColorScheme.getColorIdForReservedName('rail_response') - }); - - return { - ResponseExpectation: ResponseExpectation - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/user_model/startup_expectation.html b/chromium/third_party/catapult/tracing/tracing/model/user_model/startup_expectation.html deleted file mode 100644 index 630c79c2cb5..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/user_model/startup_expectation.html +++ /dev/null @@ -1,33 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/user_model/user_expectation.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model.um', function() { - function StartupExpectation(parentModel, start, duration) { - tr.model.um.UserExpectation.call( - this, parentModel, '', start, duration); - } - - StartupExpectation.prototype = { - __proto__: tr.model.um.UserExpectation.prototype, - constructor: StartupExpectation - }; - - tr.model.um.UserExpectation.register(StartupExpectation, { - stageTitle: 'Startup', - colorId: tr.b.ColorScheme.getColorIdForReservedName('startup') - }); - - return { - StartupExpectation: StartupExpectation - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/user_model/stub_expectation.html b/chromium/third_party/catapult/tracing/tracing/model/user_model/stub_expectation.html deleted file mode 100644 index d5445817e18..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/user_model/stub_expectation.html +++ /dev/null @@ -1,74 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/user_model/user_expectation.html"> - -<script> -'use strict'; - -/** - * @fileoverview Stub version of UserExpectation for testing. - */ -tr.exportTo('tr.model.um', function() { - function StubExpectation(args) { - this.stageTitle_ = args.stageTitle || 'Idle'; - this.initiatorTitle_ = args.initiatorTitle || ''; - - this.title_ = args.title; - if (!this.title_) { - var defaultTitle = []; - if (this.initiatorTitle_) - defaultTitle.push(this.initiatorTitle_); - if (this.stageTitle_) - defaultTitle.push(this.stageTitle_); - this.title_ = defaultTitle.join(' ') || 'title'; - } - - this.normalizedUserComfort_ = args.normalizedUserComfort || 0; - this.normalizedEfficiency_ = args.normalizedEfficiency || 0; - - var sd = tr.c.TestUtils.getStartAndDurationFromDict(args); - - tr.model.um.UserExpectation.call( - this, args.parentModel, this.initiatorTitle, sd.start, sd.duration); - - // Must be set after base class call. - this.colorId_ = args.colorId || 0; - - if (args.associatedEvents) { - args.associatedEvents.forEach(function(event) { - this.associatedEvents.push(event); - }, this); - } - } - - StubExpectation.prototype = { - __proto__: tr.model.um.UserExpectation.prototype, - - get colorId() { - return this.colorId_; - }, - - get title() { - return this.title_; - }, - - get stageTitle() { - return this.stageTitle_; - }, - - get initiatorTitle() { - return this.initiatorTitle_; - } - }; - - return { - StubExpectation: StubExpectation - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/user_model/user_expectation.html b/chromium/third_party/catapult/tracing/tracing/model/user_model/user_expectation.html deleted file mode 100644 index 43e8888740c..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/user_model/user_expectation.html +++ /dev/null @@ -1,151 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/range_utils.html"> -<link rel="import" href="/tracing/base/statistics.html"> -<link rel="import" href="/tracing/model/compound_event_selection_state.html"> -<link rel="import" href="/tracing/model/event_set.html"> -<link rel="import" href="/tracing/model/timed_event.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model.um', function() { - var CompoundEventSelectionState = tr.model.CompoundEventSelectionState; - - function UserExpectation(parentModel, initiatorTitle, start, duration) { - tr.model.TimedEvent.call(this, start); - this.associatedEvents = new tr.model.EventSet(); - this.duration = duration; - this.initiatorTitle_ = initiatorTitle; - this.parentModel = parentModel; - this.typeInfo_ = undefined; - - // sourceEvents are the ones that caused the UserModelBuilder to create this - // UserExpectation. - this.sourceEvents = new tr.model.EventSet(); - } - - UserExpectation.prototype = { - __proto__: tr.model.TimedEvent.prototype, - - computeCompoundEvenSelectionState: function(selection) { - var cess = CompoundEventSelectionState.NOT_SELECTED; - if (selection.contains(this)) - cess |= CompoundEventSelectionState.EVENT_SELECTED; - - if (this.associatedEvents.intersectionIsEmpty(selection)) - return cess; - - var allContained = this.associatedEvents.every(function(event) { - return selection.contains(event); - }); - - if (allContained) - cess |= CompoundEventSelectionState.ALL_ASSOCIATED_EVENTS_SELECTED; - else - cess |= CompoundEventSelectionState.SOME_ASSOCIATED_EVENTS_SELECTED; - return cess; - }, - - // Returns samples which are overlapping with V8.Execute - get associatedSamples() { - var samples = new tr.model.EventSet(); - this.associatedEvents.forEach(function(event) { - if (event instanceof tr.model.ThreadSlice) - samples.addEventSet(event.overlappingSamples); - }); - return samples; - }, - - get userFriendlyName() { - return this.title + ' User Expectation at ' + - tr.v.Unit.byName.timeStampInMs.format(this.start); - }, - - get stableId() { - return ('UserExpectation.' + this.guid); - }, - - get typeInfo() { - if (!this.typeInfo_) - this.typeInfo_ = UserExpectation.findTypeInfo(this.constructor); - - // If you set Subclass.prototype = {}, then you must explicitly specify - // constructor in that prototype object! - // http://javascript.info/tutorial/constructor - - if (!this.typeInfo_) - throw new Error('Unregistered UserExpectation'); - - return this.typeInfo_; - }, - - get colorId() { - return this.typeInfo.metadata.colorId; - }, - - get stageTitle() { - return this.typeInfo.metadata.stageTitle; - }, - - get initiatorTitle() { - return this.initiatorTitle_; - }, - - get title() { - if (!this.initiatorTitle) - return this.stageTitle; - - return this.initiatorTitle + ' ' + this.stageTitle; - }, - - /** - * Returns the sum of the number of CPU ms spent by this UserExpectation. - */ - get totalCpuMs() { - var cpuMs = 0; - this.associatedEvents.forEach(function(event) { - if (event.cpuSelfTime) - cpuMs += event.cpuSelfTime; - }); - return cpuMs; - } - }; - - var options = new tr.b.ExtensionRegistryOptions(tr.b.BASIC_REGISTRY_MODE); - tr.b.decorateExtensionRegistry(UserExpectation, options); - - UserExpectation.addEventListener('will-register', function(e) { - var metadata = e.typeInfo.metadata; - - if (metadata.stageTitle === undefined) { - throw new Error('Registered UserExpectations must provide ' + - 'stageTitle'); - } - - if (metadata.colorId === undefined) { - throw new Error('Registered UserExpectations must provide ' + - 'colorId'); - } - }); - - tr.model.EventRegistry.register( - UserExpectation, - { - name: 'user-expectation', - pluralName: 'user-expectations', - singleViewElementName: 'tr-ui-a-single-user-expectation-sub-view', - multiViewElementName: 'tr-ui-a-multi-user-expectation-sub-view' - }); - - return { - UserExpectation: UserExpectation - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/user_model/user_model.html b/chromium/third_party/catapult/tracing/tracing/model/user_model/user_model.html deleted file mode 100644 index fd30d6a610b..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/user_model/user_model.html +++ /dev/null @@ -1,67 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/event_container.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model.um', function() { - function UserModel(parentModel) { - tr.model.EventContainer.call(this); - this.parentModel_ = parentModel; - this.expectations_ = new tr.model.EventSet(); - } - - UserModel.prototype = { - __proto__: tr.model.EventContainer.prototype, - - get stableId() { - return 'UserModel'; - }, - - get parentModel() { - return this.parentModel_; - }, - - sortExpectations: function() { - Array.prototype.sort.call(this.expectations_, function(x, y) { - return x.start - y.start; - }); - }, - - get expectations() { - return this.expectations_; - }, - - shiftTimestampsForward: function(amount) { - }, - - addCategoriesToDict: function(categoriesDict) { - }, - - childEvents: function*() { - yield * this.expectations; - }, - - childEventContainers: function*() { - }, - - updateBounds: function() { - this.bounds.reset(); - this.expectations.forEach(function(expectation) { - expectation.addBoundsToRange(this.bounds); - }, this); - } - }; - - return { - UserModel: UserModel - }; -}); -</script> - diff --git a/chromium/third_party/catapult/tracing/tracing/model/vm_region.html b/chromium/third_party/catapult/tracing/tracing/model/vm_region.html deleted file mode 100644 index 45ce7f37206..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/vm_region.html +++ /dev/null @@ -1,389 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/base/base.html"> - -<script> -'use strict'; - -/** - * @fileoverview Provides classes for representing and classifying VM regions. - * - * See https://goo.gl/5SSPv0 for more details. - */ -tr.exportTo('tr.model', function() { - - /** - * A single virtual memory region (also called a memory map). - * - * @constructor - */ - function VMRegion(startAddress, sizeInBytes, protectionFlags, - mappedFile, byteStats) { - this.startAddress = startAddress; - this.sizeInBytes = sizeInBytes; - this.protectionFlags = protectionFlags; - this.mappedFile = mappedFile || ''; - this.byteStats = byteStats || {}; - }; - - VMRegion.PROTECTION_FLAG_READ = 4; - VMRegion.PROTECTION_FLAG_WRITE = 2; - VMRegion.PROTECTION_FLAG_EXECUTE = 1; - VMRegion.PROTECTION_FLAG_MAYSHARE = 128; - - VMRegion.prototype = { - get uniqueIdWithinProcess() { - // This value is assumed to be unique within a process. - return this.mappedFile + '#' + this.startAddress; - }, - - get protectionFlagsToString() { - if (this.protectionFlags === undefined) - return undefined; - return ( - (this.protectionFlags & VMRegion.PROTECTION_FLAG_READ ? 'r' : '-') + - (this.protectionFlags & VMRegion.PROTECTION_FLAG_WRITE ? 'w' : '-') + - (this.protectionFlags & VMRegion.PROTECTION_FLAG_EXECUTE ? - 'x' : '-') + - (this.protectionFlags & VMRegion.PROTECTION_FLAG_MAYSHARE ? 's' : 'p') - ); - } - }; - - VMRegion.fromDict = function(dict) { - return new VMRegion( - dict.startAddress, - dict.sizeInBytes, - dict.protectionFlags, - dict.mappedFile, - dict.byteStats); - }; - - /** - * Node in a VM region classification tree. - * - * Note: Most users of this class should use the - * VMRegionClassificationNode.fromRegions static method instead of this - * constructor because it leads to better performance due to fewer memory - * allocations. - * - * @constructor - */ - function VMRegionClassificationNode(opt_rule) { - this.rule_ = opt_rule || VMRegionClassificationNode.CLASSIFICATION_RULES; - - // True iff this node or any of its descendant classification nodes has at - // least one classified VM region. - this.hasRegions = false; - - // Total virtual size and byte stats of all regions matching this node's - // rule (including its sub-rules). - this.sizeInBytes = undefined; - this.byteStats = {}; - - // Array of child classification nodes if this is an intermediate node. - this.children_ = undefined; - - // Array of VM regions. If this is an intermediate node, then the regions - // are cached for lazy tree construction (i.e. its child classification - // nodes yet have to be built). - this.regions_ = []; - } - - /** - * Rules for classifying memory maps. - * - * These rules are derived from core/jni/android_os_Debug.cpp in Android. - */ - VMRegionClassificationNode.CLASSIFICATION_RULES = { - name: 'Total', - children: [ - { - name: 'Android', - file: /^\/dev\/ashmem(?!\/libc malloc)/, - children: [ - { - name: 'Java runtime', - file: /^\/dev\/ashmem\/dalvik-/, - children: [ - { - name: 'Spaces', - file: /\/dalvik-(alloc|main|large object|non moving|zygote) space/, // @suppress longLineCheck - children: [ - { - name: 'Normal', - file: /\/dalvik-(alloc|main)/ - }, - { - name: 'Large', - file: /\/dalvik-large object/ - }, - { - name: 'Zygote', - file: /\/dalvik-zygote/ - }, - { - name: 'Non-moving', - file: /\/dalvik-non moving/ - } - ] - }, - { - name: 'Linear Alloc', - file: /\/dalvik-LinearAlloc/ - }, - { - name: 'Indirect Reference Table', - file: /\/dalvik-indirect.ref/ - }, - { - name: 'Cache', - file: /\/dalvik-jit-code-cache/ - }, - { - name: 'Accounting' - } - ] - }, - { - name: 'Cursor', - file: /\/CursorWindow/ - }, - { - name: 'Ashmem' - } - ] - }, - { - name: 'Native heap', - file: /^((\[heap\])|(\[anon:)|(\/dev\/ashmem\/libc malloc)|(\[discounted tracing overhead\])|$)/ // @suppress longLineCheck - }, - { - name: 'Stack', - file: /^\[stack/ - }, - { - name: 'Files', - file: /\.((((jar)|(apk)|(ttf)|(odex)|(oat)|(art))$)|(dex)|(so))/, - children: [ - { - name: 'so', - file: /\.so/ - }, - { - name: 'jar', - file: /\.jar$/ - }, - { - name: 'apk', - file: /\.apk$/ - }, - { - name: 'ttf', - file: /\.ttf$/ - }, - { - name: 'dex', - file: /\.((dex)|(odex$))/ - }, - { - name: 'oat', - file: /\.oat$/ - }, - { - name: 'art', - file: /\.art$/ - } - ] - }, - { - name: 'Devices', - file: /(^\/dev\/)|(anon_inode:dmabuf)/, - children: [ - { - name: 'GPU', - file: /\/((nv)|(mali)|(kgsl))/ - }, - { - name: 'DMA', - file: /anon_inode:dmabuf/ - } - ] - } - ] - }; - VMRegionClassificationNode.OTHER_RULE = { name: 'Other' }; - - VMRegionClassificationNode.fromRegions = function(regions, opt_rules) { - var tree = new VMRegionClassificationNode(opt_rules); - tree.regions_ = regions; - for (var i = 0; i < regions.length; i++) - tree.addStatsFromRegion_(regions[i]); - return tree; - }; - - VMRegionClassificationNode.prototype = { - get title() { - return this.rule_.name; - }, - - get children() { - if (this.isLeafNode) - return undefined; // Leaf nodes don't have children (by definition). - if (this.children_ === undefined) - this.buildTree_(); // Lazily classify VM regions. - return this.children_; - }, - - get regions() { - if (!this.isLeafNode) { - // Intermediate nodes only temporarily cache VM regions for lazy tree - // construction. - return undefined; - } - return this.regions_; - }, - - get allRegionsForTesting() { - if (this.regions_ !== undefined) { - if (this.children_ !== undefined) { - throw new Error('Internal error: a VM region classification node ' + - 'cannot have both regions and children'); - } - // Leaf node (or caching internal node). - return this.regions_; - } - - // Intermediate node. - var regions = []; - this.children_.forEach(function(childNode) { - regions = regions.concat(childNode.allRegionsForTesting); - }); - return regions; - }, - - get isLeafNode() { - var children = this.rule_.children; - return children === undefined || children.length === 0; - }, - - addRegion: function(region) { - this.addRegionRecursively_(region, true /* addStatsToThisNode */); - }, - - someRegion: function(fn, opt_this) { - if (this.regions_ !== undefined) { - // Leaf node (or caching internal node). - return this.regions_.some(fn, opt_this); - } - - // Intermediate node. - return this.children_.some(function(childNode) { - return childNode.someRegion(fn, opt_this); - }); - }, - - addRegionRecursively_: function(region, addStatsToThisNode) { - if (addStatsToThisNode) - this.addStatsFromRegion_(region); - - if (this.regions_ !== undefined) { - if (this.children_ !== undefined) { - throw new Error('Internal error: a VM region classification node ' + - 'cannot have both regions and children'); - } - // Leaf node or an intermediate node caching VM regions (add the - // region to this node and don't classify further). - this.regions_.push(region); - return; - } - - // Non-leaf rule (classify region row further down the tree). - function regionRowMatchesChildNide(child) { - var fileRegExp = child.rule_.file; - if (fileRegExp === undefined) - return true; - return fileRegExp.test(region.mappedFile); - } - - var matchedChild = tr.b.findFirstInArray( - this.children_, regionRowMatchesChildNide); - if (matchedChild === undefined) { - // Region belongs to the 'Other' node (created lazily). - if (this.children_.length !== this.rule_.children.length) - throw new Error('Internal error'); - matchedChild = new VMRegionClassificationNode( - VMRegionClassificationNode.OTHER_RULE); - this.children_.push(matchedChild); - } - - matchedChild.addRegionRecursively_(region, true); - }, - - buildTree_: function() { - var cachedRegions = this.regions_; - this.regions_ = undefined; - - this.buildChildNodesRecursively_(); - for (var i = 0; i < cachedRegions.length; i++) { - // Note that we don't add the VM region's stats to this node because - // they have already been added to it. - this.addRegionRecursively_( - cachedRegions[i], false /* addStatsToThisNode */); - } - }, - - buildChildNodesRecursively_: function() { - if (this.children_ !== undefined) { - throw new Error( - 'Internal error: Classification node already has children'); - } - if (this.regions_ !== undefined && this.regions_.length !== 0) { - throw new Error( - 'Internal error: Classification node should have no regions'); - } - - if (this.isLeafNode) - return; // Leaf node: Nothing to do. - - // Intermediate node: Clear regions and build children recursively. - this.regions_ = undefined; - this.children_ = this.rule_.children.map(function(childRule) { - var child = new VMRegionClassificationNode(childRule); - child.buildChildNodesRecursively_(); - return child; - }); - }, - - addStatsFromRegion_: function(region) { - this.hasRegions = true; - - // Aggregate virtual size. - var regionSizeInBytes = region.sizeInBytes; - if (regionSizeInBytes !== undefined) - this.sizeInBytes = (this.sizeInBytes || 0) + regionSizeInBytes; - - // Aggregate byte stats. - var thisByteStats = this.byteStats; - var regionByteStats = region.byteStats; - for (var byteStatName in regionByteStats) { - var regionByteStatValue = regionByteStats[byteStatName]; - if (regionByteStatValue === undefined) - continue; - thisByteStats[byteStatName] = - (thisByteStats[byteStatName] || 0) + regionByteStatValue; - } - } - }; - - return { - VMRegion: VMRegion, - VMRegionClassificationNode: VMRegionClassificationNode - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/vm_region_test.html b/chromium/third_party/catapult/tracing/tracing/model/vm_region_test.html deleted file mode 100644 index a57c0e9d039..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/vm_region_test.html +++ /dev/null @@ -1,1071 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright 2016 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/core/test_utils.html"> -<link rel="import" href="/tracing/model/memory_dump_test_utils.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var VMRegion = tr.model.VMRegion; - var VMRegionClassificationNode = tr.model.VMRegionClassificationNode; - var checkVMRegions = tr.model.MemoryDumpTestUtils.checkVMRegions; - - function checkProtectionFlagsToString(protectionFlags, expectedString) { - var vmRegion = VMRegion.fromDict({ - startAddress: 256, - sizeInBytes: 336, - protectionFlags: protectionFlags, - mappedFile: '[stack:20310]', - byteStats: { - privateDirtyResident: 96, - swapped: 144, - proportionalResident: 158 - } - }); - assert.strictEqual(vmRegion.protectionFlagsToString, expectedString); - } - - var TEST_RULES = { - name: 'Root', - children: [ - { - name: 'Words', - file: /^[a-zA-Z]/, - children: [ - { - name: 'A-D', - file: /^[a-dA-D]/ - }, - { - name: 'E-H', - file: /^[e-hE-H]/ - } - ] - }, - { - name: 'Digits', - file: /\d$/, - children: [] - } - ] - }; - - // Constant representing the expectation that the children of a - // VMRegionClassificationNode have not been built yet. - var CHILDREN_NOT_BUILT_YET = {}; - - function checkTree(node, expectedStructure) { - assert.strictEqual(node.title, expectedStructure.title); - assert.strictEqual(node.hasRegions, expectedStructure.hasRegions); - assert.strictEqual(node.sizeInBytes, expectedStructure.sizeInBytes); - assert.deepEqual(node.byteStats, expectedStructure.byteStats || {}); - assert.strictEqual(node.isLeafNode, expectedStructure.isLeafNode); - - var actualRegions = node.regions; - var expectedRegions = expectedStructure.regions; - if (expectedRegions === undefined) { - assert.isUndefined(actualRegions); - } else { - assert.instanceOf(actualRegions, Array); - checkVMRegions(actualRegions, expectedRegions); - } - - var expectedChildren = expectedStructure.children; - if (expectedChildren === CHILDREN_NOT_BUILT_YET) { - assert.isUndefined(node.children_); - } else if (expectedChildren === undefined) { - assert.isUndefined(node.children); - } else { - var actualChildrenMap = new Map(); - node.children.forEach(function(childNode) { - actualChildrenMap.set(childNode.title, childNode); - }); - var expectedChildrenMap = new Map(); - expectedChildren.forEach(function(childNode) { - expectedChildrenMap.set(childNode.title, childNode); - }); - assert.strictEqual(actualChildrenMap.size, expectedChildrenMap.size); - for (var title of expectedChildrenMap.keys()) { - checkTree(actualChildrenMap.get(title), - expectedChildrenMap.get(title)); - } - } - } - - function checkClassificationRules(mappedFile, expectedPath) { - var region = VMRegion.fromDict({ - mappedFile: mappedFile, - sizeInBytes: 16, - byteStats: { - privateDirtyResident: 7 - } - }); - var node = VMRegionClassificationNode.fromRegions([region]); - expectedPath.forEach(function(title) { - node = tr.b.findFirstInArray(node.children, function(childNode) { - return childNode.title === title; - }); - }); - assert.deepEqual(node.regions, [region]); - } - - test('vmRegion_protectionFlagsToString', function() { - checkProtectionFlagsToString(undefined, undefined); - checkProtectionFlagsToString(0, '---p'); - checkProtectionFlagsToString(VMRegion.PROTECTION_FLAG_READ, 'r--p'); - checkProtectionFlagsToString( - VMRegion.PROTECTION_FLAG_READ | VMRegion.PROTECTION_FLAG_MAYSHARE, - 'r--s'); - checkProtectionFlagsToString( - VMRegion.PROTECTION_FLAG_READ | VMRegion.PROTECTION_FLAG_EXECUTE, - 'r-xp'); - checkProtectionFlagsToString( - VMRegion.PROTECTION_FLAG_READ | VMRegion.PROTECTION_FLAG_WRITE, - 'rw-p'); - checkProtectionFlagsToString( - VMRegion.PROTECTION_FLAG_READ | VMRegion.PROTECTION_FLAG_WRITE | - VMRegion.PROTECTION_FLAG_EXECUTE, - 'rwxp'); - checkProtectionFlagsToString( - VMRegion.PROTECTION_FLAG_READ | VMRegion.PROTECTION_FLAG_WRITE | - VMRegion.PROTECTION_FLAG_MAYSHARE, - 'rw-s'); - checkProtectionFlagsToString( - VMRegion.PROTECTION_FLAG_READ | VMRegion.PROTECTION_FLAG_EXECUTE | - VMRegion.PROTECTION_FLAG_MAYSHARE, - 'r-xs'); - checkProtectionFlagsToString( - VMRegion.PROTECTION_FLAG_READ | VMRegion.PROTECTION_FLAG_WRITE | - VMRegion.PROTECTION_FLAG_EXECUTE | - VMRegion.PROTECTION_FLAG_MAYSHARE, - 'rwxs'); - }); - - // The add(After|Before)Build tests below check that the classification tree - // has the correct structure regardless of the ordering of adding regions and - // the lazy construction. - - test('vmRegionClassificationNode_constructor_addAfterBuild', function() { - var rootNode = new VMRegionClassificationNode(TEST_RULES); - - // Check the root node and verify that the full tree structure has *not* - // been constructed yet. - checkTree(rootNode, { - title: 'Root', - hasRegions: false, - isLeafNode: false, - children: CHILDREN_NOT_BUILT_YET - }); - - // Reading the children of the root node *should* trigger building the - // full tree. - checkTree(rootNode, { - title: 'Root', - hasRegions: false, - isLeafNode: false, - children: [ - { - title: 'Words', - hasRegions: false, - isLeafNode: false, - children: [ - { - title: 'A-D', - hasRegions: false, - isLeafNode: true, - regions: [] - }, - { - title: 'E-H', - hasRegions: false, - isLeafNode: true, - regions: [] - } - ] - }, - { - title: 'Digits', - hasRegions: false, - isLeafNode: true, - regions: [] - } - ] - }); - - // Add VM regions to the tree *after* it has been fully built. - rootNode.addRegion(VMRegion.fromDict({ - mappedFile: 'W2', // Root/Words/Other. - sizeInBytes: 16, - byteStats: { - proportionalResident: 32, - swapped: 64 - } - })); - rootNode.addRegion(VMRegion.fromDict({ - mappedFile: '__42', // Root/Digits. - byteStats: { - proportionalResident: 33, - privateDirtyResident: 77 - } - })); - checkTree(rootNode, { - title: 'Root', - hasRegions: true, - sizeInBytes: 16, - byteStats: { - proportionalResident: 32 + 33, - privateDirtyResident: 77, - swapped: 64 - }, - isLeafNode: false, - children: [ - { - title: 'Words', - hasRegions: true, - sizeInBytes: 16, - byteStats: { - proportionalResident: 32, - swapped: 64 - }, - isLeafNode: false, - children: [ - { - title: 'A-D', - hasRegions: false, - isLeafNode: true, - regions: [] - }, - { - title: 'E-H', - hasRegions: false, - isLeafNode: true, - regions: [] - }, - { - title: 'Other', - hasRegions: true, - sizeInBytes: 16, - byteStats: { - proportionalResident: 32, - swapped: 64 - }, - isLeafNode: true, - regions: [ - { - mappedFile: 'W2', - sizeInBytes: 16, - byteStats: { - proportionalResident: 32, - swapped: 64 - } - } - ] - } - ] - }, - { - title: 'Digits', - hasRegions: true, - byteStats: { - proportionalResident: 33, - privateDirtyResident: 77 - }, - isLeafNode: true, - regions: [ - { - mappedFile: '__42', - byteStats: { - proportionalResident: 33, - privateDirtyResident: 77 - } - } - ] - } - ] - }); - }); - - test('vmRegionClassificationNode_constructor_addBeforeBuild', function() { - var rootNode = new VMRegionClassificationNode(TEST_RULES); - - // Add regions to the tree *before* it has been fully built. This should - // *not* trigger building the full tree (but the total sizeInBytes and - // byteStats should be updated accordingly). - rootNode.addRegion(VMRegion.fromDict({ - mappedFile: '__42', // Root/Digits. - byteStats: { - proportionalResident: 33, - privateDirtyResident: 77 - } - })); - rootNode.addRegion(VMRegion.fromDict({ - mappedFile: 'W2', // Root/Words/Other. - sizeInBytes: 16, - byteStats: { - proportionalResident: 32, - swapped: 64 - } - })); - checkTree(rootNode, { - title: 'Root', - hasRegions: true, - sizeInBytes: 16, - byteStats: { - proportionalResident: 32 + 33, - privateDirtyResident: 77, - swapped: 64 - }, - isLeafNode: false, - children: CHILDREN_NOT_BUILT_YET - }); - - // Reading the children of the root node should trigger building the full - // tree. - checkTree(rootNode, { - title: 'Root', - hasRegions: true, - sizeInBytes: 16, - byteStats: { - proportionalResident: 32 + 33, - privateDirtyResident: 77, - swapped: 64 - }, - isLeafNode: false, - children: [ - { - title: 'Words', - hasRegions: true, - sizeInBytes: 16, - byteStats: { - proportionalResident: 32, - swapped: 64 - }, - isLeafNode: false, - children: [ - { - title: 'A-D', - hasRegions: false, - isLeafNode: true, - regions: [] - }, - { - title: 'E-H', - hasRegions: false, - isLeafNode: true, - regions: [] - }, - { - title: 'Other', - hasRegions: true, - sizeInBytes: 16, - byteStats: { - proportionalResident: 32, - swapped: 64 - }, - isLeafNode: true, - regions: [ - { - mappedFile: 'W2', - sizeInBytes: 16, - byteStats: { - proportionalResident: 32, - swapped: 64 - } - } - ] - } - ] - }, - { - title: 'Digits', - hasRegions: true, - byteStats: { - proportionalResident: 33, - privateDirtyResident: 77 - }, - isLeafNode: true, - regions: [ - { - mappedFile: '__42', - byteStats: { - proportionalResident: 33, - privateDirtyResident: 77 - } - } - ] - } - ] - }); - - // Add more VM regions *after* the tree has been fully built. - rootNode.addRegion(VMRegion.fromDict({ - mappedFile: '%invalid%', // Root/Other. - sizeInBytes: 123 - })); - rootNode.addRegion(VMRegion.fromDict({ - mappedFile: '__43', // Root/Digits. - byteStats: { - swapped: 19 - } - })); - rootNode.addRegion(VMRegion.fromDict({ - mappedFile: 'free', // Root/Words/E-H. - sizeInBytes: undefined - })); - checkTree(rootNode, { - title: 'Root', - hasRegions: true, - sizeInBytes: 16 + 123, - byteStats: { - proportionalResident: 32 + 33, - privateDirtyResident: 77, - swapped: 64 + 19, - }, - isLeafNode: false, - children: [ - { - title: 'Words', - hasRegions: true, - sizeInBytes: 16, - byteStats: { - proportionalResident: 32, - swapped: 64 - }, - isLeafNode: false, - children: [ - { - title: 'A-D', - hasRegions: false, - isLeafNode: true, - regions: [] - }, - { - title: 'E-H', - hasRegions: true, - isLeafNode: true, - regions: [ - { - mappedFile: 'free' - } - ] - }, - { - title: 'Other', - hasRegions: true, - sizeInBytes: 16, - byteStats: { - proportionalResident: 32, - swapped: 64 - }, - isLeafNode: true, - regions: [ - { - mappedFile: 'W2', - sizeInBytes: 16, - byteStats: { - proportionalResident: 32, - swapped: 64 - } - } - ] - } - ] - }, - { - title: 'Digits', - hasRegions: true, - byteStats: { - proportionalResident: 33, - privateDirtyResident: 77, - swapped: 19 - }, - isLeafNode: true, - regions: [ - { - mappedFile: '__42', - byteStats: { - proportionalResident: 33, - privateDirtyResident: 77 - } - }, - { - mappedFile: '__43', - byteStats: { - swapped: 19 - } - } - ] - }, - { - title: 'Other', - hasRegions: true, - sizeInBytes: 123, - isLeafNode: true, - regions: [ - { - mappedFile: '%invalid%', - sizeInBytes: 123 - } - ] - } - ] - }); - }); - - test('vmRegionClassificationNode_fromRegions_addAfterBuild', function() { - // Construct the root node from a list of regions. This should *not* - // trigger building the full tree (but the total sizeInBytes and byteStats - // should be updated accordingly). - var rootNode = VMRegionClassificationNode.fromRegions([ - VMRegion.fromDict({ - mappedFile: '__42', // Root/Digits. - byteStats: { - proportionalResident: 33, - privateDirtyResident: 77 - } - }), - VMRegion.fromDict({ - mappedFile: '__43', // Root/Digits. - byteStats: { - swapped: 19 - } - }) - ], TEST_RULES); - checkTree(rootNode, { - title: 'Root', - hasRegions: true, - byteStats: { - proportionalResident: 33, - privateDirtyResident: 77, - swapped: 19 - }, - isLeafNode: false, - children: CHILDREN_NOT_BUILT_YET - }); - - // Reading the children of the root node should trigger building the full - // tree. - checkTree(rootNode, { - title: 'Root', - hasRegions: true, - byteStats: { - proportionalResident: 33, - privateDirtyResident: 77, - swapped: 19 - }, - isLeafNode: false, - children: [ - { - title: 'Words', - hasRegions: false, - isLeafNode: false, - children: [ - { - title: 'A-D', - hasRegions: false, - isLeafNode: true, - regions: [] - }, - { - title: 'E-H', - hasRegions: false, - isLeafNode: true, - regions: [] - } - ] - }, - { - title: 'Digits', - hasRegions: true, - byteStats: { - proportionalResident: 33, - privateDirtyResident: 77, - swapped: 19 - }, - isLeafNode: true, - regions: [ - { - mappedFile: '__42', - byteStats: { - proportionalResident: 33, - privateDirtyResident: 77 - } - }, - { - mappedFile: '__43', - byteStats: { - swapped: 19 - } - } - ] - } - ] - }); - - // Add more VM regions *after* the tree has been fully built. - rootNode.addRegion(VMRegion.fromDict({ - mappedFile: 'W2', // Root/Words/Other. - sizeInBytes: 16, - byteStats: { - proportionalResident: 32, - swapped: 64 - } - })); - checkTree(rootNode, { - title: 'Root', - hasRegions: true, - sizeInBytes: 16, - byteStats: { - proportionalResident: 32 + 33, - privateDirtyResident: 77, - swapped: 19 + 64, - }, - isLeafNode: false, - children: [ - { - title: 'Words', - hasRegions: true, - sizeInBytes: 16, - byteStats: { - proportionalResident: 32, - swapped: 64 - }, - isLeafNode: false, - children: [ - { - title: 'A-D', - hasRegions: false, - isLeafNode: true, - regions: [] - }, - { - title: 'E-H', - hasRegions: false, - isLeafNode: true, - regions: [] - }, - { - title: 'Other', - hasRegions: true, - sizeInBytes: 16, - byteStats: { - proportionalResident: 32, - swapped: 64 - }, - isLeafNode: true, - regions: [ - { - mappedFile: 'W2', - sizeInBytes: 16, - byteStats: { - proportionalResident: 32, - swapped: 64 - } - } - ] - } - ] - }, - { - title: 'Digits', - hasRegions: true, - byteStats: { - proportionalResident: 33, - privateDirtyResident: 77, - swapped: 19 - }, - isLeafNode: true, - regions: [ - { - mappedFile: '__42', - byteStats: { - proportionalResident: 33, - privateDirtyResident: 77 - } - }, - { - mappedFile: '__43', - byteStats: { - swapped: 19 - } - } - ] - } - ] - }); - }); - - test('vmRegionClassificationNode_fromRegions_addBeforeBuild', function() { - // Construct the root node from a list of regions and then add another - // region. This should *not* trigger building the full tree (but the total - // sizeInBytes and byteStats should be updated accordingly). - var rootNode = VMRegionClassificationNode.fromRegions([ - VMRegion.fromDict({ - mappedFile: '__42', // Root/Digits. - byteStats: { - proportionalResident: 33, - privateDirtyResident: 77 - } - }), - VMRegion.fromDict({ - mappedFile: '__43', // Root/Digits. - byteStats: { - swapped: 19 - } - }) - ], TEST_RULES); - rootNode.addRegion(VMRegion.fromDict({ - mappedFile: '__42', // Root/Digits. - startAddress: 2048, // Necessary to distinguish from the first region. - sizeInBytes: 1000, - byteStats: { - privateDirtyResident: 500 - } - })); - checkTree(rootNode, { - title: 'Root', - hasRegions: true, - sizeInBytes: 1000, - byteStats: { - proportionalResident: 33, - privateDirtyResident: 77 + 500, - swapped: 19 - }, - isLeafNode: false, - children: CHILDREN_NOT_BUILT_YET - }); - - // Reading the children of the root node should trigger building the full - // tree. - checkTree(rootNode, { - title: 'Root', - hasRegions: true, - sizeInBytes: 1000, - byteStats: { - proportionalResident: 33, - privateDirtyResident: 77 + 500, - swapped: 19 - }, - isLeafNode: false, - children: [ - { - title: 'Words', - hasRegions: false, - isLeafNode: false, - children: [ - { - title: 'A-D', - hasRegions: false, - isLeafNode: true, - regions: [] - }, - { - title: 'E-H', - hasRegions: false, - isLeafNode: true, - regions: [] - } - ] - }, - { - title: 'Digits', - hasRegions: true, - sizeInBytes: 1000, - byteStats: { - proportionalResident: 33, - privateDirtyResident: 77 + 500, - swapped: 19 - }, - isLeafNode: true, - regions: [ - { - mappedFile: '__42', - byteStats: { - proportionalResident: 33, - privateDirtyResident: 77 - } - }, - { - mappedFile: '__43', - byteStats: { - swapped: 19 - } - }, - { - mappedFile: '__42', - startAddress: 2048, - sizeInBytes: 1000, - byteStats: { - privateDirtyResident: 500 - } - } - ] - } - ] - }); - - // Add more VM regions *after* the tree has been fully built. - rootNode.addRegion(VMRegion.fromDict({ - mappedFile: 'W2', // Root/Words/Other. - sizeInBytes: 16, - byteStats: { - proportionalResident: 32, - swapped: 64 - } - })); - checkTree(rootNode, { - title: 'Root', - hasRegions: true, - sizeInBytes: 1000 + 16, - byteStats: { - proportionalResident: 32 + 33, - privateDirtyResident: 500 + 77, - swapped: 19 + 64, - }, - isLeafNode: false, - children: [ - { - title: 'Words', - hasRegions: true, - sizeInBytes: 16, - byteStats: { - proportionalResident: 32, - swapped: 64 - }, - isLeafNode: false, - children: [ - { - title: 'A-D', - hasRegions: false, - isLeafNode: true, - regions: [] - }, - { - title: 'E-H', - hasRegions: false, - isLeafNode: true, - regions: [] - }, - { - title: 'Other', - hasRegions: true, - sizeInBytes: 16, - byteStats: { - proportionalResident: 32, - swapped: 64 - }, - isLeafNode: true, - regions: [ - { - mappedFile: 'W2', - sizeInBytes: 16, - byteStats: { - proportionalResident: 32, - swapped: 64 - } - } - ] - } - ] - }, - { - title: 'Digits', - hasRegions: true, - sizeInBytes: 1000, - byteStats: { - proportionalResident: 33, - privateDirtyResident: 500 + 77, - swapped: 19 - }, - isLeafNode: true, - regions: [ - { - mappedFile: '__42', - byteStats: { - proportionalResident: 33, - privateDirtyResident: 77 - } - }, - { - mappedFile: '__43', - byteStats: { - swapped: 19 - } - }, - { - mappedFile: '__42', - startAddress: 2048, - sizeInBytes: 1000, - byteStats: { - privateDirtyResident: 500 - } - } - ] - } - ] - }); - }); - - test('vmRegionClassificationNode_someRegion', function() { - var rootNode = new VMRegionClassificationNode(TEST_RULES); - - // There are no regions in the tree, so the method should always return - // false. - assert.isFalse(rootNode.someRegion(function(region) { - throw new Error('There are no regions in the tree!!!'); - })); - - rootNode.addRegion(VMRegion.fromDict({ - mappedFile: 'W2', // Root/Words/Other. - sizeInBytes: 16, - byteStats: { - proportionalResident: 32, - swapped: 64 - } - })); - rootNode.addRegion(VMRegion.fromDict({ - mappedFile: '__42', // Root/Digits. - byteStats: { - proportionalResident: 33, - privateDirtyResident: 77 - } - })); - rootNode.addRegion(VMRegion.fromDict({ - mappedFile: '__43', // Root/Digits. - byteStats: { - proportionalResident: 33, - privateDirtyResident: 77 - } - })); - - function checkSomeRegion() { - // Find the order in which the regions are traversed and checked that all - // regions were visited. - var visitedRegionMappedFiles = []; - assert.isFalse(rootNode.someRegion(function(region) { - visitedRegionMappedFiles.push(region.mappedFile); - return false; - })); - assert.lengthOf(visitedRegionMappedFiles, 3); - assert.sameMembers(visitedRegionMappedFiles, ['W2', '__42', '__43']); - - // Assuming the traversal order is deterministic, we check that once the - // callback returns true, no further regions are visited. - visitedRegionMappedFiles.forEach( - function(mappedFileToMatch, index) { - var visitedRegionMappedFiles2 = []; - assert.isTrue(rootNode.someRegion(function(region) { - this.files.push(region.mappedFile); - return region.mappedFile === mappedFileToMatch; - }, { files: visitedRegionMappedFiles2 } /* opt_this */)); - assert.deepEqual(visitedRegionMappedFiles2, - visitedRegionMappedFiles.slice(0, index + 1)); - }); - } - - // Before lazy construction (single node with a flat list of regions). - checkSomeRegion(); - assert.isUndefined(rootNode.children_); - - // After lazy construction (tree of nodes with lists of regions). - assert.isDefined(rootNode.children); // Force building the tree. - assert.isDefined(rootNode.children_); - checkSomeRegion(); - }); - - test('classificationRules', function() { - checkClassificationRules('/dev/ashmem/dalvik-main space (deleted)', - ['Android', 'Java runtime', 'Spaces', 'Normal']); - checkClassificationRules('/dev/ashmem/dalvik-non moving space', - ['Android', 'Java runtime', 'Spaces', 'Non-moving']); - checkClassificationRules('/dev/ashmem/dalvik-zygote space (deleted)', - ['Android', 'Java runtime', 'Spaces', 'Zygote']); - checkClassificationRules('/dev/ashmem/dalvik-allocation stack (deleted)', - ['Android', 'Java runtime', 'Accounting']); - checkClassificationRules( - '/dev/ashmem/dalvik-allocspace main rosalloc space 1 live-bitmap 2', - ['Android', 'Java runtime', 'Accounting']); - checkClassificationRules( - '/dev/ashmem/dalvik-allocspace non moving space live-bitmap 4', - ['Android', 'Java runtime', 'Accounting']); - checkClassificationRules('/dev/ashmem/dalvik-allocspace zygote / ' + - 'non moving space live-bitmap 0 (deleted)', - ['Android', 'Java runtime', 'Accounting']); - checkClassificationRules('/dev/ashmem/dalvik-card table (deleted)', - ['Android', 'Java runtime', 'Accounting']); - checkClassificationRules('/dev/ashmem/dalvik-large live objects (deleted)', - ['Android', 'Java runtime', 'Accounting']); - checkClassificationRules('/dev/ashmem/dalvik-live stack (deleted)', - ['Android', 'Java runtime', 'Accounting']); - checkClassificationRules( - '/dev/ashmem/dalvik-mark sweep sweep array free buffer (deleted)', - ['Android', 'Java runtime', 'Accounting']); - checkClassificationRules('/dev/ashmem/dalvik-rosalloc page map (deleted)', - ['Android', 'Java runtime', 'Accounting']); - checkClassificationRules('/dev/ashmem/dalvik-indirect ref table (deleted)', - ['Android', 'Java runtime', 'Indirect Reference Table']); - checkClassificationRules('/dev/ashmem/dalvik-LinearAlloc (deleted)', - ['Android', 'Java runtime', 'Linear Alloc']); - checkClassificationRules('/dev/ashmem/dalvik-jit-code-cache (deleted)', - ['Android', 'Java runtime', 'Cache']); - checkClassificationRules('/dev/ashmem/CursorWindow (deleted)', - ['Android', 'Cursor']); - checkClassificationRules('/dev/ashmem (deleted)', ['Android', 'Ashmem']); - checkClassificationRules('/dev/ashmem/GFXStats-10082', - ['Android', 'Ashmem']); - - checkClassificationRules('[stack:23164]', ['Stack']); - checkClassificationRules('[stack]', ['Stack']); - - checkClassificationRules('[discounted tracing overhead]', ['Native heap']); - checkClassificationRules('', ['Native heap']); - checkClassificationRules('[heap]', ['Native heap']); - checkClassificationRules('[anon:libc_malloc]', ['Native heap']); - checkClassificationRules('[anon:thread signal stack]', ['Native heap']); - checkClassificationRules('/dev/ashmem/libc malloc (deleted)', - ['Native heap']); - - checkClassificationRules('/usr/lib/nvidia-340/libGL.so.331.79', - ['Files', 'so']); - checkClassificationRules('/usr/lib/x86_64-linux-gnu/libibus-1.0.so.5.0.505', - ['Files', 'so']); - checkClassificationRules('/data/data/com.google.android.apps.chrome/' + - 'app_chrome/RELRO:libchrome.so (deleted)', ['Files', 'so']); - checkClassificationRules( - '/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf', - ['Files', 'ttf']); - checkClassificationRules( - '/data/app/com.google.android.apps.chrome-2/base.apk', - ['Files', 'apk']); - checkClassificationRules( - '/data/app/com.google.android.apps.chrome-2/lib/arm/libchrome.so', - ['Files', 'so']); - checkClassificationRules( - '/data/app/com.google.android.apps.chrome-2/oat/arm/base.odex', - ['Files', 'dex']); - checkClassificationRules( - '/data/dalvik-cache/arm/system@framework@boot.art', ['Files', 'art']); - checkClassificationRules( - '/data/dalvik-cache/arm/system@framework@boot.oat', ['Files', 'oat']); - - checkClassificationRules('/dev/nvidia0', ['Devices', 'GPU']); - checkClassificationRules('/dev/kgsl-3d0', ['Devices', 'GPU']); - checkClassificationRules('anon_inode:dmabuf', ['Devices', 'DMA']); - checkClassificationRules('/dev/binder', ['Devices', 'Other']); - - checkClassificationRules('/src/out/Release/chrome', ['Other']); - checkClassificationRules('/tmp/gluY4SVp (deleted)', ['Other']); - checkClassificationRules('/src/out/Release/resources.pak', ['Other']); - checkClassificationRules('[vdso]', ['Other']); - checkClassificationRules('[vsyscall]', ['Other']); - checkClassificationRules('[vectors]', ['Other']); - checkClassificationRules('[vvar]', ['Other']); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/x_marker_annotation.html b/chromium/third_party/catapult/tracing/tracing/model/x_marker_annotation.html deleted file mode 100644 index a5bd1e346e2..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/model/x_marker_annotation.html +++ /dev/null @@ -1,51 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2015 The Chromium Authors. All rights reserved. -Use of this source code is governed by a BSD-style license that can be -found in the LICENSE file. ---> - -<link rel="import" href="/tracing/model/annotation.html"> -<link rel="import" href="/tracing/ui/annotations/x_marker_annotation_view.html"> - -<script> -'use strict'; - -tr.exportTo('tr.model', function() { - - function XMarkerAnnotation(timestamp) { - tr.model.Annotation.apply(this, arguments); - - this.timestamp = timestamp; - this.strokeStyle = 'rgba(0, 0, 255, 0.5)'; - } - - XMarkerAnnotation.fromDict = function(dict) { - return new XMarkerAnnotation(dict.args.timestamp); - } - - XMarkerAnnotation.prototype = { - __proto__: tr.model.Annotation.prototype, - - toDict: function() { - return { - typeName: 'xmarker', - args: { - timestamp: this.timestamp - } - }; - }, - - createView_: function(viewport) { - return new tr.ui.annotations.XMarkerAnnotationView(viewport, this); - } - }; - - tr.model.Annotation.register( - XMarkerAnnotation, {typeName: 'xmarker'}); - - return { - XMarkerAnnotation: XMarkerAnnotation - }; -}); -</script> |