diff options
Diffstat (limited to 'chromium/third_party/catapult/tracing/tracing/value')
47 files changed, 0 insertions, 5891 deletions
diff --git a/chromium/third_party/catapult/tracing/tracing/value/__init__.py b/chromium/third_party/catapult/tracing/tracing/value/__init__.py deleted file mode 100644 index c134637dac2..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/__init__.py +++ /dev/null @@ -1,192 +0,0 @@ -# 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. - -# Simplified version of telemetry Value system, just enough for us to get -# us up and running. - - -class Value(object): - - def __init__(self, canonical_url, name, units, description=None, - important=False, ir_stable_id=None): - self.canonical_url = canonical_url - self.name = name - self.units = units - self.description = description - self.important = important - self.ir_stable_id = ir_stable_id - - def AsDict(self): - d = { - 'canonical_url': self.canonical_url, - 'name': self.name, - 'important': self.important - } - # Only dump values if they're non-None, because Python json-ification turns - # these to null, instead of leaving them out. - if self.units is not None: - d['units'] = self.units - - if self.description is not None: - d['description'] = self.description - - if self.ir_stable_id is not None: - d['ir_stable_id'] = self.ir_stable_id - - self._AsDictInto(d) - assert 'type' in d - - return d - - def _AsDictInto(self, d): - raise NotImplementedError() - - @classmethod - def FromDict(cls, d): - if d['type'] == 'dict': - return DictValue.FromDict(d) - elif d['type'] == 'scalar': - return ScalarValue.FromDict(d) - elif d['type'] == 'failure': - return FailureValue.FromDict(d) - elif d['type'] == 'skip': - return SkipValue.FromDict(d) - else: - raise NotImplementedError() - - -# TODO(eakuefner): Change to NumericValue after porting Unit -# (https://github.com/catapult-project/catapult/issues/2049) -class ScalarValue(Value): - - def __init__(self, canonical_url, name, value, description=None, - important=False, ir_stable_id=None): - assert isinstance(value, dict) - super(ScalarValue, self).__init__(canonical_url, name, units=None, - description=description, - important=important, - ir_stable_id=ir_stable_id) - self._value = value - - def __repr__(self): - return '%s("%s", "%s")' % (self.__class__.__name__, - self.name, self.value) - - def _AsDictInto(self, d): - d['type'] = 'scalar' - d['value'] = self._value - - @classmethod - def FromDict(cls, d): - assert d.get('units', None) == None - return cls(d['canonical_url'], name=d['name'], - description=d.get('description', None), - value=d['value'], - important=d['important'], - ir_stable_id=d.get('ir_stable_id', None)) - - @property - def value(self): - return self._value - - def __getitem__(self, key): - return self._value[key] - - -class DictValue(Value): - - def __init__(self, canonical_url, name, value, description=None, - important=False, ir_stable_id=None): - assert isinstance(value, dict) - super(DictValue, self).__init__(canonical_url, name, units=None, - description=description, - important=important, - ir_stable_id=ir_stable_id) - self._value = value - - def __repr__(self): - return '%s("%s", "%s")' % (self.__class__.__name__, - self.name, self.value) - - def _AsDictInto(self, d): - d['type'] = 'dict' - d['value'] = self._value - - @classmethod - def FromDict(cls, d): - assert d.get('units', None) == None - return cls(d['canonical_url'], name=d['name'], - description=d.get('description', None), - value=d['value'], - important=d['important'], - ir_stable_id=d.get('ir_stable_id', None)) - - @property - def value(self): - return self._value - - def __getitem__(self, key): - return self._value[key] - -class FailureValue(Value): - - def __init__(self, canonical_url, failure_type_name, description, stack, - important=False, ir_stable_id=None): - super(FailureValue, self).__init__(canonical_url, - name=failure_type_name, - units=None, - description=description, - important=important, - ir_stable_id=ir_stable_id) - assert isinstance(stack, basestring) - self.stack = stack - - def __repr__(self): - return '%s("%s", "%s")' % (self.__class__.__name__, - self.name, self.description) - - def _AsDictInto(self, d): - d['type'] = 'failure' - d['stack_str'] = self.stack - - @classmethod - def FromDict(cls, d): - assert d.get('units', None) == None - return cls(d['canonical_url'], - failure_type_name=d['name'], - description=d.get('description', None), - stack=d['stack_str'], - important=d.get('important', False), - ir_stable_id=d.get('ir_stable_id', None)) - - def GetGTestPrintString(self): - return self.stack - - -class SkipValue(Value): - - def __init__(self, canonical_url, skipped_result_name, - description=None, important=False, ir_stable_id=None): - super(SkipValue, self).__init__(canonical_url, - name=skipped_result_name, - units=None, - description=description, - important=important, - ir_stable_id=ir_stable_id) - - def __repr__(self): - return '%s("%s", "%s")' % (self.__class__.__name__, - self.name, self.description) - - def _AsDictInto(self, d): - d['type'] = 'skip' - - @classmethod - def FromDict(cls, d): - assert d.get('units', None) == None - return cls(d['canonical_url'], - skipped_result_name=d['name'], - description=d.get('description', None), - important=d.get('important', False), - ir_stable_id=d.get('ir_stable_id', None)) diff --git a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/composition.html b/chromium/third_party/catapult/tracing/tracing/value/diagnostics/composition.html deleted file mode 100644 index c58f29d0b02..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/composition.html +++ /dev/null @@ -1,33 +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/value/diagnostics/related_value_set.html"> - -<script> -'use strict'; - -tr.exportTo('tr.v.d', function() { - /** @constructor */ - function Composition(opt_values) { - tr.v.d.RelatedValueSet.call(this, opt_values); - } - - Composition.prototype = { - __proto__: tr.v.d.RelatedValueSet.prototype - }; - - Composition.fromDict = function(d) { - return new Composition(d.guids.map(guid => new tr.v.d.ValueRef(guid))); - }; - - tr.v.d.Diagnostic.register(Composition); - - return { - Composition: Composition - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/diagnostic.html b/chromium/third_party/catapult/tracing/tracing/value/diagnostics/diagnostic.html deleted file mode 100644 index 2b65454620b..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/diagnostic.html +++ /dev/null @@ -1,60 +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/extension_registry.html"> - -<script> -'use strict'; - -tr.exportTo('tr.v.d', function() { - /** @constructor */ - function Diagnostic() { - } - - Diagnostic.prototype = { - asDict: function() { - var result = {type: this.constructor.name}; - this.asDictInto_(result); - return result; - }, - - asDictInto_: function(d) { - throw new Error('Abstract virtual method'); - } - }; - - var options = new tr.b.ExtensionRegistryOptions(tr.b.BASIC_REGISTRY_MODE); - options.defaultMetadata = {}; - options.mandatoryBaseClass = Diagnostic; - tr.b.decorateExtensionRegistry(Diagnostic, options); - - Diagnostic.addEventListener('will-register', function(e) { - var constructor = e.typeInfo.constructor; - if (!(constructor.fromDict instanceof Function) || - (constructor.fromDict.length !== 1)) { - throw new Error('Diagnostics must define fromDict(d)'); - } - - // When subclasses set their prototype to an entirely new object and omit - // their constructor, then it becomes impossible for asDict() to find their - // constructor name. Add it back here so that asDict() can find it. - constructor.prototype.constructor = constructor; - }); - - Diagnostic.fromDict = function(d) { - var typeInfo = Diagnostic.findTypeInfoWithName(d.type); - if (!typeInfo) - throw new Error('Unrecognized diagnostic type: ' + d.type); - - return typeInfo.constructor.fromDict(d); - }; - - return { - Diagnostic: Diagnostic - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/diagnostic_map.html b/chromium/third_party/catapult/tracing/tracing/value/diagnostics/diagnostic_map.html deleted file mode 100644 index 4af13e22d54..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/diagnostic_map.html +++ /dev/null @@ -1,98 +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. ---> - -<!-- - Include all Diagnostic subclasses here so that DiagnosticMap.addDicts() and - DiagnosticMap.fromDict() always have access to all subclasses in the - Diagnostic registry. ---> - -<link rel="import" href="/tracing/value/diagnostics/composition.html"> -<link rel="import" href="/tracing/value/diagnostics/generic.html"> -<link rel="import" href="/tracing/value/diagnostics/iteration_info.html"> -<link rel="import" href="/tracing/value/diagnostics/related_event_set.html"> -<link rel="import" href="/tracing/value/diagnostics/related_value_map.html"> -<link rel="import" href="/tracing/value/diagnostics/related_value_set.html"> - -<script> -'use strict'; - -tr.exportTo('tr.v.d', function() { - /** @constructor */ - function DiagnosticMap() { - this.diagnosticsByName_ = {}; - } - - DiagnosticMap.prototype = { - /** - * Add a new Diagnostic to this map. - * - * @param {string} name - * @param {!tr.v.d.Diagnostic} diagnostic - */ - add: function(name, diagnostic) { - if (!(diagnostic instanceof tr.v.d.Diagnostic)) - throw new Error('Must be instanceof Diagnostic: ' + diagnostic); - - if (typeof(name) !== 'string') - throw new Error('name must be string, not ' + name); - - if (this.diagnosticsByName_[name]) - throw new Error('Attempt to add duplicate diagnostic ' + name); - - this.diagnosticsByName_[name] = diagnostic; - }, - - /** - * Add Diagnostics from a dictionary of dictionaries. - * - * @param {Object} dict - */ - addDicts: function(dict) { - tr.b.iterItems(dict, function(name, diagnosticDict) { - this.add(name, tr.v.d.Diagnostic.fromDict(diagnosticDict)); - }, this); - }, - - /** - * @param {string} name - * @return {tr.v.d.Diagnostic} - */ - get: function(name) { - return this.diagnosticsByName_[name]; - }, - - /** - * Iterate over this map's key-value-pairs. - * - * @param {function(string, tr.v.d.Diagnostic)} callback - * @param {Object=} opt_this - */ - forEach: function(callback, opt_this) { - tr.b.iterItems(this.diagnosticsByName_, callback, opt_this || this); - }, - - asDict: function() { - var dict = {}; - this.forEach(function(name, diagnostic) { - dict[name] = diagnostic.asDict(); - }); - return dict; - } - }; - - DiagnosticMap.fromDict = function(d) { - var diagnostics = new DiagnosticMap(); - diagnostics.addDicts(d); - return diagnostics; - }; - - return { - DiagnosticMap: DiagnosticMap - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/generic.html b/chromium/third_party/catapult/tracing/tracing/value/diagnostics/generic.html deleted file mode 100644 index 7ac19796e34..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/generic.html +++ /dev/null @@ -1,46 +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/value/diagnostics/diagnostic.html"> - -<script> -'use strict'; - -tr.exportTo('tr.v.d', function() { - /** - * A Generic diagnostic can contain any Plain-Ol'-Data objects that can be - * serialized using JSON.stringify(): null, boolean, number, string, array, - * dict. Generic diagnostics cannot contain tr.v.Value objects! - * - * @constructor - * @param {*} value - */ - function Generic(value) { - this.value = value; - } - - Generic.prototype = { - __proto__: tr.v.d.Diagnostic.prototype, - - asDictInto_: function(d) { - d.value = this.value; - } - }; - - Generic.fromDict = function(d) { - return new Generic(d.value); - }; - - tr.v.d.Diagnostic.register(Generic, { - elementName: 'tr-v-ui-generic-diagnostic-span' - }); - - return { - Generic: Generic - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/iteration_info.html b/chromium/third_party/catapult/tracing/tracing/value/diagnostics/iteration_info.html deleted file mode 100644 index d2047935916..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/iteration_info.html +++ /dev/null @@ -1,102 +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/value/diagnostics/diagnostic.html"> - -<script> -'use strict'; - -tr.exportTo('tr.v.d', function() { - /** - * @constructor - * @param {!Object} info - * @param {string} info.benchmarkName - * @param {undefined|string} info.label - * @param {undefined|!Object} info.storyGroupingKeys - * @param {undefined|string} info.storyDisplayName - * @param {string} info.storyUrl - * @param {number} info.storyRepeatCounter - * @param {number} info.storysetRepeatCounter - * @param {number} info.benchmarkStartMs Milliseconds since Unix epoch. - */ - function IterationInfo(info) { - this.benchmarkName_ = info.benchmarkName; - this.benchmarkStart_ = new Date(info.benchmarkStartMs); - this.label_ = info.label; - this.storyDisplayName_ = info.storyDisplayName; - this.storyGroupingKeys_ = info.storyGroupingKeys; - this.storyRepeatCounter_ = info.storyRepeatCounter; - this.storyUrl_ = info.storyUrl; - this.storysetRepeatCounter_ = info.storysetRepeatCounter; - } - - IterationInfo.prototype = { - __proto__: tr.v.d.Diagnostic.prototype, - - asDictInto_: function(d) { - d.benchmarkName = this.benchmarkName; - d.benchmarkStartMs = this.benchmarkStart.getTime(); - d.label = this.label; - d.storyDisplayName = this.storyDisplayName; - d.storyGroupingKeys = this.storyGroupingKeys; - d.storyRepeatCounter = this.storyRepeatCounter; - d.storyUrl = this.storyUrl; - d.storysetRepeatCounter = this.storysetRepeatCounter; - }, - - get displayLabel() { - if (this.label) - return this.label; - return this.benchmarkName + ' ' + this.benchmarkStart; - }, - - get benchmarkName() { - return this.benchmarkName_; - }, - - get label() { - return this.label_; - }, - - get storyGroupingKeys() { - return this.storyGroupingKeys_; - }, - - get storyDisplayName() { - return this.storyDisplayName_; - }, - - get storyUrl() { - return this.storyUrl_; - }, - - get storyRepeatCounter() { - return this.storyRepeatCounter_; - }, - - get storysetRepeatCounter() { - return this.storysetRepeatCounter_; - }, - - get benchmarkStart() { - return this.benchmarkStart_; - } - }; - - IterationInfo.fromDict = function(d) { - return new IterationInfo(d); - }; - - tr.v.d.Diagnostic.register(IterationInfo, { - elementName: 'tr-v-ui-iteration-info-span' - }); - - return { - IterationInfo: IterationInfo - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/related_event_set.html b/chromium/third_party/catapult/tracing/tracing/value/diagnostics/related_event_set.html deleted file mode 100644 index fa611de3695..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/related_event_set.html +++ /dev/null @@ -1,122 +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/event_set.html"> -<link rel="import" href="/tracing/value/diagnostics/diagnostic.html"> - -<script> -'use strict'; - -tr.exportTo('tr.v.d', function() { - /** - * Similar to ValueRef, this is a placeholder in case the referenced Event - * isn't available in memory to point to directly. - * - * @constructor - * @param {!Object} event - * @param {string} event.stableId - * @param {string} event.title - * @param {number} event.start - * @param {number} event.duration - */ - function EventRef(event) { - this.stableId = event.stableId; - this.title = event.title; - this.start = event.start; - this.duration = event.duration; - this.end = this.start + this.duration; - - // tr.v.d.RelatedEventSet identifies events using stableId, but - // tr.model.EventSet uses guid. - this.guid = tr.b.GUID.allocateSimple(); - } - - /** - * A RelatedEventSet diagnostic contains references to Events - * - * @constructor - * @param {(!tr.model.EventSet|Array.<!(EventRef|tr.model.Event)>|!EventRef|!tr.model.Event)=} opt_events - */ - function RelatedEventSet(opt_events) { - this.eventsByStableId_ = {}; - - if (opt_events) { - if (opt_events instanceof tr.model.EventSet || - opt_events instanceof Array) - opt_events.forEach(this.push.bind(this)); - else - this.push(opt_events); - } - } - - RelatedEventSet.prototype = { - __proto__: tr.v.d.Diagnostic.prototype, - - /** - * Add an event to this set. - * - * @param {!(EventRef|tr.model.Event)} event - */ - push: function(event) { - this.eventsByStableId_[event.stableId] = event; - }, - - /** - * @return {!Array.<!(EventRef|tr.model.Event)>} - */ - get events() { - return tr.b.dictionaryValues(this.eventsByStableId_); - }, - - /** - * Resolve all EventRefs into Events by finding their stableIds in |model|. - * If a stableId cannot be found and |opt_required| is true, then throw an - * Error. - * If a stableId cannot be found and |opt_required| is false, then the - * EventRef will remain an EventRef. - * - * @param {!tr.model.Model} model - * @param {boolean=} opt_required - */ - resolve: function(model, opt_required) { - tr.b.iterItems(this.eventsByStableId_, function(stableId, event) { - if (!(event instanceof EventRef)) - return; - - event = model.getEventByStableId(stableId); - if (event instanceof tr.model.Event) - this.eventsByStableId_[stableId] = event; - else if (opt_required) - throw new Error('Unable to find Event ' + ref.stableId); - }, this); - }, - - asDictInto_: function(d) { - d.events = this.events.map(function eventAsDict(event) { - return { - stableId: event.stableId, - title: event.title, - start: event.start, - duration: event.duration - }; - }); - } - }; - - RelatedEventSet.fromDict = function(d) { - return new RelatedEventSet(d.events.map(event => new EventRef(event))); - }; - - tr.v.d.Diagnostic.register(RelatedEventSet, { - elementName: 'tr-v-ui-related-event-set-span' - }); - - return { - RelatedEventSet: RelatedEventSet - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/related_event_set_test.html b/chromium/third_party/catapult/tracing/tracing/value/diagnostics/related_event_set_test.html deleted file mode 100644 index de901b53e2d..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/related_event_set_test.html +++ /dev/null @@ -1,52 +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/value/diagnostics/related_event_set.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('eventSet', function() { - var slice = undefined; - var model = tr.c.TestUtils.newModel(function(model) { - slice = tr.c.TestUtils.newSliceEx({ - type: tr.model.ThreadSlice, - title: 'foo', - start: 0, - duration: 10 - }); - var thread = model.getOrCreateProcess(1).getOrCreateThread(2); - thread.sliceGroup.pushSlice(slice); - }); - - var d = new tr.v.d.RelatedEventSet(slice); - assert.lengthOf(d.events, 1); - assert.strictEqual(d.events[0], slice); - - d = new tr.v.d.RelatedEventSet([slice]); - assert.lengthOf(d.events, 1); - assert.strictEqual(d.events[0], slice); - - d = new tr.v.d.RelatedEventSet(new tr.model.EventSet([slice])); - assert.lengthOf(d.events, 1); - assert.strictEqual(d.events[0], slice); - - var d2 = tr.v.d.Diagnostic.fromDict(d.asDict()); - assert.instanceOf(d2, tr.v.d.RelatedEventSet); - assert.lengthOf(d2.events, 1); - - // Can't use assert.instanceOf() because EventRef is private. - assert.isFalse(d2.events[0] instanceof tr.model.Event); - - d2.resolve(model, true); - - assert.strictEqual(d2.events[0], slice); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/related_value_map.html b/chromium/third_party/catapult/tracing/tracing/value/diagnostics/related_value_map.html deleted file mode 100644 index b3ee5011017..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/related_value_map.html +++ /dev/null @@ -1,110 +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"> -<link rel="import" href="/tracing/value/diagnostics/related_value_set.html"> - -<script> -'use strict'; - -tr.exportTo('tr.v.d', function() { - /** @constructor */ - function RelatedValueMap() { - this.valuesByName_ = {}; - } - - RelatedValueMap.prototype = { - __proto__: tr.v.d.Diagnostic.prototype, - - /** - * Add a named Value to this map. - * - * @param {string} name - * @param {!(tr.v.d.ValueRef|tr.v.Value)} value - */ - set: function(name, value) { - if (!(value instanceof tr.v.Value) && - !(value instanceof tr.v.d.ValueRef)) - throw new Error('Must be instanceof Value or ValueRef: ' + value); - - this.valuesByName_[name] = value; - }, - - /** - * Iterate over the named Values. - * - * @param {!function(string, !(tr.v.d.ValueRef|tr.v.Value))} callback - * @param {*=} opt_this - */ - iterItems: function(callback, opt_this) { - tr.b.iterItems(this.valuesByName_, callback, opt_this || this); - }, - - /** - * @return {!Array.<!(tr.v.d.ValueRef|tr.v.Value)>} - */ - get values() { - return tr.b.dictionaryValues(this.valuesByName_); - }, - - /** - * Lookup a Value by name. Returns undefined if |name| is not found. - * - * @param {string} name - * @return {!tr.v.d.ValueRef|!tr.v.Value|undefined} - */ - get: function(name) { - return this.valuesByName_[name]; - }, - - /** - * Resolve all ValueRefs into Values by looking up their guids in - * |valueSet|. - * If a value cannot be found and |opt_required| is true, then throw an - * Error. - * If a value cannot be found and |opt_required| is false, then the ValueRef - * will remain a ValueRef. - * - * @param {!tr.v.ValueSet} valueSet - * @param {boolean=} opt_required - */ - resolve: function(valueSet, opt_required) { - this.iterItems(function(name, value) { - if (!(value instanceof tr.v.d.ValueRef)) - return; - - value = valueSet.lookup(value.guid); - if (value instanceof tr.v.Value) - this.valuesByName_[name] = value; - else if (opt_required) - throw new Error('Unable to find Value ' + guid); - }, this); - }, - - asDictInto_: function(d) { - d.values = tr.b.mapItems(this.valuesByName_, (name, value) => value.guid); - } - }; - - RelatedValueMap.fromDict = function(d) { - var map = new RelatedValueMap(); - tr.b.iterItems(d.values, function(name, guid) { - map.set(name, new tr.v.d.ValueRef(guid)); - }); - return map; - }; - - tr.v.d.Diagnostic.register(RelatedValueMap, { - elementName: 'tr-v-ui-related-value-map-span' - }); - - - return { - RelatedValueMap: RelatedValueMap - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/related_value_set.html b/chromium/third_party/catapult/tracing/tracing/value/diagnostics/related_value_set.html deleted file mode 100644 index 412c4dff0f2..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/related_value_set.html +++ /dev/null @@ -1,96 +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"> -<link rel="import" href="/tracing/value/diagnostics/diagnostic.html"> - -<script> -'use strict'; - -tr.exportTo('tr.v.d', function() { - /** @constructor */ - function ValueRef(guid) { - this.guid = guid; - } - - /** @constructor */ - function RelatedValueSet(opt_values) { - this.valuesByGuid_ = {}; - - if (opt_values) - opt_values.forEach(this.add, this); - } - - RelatedValueSet.prototype = { - __proto__: tr.v.d.Diagnostic.prototype, - - /** - * Add a Value to this set. - * - * @param {!(ValueRef|tr.v.Value)} v - */ - add: function(value) { - if (!(value instanceof tr.v.Value) && - !(value instanceof ValueRef)) - throw new Error('Must be instanceof Value or ValueRef: ' + value); - - if (this.valuesByGuid_[value.guid]) - throw new Error('Tried to add same value twice'); - - this.valuesByGuid_[value.guid] = value; - }, - - /** - * @return {Array.<(ValueRef|tr.v.Value)>} - */ - get values() { - return tr.b.dictionaryValues(this.valuesByGuid_); - }, - - /** - * Resolve all ValueRefs into Values by looking up their guids in - * |valueSet|. - * If a value cannot be found and |opt_required| is true, then throw an - * Error. - * If a value cannot be found and |opt_required| is false, then the ValueRef - * will remain a ValueRef. - * - * @param {!tr.v.ValueSet} valueSet - * @param {boolean=} opt_required - */ - resolve: function(valueSet, opt_required) { - tr.b.iterItems(this.valuesByGuid_, function(guid, value) { - if (!(value instanceof ValueRef)) - return; - - value = valueSet.lookup(guid); - if (value instanceof tr.v.Value) - this.valuesByGuid_[guid] = value; - else if (opt_required) - throw new Error('Unable to find Value ' + guid); - }, this); - }, - - asDictInto_: function(d) { - d.guids = tr.b.dictionaryKeys(this.valuesByGuid_); - } - }; - - RelatedValueSet.fromDict = function(d) { - return new RelatedValueSet(d.guids.map(guid => new ValueRef(guid))); - }; - - tr.v.d.Diagnostic.register(RelatedValueSet, { - elementName: 'tr-v-ui-related-value-set-span' - }); - - return { - RelatedValueSet: RelatedValueSet, - ValueRef: ValueRef - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/generic_table.html b/chromium/third_party/catapult/tracing/tracing/value/generic_table.html deleted file mode 100644 index 220510c8952..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/generic_table.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/base/base.html"> -<script> -'use strict'; - -tr.exportTo('tr.v', function() { - /** - * Tabular data wrapper. Simply wraps an array of items. - */ - function GenericTable(items) { - if (items !== undefined) - this.items = items; - else - this.items = []; - }; - - GenericTable.prototype = { - }; - - return { - GenericTable: GenericTable - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/numeric.html b/chromium/third_party/catapult/tracing/tracing/value/numeric.html deleted file mode 100644 index f8fc53f890a..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/numeric.html +++ /dev/null @@ -1,667 +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"> -<link rel="import" href="/tracing/base/range.html"> -<link rel="import" href="/tracing/base/running_statistics.html"> -<link rel="import" href="/tracing/base/sorted_array_utils.html"> -<link rel="import" href="/tracing/base/statistics.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -tr.exportTo('tr.v', function() { - var Range = tr.b.Range; - - var MAX_SOURCE_INFOS = 16; - - function NumericBase(unit) { - if (!(unit instanceof tr.v.Unit)) - throw new Error('Expected provided unit to be instance of Unit'); - - this.unit = unit; - } - - NumericBase.prototype = { - asDict: function() { - var d = { - unit: this.unit.asJSON() - }; - - this.asDictInto_(d); - return d; - } - }; - - NumericBase.fromDict = function(d) { - if (d.type === 'scalar') - return ScalarNumeric.fromDict(d); - - if (d.type === 'numeric') - return Numeric.fromDict(d); - - throw new Error('Not implemented'); - }; - - function NumericBin(parentNumeric, opt_range) { - this.parentNumeric = parentNumeric; - this.range = opt_range || (new tr.b.Range()); - this.count = 0; - this.sourceInfos = []; - } - - NumericBin.fromDict = function(parentNumeric, d) { - var n = new NumericBin(parentNumeric); - n.range.min = d.min; - n.range.max = d.max; - n.count = d.count; - n.sourceInfos = d.sourceInfos; - return n; - }; - - NumericBin.prototype = { - add: function(value, sourceInfo) { - this.count += 1; - tr.b.Statistics.uniformlySampleStream(this.sourceInfos, this.count, - sourceInfo, MAX_SOURCE_INFOS); - }, - - addBin: function(other) { - if (!this.range.equals(other.range)) - throw new Error('Merging incompatible Numeric bins.'); - tr.b.Statistics.mergeSampledStreams(this.sourceInfos, this.count, - other.sourceInfos, other.count, MAX_SOURCE_INFOS); - this.count += other.count; - }, - - asDict: function() { - return { - min: this.range.min, - max: this.range.max, - count: this.count, - sourceInfos: this.sourceInfos.slice(0) - }; - }, - - asJSON: function() { - return this.asDict(); - } - }; - - function Numeric(unit, range, binInfo) { - NumericBase.call(this, unit); - - this.range = range; - - this.numNans = 0; - this.nanSourceInfos = []; - - this.running = new tr.b.RunningStatistics(); - this.maxCount_ = 0; - - this.underflowBin = binInfo.underflowBin; - this.centralBins = binInfo.centralBins; - this.overflowBin = binInfo.overflowBin; - - this.allBins = []; - this.allBins.push(this.underflowBin); - this.allBins.push.apply(this.allBins, this.centralBins); - this.allBins.push(this.overflowBin); - - this.allBins.forEach(function(bin) { - if (bin.count > this.maxCount_) - this.maxCount_ = bin.count; - }, this); - - this.summaryOptions = this.defaultSummaryOptions(); - } - - Numeric.fromDict = function(d) { - var range = Range.fromExplicitRange(d.min, d.max); - var binInfo = {}; - binInfo.underflowBin = NumericBin.fromDict(undefined, d.underflowBin); - binInfo.centralBins = d.centralBins.map(function(binAsDict) { - return NumericBin.fromDict(undefined, binAsDict); - }); - binInfo.overflowBin = NumericBin.fromDict(undefined, d.overflowBin); - var n = new Numeric(tr.v.Unit.fromJSON(d.unit), range, binInfo); - n.allBins.forEach(function(bin) { - bin.parentNumeric = n; - }); - if (d.running) - n.running = tr.b.RunningStatistics.fromDict(d.running); - if (d.summaryOptions) - n.customizeSummaryOptions(d.summaryOptions); - n.numNans = d.numNans; - n.nanSourceInfos = d.nanSourceInfos; - return n; - }; - - Numeric.prototype = { - __proto__: NumericBase.prototype, - - get numValues() { - return tr.b.Statistics.sum(this.allBins, function(e) { - return e.count; - }); - }, - - get average() { - return this.running.mean; - }, - - get sum() { - return this.running.sum; - }, - - get maxCount() { - return this.maxCount_; - }, - - /* - * Compute an approximation of percentile based on the counts in the bins. - * If the real percentile lies within |this.range| then the result of - * the function will deviate from the real percentile by at most - * the maximum width of the bin(s) within which the point(s) - * from which the real percentile would be calculated lie. - * If the real percentile is outside |this.range| then the function - * returns the closest range limit: |this.range.min| or |this.range.max|. - * - * @param {number} percent The percent must be between 0.0 and 1.0. - */ - getApproximatePercentile: function(percent) { - if (!(percent >= 0 && percent <= 1)) - throw new Error('percent must be [0,1]'); - if (this.numValues == 0) - return 0; - var valuesToSkip = Math.floor((this.numValues - 1) * percent); - for (var i = 0; i < this.allBins.length; i++) { - var bin = this.allBins[i]; - valuesToSkip -= bin.count; - if (valuesToSkip < 0) { - if (bin === this.underflowBin) - return bin.range.max; - else if (bin === this.overflowBin) - return bin.range.min; - else - return bin.range.center; - } - } - throw new Error('Unreachable'); - }, - - getInterpolatedCountAt: function(value) { - var bin = this.getBinForValue(value); - var idx = this.centralBins.indexOf(bin); - if (idx < 0) { - // |value| is in either the underflowBin or the overflowBin. - // We can't interpolate between infinities. - return bin.count; - } - - // |value| must fall between the centers of two bins. - // The bin whose center is less than |value| will be this: - var lesserBin = bin; - - // The bin whose center is greater than |value| will be this: - var greaterBin = bin; - - // One of those bins could be an under/overflow bin. - // Avoid dealing with Infinities by arbitrarily saying that center of the - // underflow bin is its range.max, and the center of the overflow bin is - // its range.min. - // The centers of bins in |this.centralBins| will default to their - // |range.center|. - - var lesserBinCenter = undefined; - var greaterBinCenter = undefined; - - if (value < greaterBin.range.center) { - if (idx > 0) { - lesserBin = this.centralBins[idx - 1]; - } else { - lesserBin = this.underflowBin; - lesserBinCenter = lesserBin.range.max; - } - } else { - if (idx < (this.centralBins.length - 1)) { - greaterBin = this.centralBins[idx + 1]; - } else { - greaterBin = this.overflowBin; - greaterBinCenter = greaterBin.range.min; - } - } - - if (greaterBinCenter === undefined) - greaterBinCenter = greaterBin.range.center; - - if (lesserBinCenter === undefined) - lesserBinCenter = lesserBin.range.center; - - value = tr.b.normalize(value, lesserBinCenter, greaterBinCenter); - - return tr.b.lerp(value, lesserBin.count, greaterBin.count); - }, - - getBinForValue: function(value) { - // Don't use subtraction to avoid arithmetic overflow. - var binIndex = tr.b.findHighIndexInSortedArray( - this.allBins, b => value < b.range.max ? -1 : 1); - return this.allBins[binIndex] || this.overflowBin; - }, - - add: function(value, sourceInfo) { - if (typeof(value) !== 'number' || isNaN(value)) { - this.numNans++; - tr.b.Statistics.uniformlySampleStream(this.nanSourceInfos, this.numNans, - sourceInfo, MAX_SOURCE_INFOS); - return; - } - - var bin = this.getBinForValue(value); - bin.add(value, sourceInfo); - this.running.add(value); - if (bin.count > this.maxCount_) - this.maxCount_ = bin.count; - }, - - addNumeric: function(other) { - if (!this.range.equals(other.range) || - !this.unit === other.unit || - this.allBins.length !== other.allBins.length) { - throw new Error('Merging incompatible Numerics.'); - } - tr.b.Statistics.mergeSampledStreams(this.nanSourceInfos, this.numNans, - other.nanSourceInfos, other.numNans, MAX_SOURCE_INFOS); - this.numNans += other.numNans; - this.running = this.running.merge(other.running); - for (var i = 0; i < this.allBins.length; ++i) { - this.allBins[i].addBin(other.allBins[i]); - } - }, - - /** - * Controls which statistics are exported to dashboard for this numeric. - * The |summaryOptions| parameter is a dictionary with optional boolean - * fields |count|, |sum|, |avg|, |std|, |min|, |max| and an optional - * array field |percentile|. - * Each percentile should be a number between 0.0 and 1.0. - * The options not included in the |summaryOptions| will not change. - */ - customizeSummaryOptions: function(summaryOptions) { - tr.b.iterItems(summaryOptions, function(key, value) { - this.summaryOptions[key] = value; - }, this); - }, - - defaultSummaryOptions: function() { - return { - count: true, - sum: true, - avg: true, - std: true, - min: true, - max: true, - percentile: [] - }; - }, - - /** - * Returns an array of {name: string, scalar: ScalarNumeric} values. - * Each enabled summary option produces the corresponding value: - * min, max, count, sum, avg, or std. - * Each percentile 0.x produces pct_0x0. - * Each percentile 0.xx produces pct_0xx. - * Each percentile 0.xxy produces pct_0xx_y. - * Percentile 1.0 produces pct_100. - */ - getSummarizedScalarNumericsWithNames: function() { - function statNameToKey(stat) { - switch (stat) { - case 'std': - return 'stddev'; - case 'avg': - return 'mean'; - } - return stat; - } - /** - * Converts the given percent to a string in the format specified above. - * @param {number} percent The percent must be between 0.0 and 1.0. - */ - function percentToString(percent) { - if (percent < 0 || percent > 1) - throw new Error('Percent must be between 0.0 and 1.0'); - switch (percent) { - case 0: - return '000'; - case 1: - return '100'; - } - var str = percent.toString(); - if (str[1] !== '.') - throw new Error('Unexpected percent'); - // Pad short strings with zeros. - str = str + '0'.repeat(Math.max(4 - str.length, 0)); - if (str.length > 4) - str = str.slice(0, 4) + '_' + str.slice(4); - return '0' + str.slice(2); - } - - var results = []; - tr.b.iterItems(this.summaryOptions, function(stat, option) { - if (!option) - return; - if (stat === 'percentile') { - option.forEach(function(percent) { - var percentile = this.getApproximatePercentile(percent); - results.push({ - name: 'pct_' + percentToString(percent), - scalar: new tr.v.ScalarNumeric(this.unit, percentile) - }); - }, this); - } else { - var statUnit = stat === 'count' ? - tr.v.Unit.byName.unitlessNumber_smallerIsBetter : this.unit; - var key = statNameToKey(stat); - var statValue = this.running[key]; - if (typeof(statValue) === 'number') { - results.push({ - name: stat, - scalar: new tr.v.ScalarNumeric(statUnit, statValue) - }); - } - } - }, this); - return results; - }, - - clone: function() { - return Numeric.fromDict(this.asDict()); - }, - - asDict: function() { - var d = { - unit: this.unit.asJSON(), - type: 'numeric', - - min: this.range.min, - max: this.range.max, - - numNans: this.numNans, - nanSourceInfos: this.nanSourceInfos, - - running: this.running.asDict(), - summaryOptions: this.summaryOptions, - - underflowBin: this.underflowBin.asDict(), - centralBins: this.centralBins.map(function(bin) { - return bin.asDict(); - }), - overflowBin: this.overflowBin.asDict() - }; - return d; - }, - - asJSON: function() { - return this.asDict(); - } - }; - - /** - * Reusable builder for tr.v.Numeric objects. - * - * The bins of the numeric are specified by adding the desired boundaries - * between bins. Initially, the builder has only a single boundary: - * - * minBinBoundary=maxBinBoundary - * | - * | - * -MAX_INT <--------|------------------------------------------> +MAX_INT - * : resulting : resulting : - * : underflow : overflow : - * : bin : bin : - * - * More boundaries can be added (in increasing order) using addBinBoundary, - * addLinearBins and addExponentialBins: - * - * minBinBoundary maxBinBoundary - * | | | | | - * | | | | | - * -MAX_INT <--------|---------|---------|-----|---------|------> +MAX_INT - * : resulting : result. : result. : : result. : resulting : - * : underflow : central : central : ... : central : overflow : - * : bin : bin 0 : bin 1 : : bin N-1 : bin : - * - * An important feature of the builder is that it's reusable, i.e. it can be - * used to build multiple numerics with the same unit and bin structure. - * - * @constructor - * @param {!tr.v.Unit} unit Unit of the resulting Numeric(s). - * @param {number} minBinBoundary The minimum boundary between bins, namely - * the underflow bin and the first central bin (or the overflow bin if - * no other boundaries are added later). - */ - function NumericBuilder(unit, minBinBoundary) { - this.unit_ = unit; - this.boundaries_ = [minBinBoundary]; - } - - NumericBuilder.prototype = { - get minBinBoundary() { - return this.boundaries_[0]; - }, - - get maxBinBoundary() { - return this.boundaries_[this.boundaries_.length - 1]; - }, - - /** - * Add a bin boundary |nextMaxBinBoundary| to the builder. - * - * This operation effectively corresponds to appending a new central bin - * with the range [this.maxBinBoundary*, nextMaxBinBoundary]. - * - * @param {number} nextMaxBinBoundary The added bin boundary (must be - * greater than |this.maxMinBoundary|). - */ - addBinBoundary: function(nextMaxBinBoundary) { - if (nextMaxBinBoundary <= this.maxBinBoundary) { - throw new Error('The added max bin boundary must be larger than ' + - 'the current max boundary'); - } - this.boundaries_.push(nextMaxBinBoundary); - - return this; - }, - - /** - * Add |binCount| linearly scaled bin boundaries up to |nextMaxBinBoundary| - * to the builder. - * - * This operation corresponds to appending |binCount| central bins of - * constant range width - * W = ((|nextMaxBinBoundary| - |this.maxBinBoundary|) / |binCount|) - * with the following ranges: - * - * [|this.maxMinBoundary|, |this.maxMinBoundary| + W] - * [|this.maxMinBoundary| + W, |this.maxMinBoundary| + 2W] - * [|this.maxMinBoundary| + 2W, |this.maxMinBoundary| + 3W] - * ... - * [|this.maxMinBoundary| + (|binCount| - 2) * W, - * |this.maxMinBoundary| + (|binCount| - 2) * W] - * [|this.maxMinBoundary| + (|binCount| - 1) * W, - * |nextMaxBinBoundary|] - * - * @param {number} nextBinBoundary The last added bin boundary (must be - * greater than |this.maxMinBoundary|). - * @param {number} binCount Number of bins to be added (must be positive). - */ - addLinearBins: function(nextMaxBinBoundary, binCount) { - if (binCount <= 0) - throw new Error('Bin count must be positive'); - - var curMaxBinBoundary = this.maxBinBoundary; - if (curMaxBinBoundary >= nextMaxBinBoundary) { - throw new Error('The last added max boundary must be greater than ' + - 'the current max boundary boundary'); - } - - var binWidth = (nextMaxBinBoundary - curMaxBinBoundary) / binCount; - for (var i = 1; i < binCount; i++) - this.addBinBoundary(curMaxBinBoundary + i * binWidth); - this.addBinBoundary(nextMaxBinBoundary); - - return this; - }, - - /** - * Add |binCount| exponentially scaled bin boundaries up to - * |nextMaxBinBoundary| to the builder. - * - * This operation corresponds to appending |binCount| central bins with - * a constant difference between the logarithms of their range min and max - * D = ((ln(|nextMaxBinBoundary|) - ln(|this.maxBinBoundary|)) / |binCount|) - * with the following ranges: - * - * [|this.maxMinBoundary|, |this.maxMinBoundary| * exp(D)] - * [|this.maxMinBoundary| * exp(D), |this.maxMinBoundary| * exp(2D)] - * [|this.maxMinBoundary| * exp(2D), |this.maxMinBoundary| * exp(3D)] - * ... - * [|this.maxMinBoundary| * exp((|binCount| - 2) * D), - * |this.maxMinBoundary| * exp((|binCount| - 2) * D)] - * [|this.maxMinBoundary| * exp((|binCount| - 1) * D), - * |nextMaxBinBoundary|] - * - * This method requires that the current max bin boundary is positive. - * - * @param {number} nextBinBoundary The last added bin boundary (must be - * greater than |this.maxMinBoundary|). - * @param {number} binCount Number of bins to be added (must be positive). - */ - addExponentialBins: function(nextMaxBinBoundary, binCount) { - if (binCount <= 0) - throw new Error('Bin count must be positive'); - - var curMaxBinBoundary = this.maxBinBoundary; - if (curMaxBinBoundary <= 0) - throw new Error('Current max bin boundary must be positive'); - if (curMaxBinBoundary >= nextMaxBinBoundary) { - throw new Error('The last added max boundary must be greater than ' + - 'the current max boundary boundary'); - } - - var binExponentWidth = - Math.log(nextMaxBinBoundary / curMaxBinBoundary) / binCount; - for (var i = 1; i < binCount; i++) { - this.addBinBoundary( - curMaxBinBoundary * Math.exp(i * binExponentWidth)); - } - this.addBinBoundary(nextMaxBinBoundary); - - return this; - }, - - /** - * Build a tr.v.Numeric from the list of bin boundaries. - * - * As explained earlier, this method can be called arbitrarily many times - * to produce arbitrarily many distinct numerics. - */ - build: function() { - var binInfo = { - underflowBin: new NumericBin(undefined, - Range.fromExplicitRange(-Number.MAX_VALUE, this.minBinBoundary)), - overflowBin: new NumericBin(undefined, - Range.fromExplicitRange(this.maxBinBoundary, Number.MAX_VALUE)), - centralBins: new Array(this.boundaries_.length - 1) - }; - for (var i = 0; i < this.boundaries_.length - 1; i++) { - binInfo.centralBins[i] = new NumericBin(undefined, - Range.fromExplicitRange( - this.boundaries_[i], this.boundaries_[i + 1])); - } - - var numeric = new Numeric( - this.unit_, - Range.fromExplicitRange(this.minBinBoundary, this.maxBinBoundary), - binInfo); - numeric.allBins.forEach(function(bin) { - bin.parentNumeric = numeric; - }); - return numeric; - } - }; - - /** - * Create a linearly scaled tr.v.NumericBuilder with |numBins| bins ranging - * from |range.min| to |range.max|. - */ - NumericBuilder.createLinear = function(unit, range, numBins) { - if (range.isEmpty) - throw new Error('Range must be non-empty'); - return new NumericBuilder(unit, range.min).addLinearBins( - range.max, numBins); - }; - - function ScalarNumeric(unit, value) { - if (!(typeof(value) == 'number')) - throw new Error('Expected value to be number'); - - NumericBase.call(this, unit); - this.value = value; - } - - ScalarNumeric.prototype = { - __proto__: NumericBase.prototype, - - asDictInto_: function(d) { - d.type = 'scalar'; - - // Infinity and NaN are left out of JSON for security reasons that do not - // apply to our use cases. - if (this.value === Infinity) - d.value = 'Infinity'; - else if (this.value === -Infinity) - d.value = '-Infinity'; - else if (isNaN(this.value)) - d.value = 'NaN'; - else - d.value = this.value; - }, - - toString: function() { - return this.unit.format(this.value); - } - }; - - ScalarNumeric.fromDict = function(d) { - // Infinity and NaN are left out of JSON for security reasons that do not - // apply to our use cases. - if (typeof(d.value) === 'string') { - if (d.value === '-Infinity') { - d.value = -Infinity; - } else if (d.value === 'Infinity') { - d.value = Infinity; - } else if (d.value === 'NaN') { - d.value = NaN; - } - } - - return new ScalarNumeric(tr.v.Unit.fromJSON(d.unit), d.value); - }; - - return { - NumericBase: NumericBase, - NumericBin: NumericBin, - Numeric: Numeric, - NumericBuilder: NumericBuilder, - ScalarNumeric: ScalarNumeric - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/numeric_test.html b/chromium/third_party/catapult/tracing/tracing/value/numeric_test.html deleted file mode 100644 index ed586ededfb..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/numeric_test.html +++ /dev/null @@ -1,420 +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/range.html"> -<link rel="import" href="/tracing/base/statistics.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 TEST_NUMERIC_BUILDER = tr.v.NumericBuilder.createLinear( - tr.v.Unit.byName.timeDurationInMs, tr.b.Range.fromExplicitRange(0, 1000), - 10); - - function checkBuilder(builder, expectedMinBoundary, expectedMaxBoundary, - expectedUnit, expectedBinRanges) { - assert.strictEqual(builder.minBinBoundary, expectedMinBoundary); - assert.strictEqual(builder.maxBinBoundary, expectedMaxBoundary); - - // Check that the builder can be used multiple times. - for (var i = 0; i < 3; i++) { - var numeric = builder.build(); - assert.instanceOf(numeric, tr.v.Numeric); - assert.strictEqual(numeric.unit, expectedUnit); - assert.strictEqual(numeric.numValues, 0); - - assert.lengthOf(numeric.allBins, expectedBinRanges.length); - for (var j = 0; j < expectedBinRanges.length; j++) { - var bin = numeric.allBins[j]; - assert.instanceOf(bin, tr.v.NumericBin); - assert.strictEqual(bin.parentNumeric, numeric); - assert.strictEqual(bin.count, 0); - assert.isTrue(bin.range.equals(expectedBinRanges[j])); - } - } - } - - test('nonUnitThrows', function() { - assert.throws(function() { new tr.v.NumericBase('foo', -273.15); }); - }); - - test('nonNumberScalarThrows', function() { - var unit = tr.v.Unit.byName.sizeInBytes; - assert.throws(function() { new tr.v.ScalarNumeric(unit, 'foo'); }); - }); - - test('numericBasic', function() { - var n = TEST_NUMERIC_BUILDER.build(); - assert.equal(n.getBinForValue(250).range.min, 200); - assert.equal(n.getBinForValue(250).range.max, 300); - n.add(-1, 'a'); - n.add(0, 'b'); - n.add(0, 'c'); - n.add(500, 'c'); - n.add(999, 'd'); - n.add(1000, 'd'); - assert.equal(n.underflowBin.count, 1); - - assert.equal(n.getBinForValue(0).count, 2); - assert.deepEqual(n.getBinForValue(0).sourceInfos, - ['b', 'c']); - - assert.equal(n.getBinForValue(500).count, 1); - assert.equal(n.getBinForValue(999).count, 1); - - assert.equal(n.overflowBin.count, 1); - assert.equal(n.numValues, 6); - assert.closeTo(n.average, 416.3, 0.1); - }); - - test('numericNans', function() { - var n = TEST_NUMERIC_BUILDER.build(); - n.add(undefined, 'b'); - n.add(NaN, 'c'); - - assert.equal(n.numNans, 2); - assert.deepEqual(n.nanSourceInfos, ['b', 'c']); - }); - - test('addNumericsValid', function() { - var n0 = TEST_NUMERIC_BUILDER.build(); - var n1 = TEST_NUMERIC_BUILDER.build(); - n0.add(-1, 'a0'); - n0.add(0, 'b0'); - n0.add(0, 'c0'); - n0.add(500, 'c0'); - n0.add(1000, 'd0'); - n0.add(NaN, 'e0'); - - n1.add(-1, 'a1'); - n1.add(0, 'b1'); - n1.add(0, 'c1'); - n1.add(999, 'd1'); - n1.add(1000, 'd1'); - n1.add(NaN, 'e1'); - - n0.addNumeric(n1); - - assert.equal(n0.numNans, 2); - assert.deepEqual(n0.nanSourceInfos, ['e0', 'e1']); - - assert.equal(n0.underflowBin.count, 2); - assert.deepEqual(n0.underflowBin.sourceInfos, ['a0', 'a1']); - - assert.equal(n0.getBinForValue(0).count, 4); - assert.deepEqual(n0.getBinForValue(0).sourceInfos, - ['b0', 'c0', 'b1', 'c1']); - - assert.equal(n0.getBinForValue(500).count, 1); - assert.deepEqual(n0.getBinForValue(500).sourceInfos, ['c0']); - - assert.equal(n0.getBinForValue(999).count, 1); - assert.deepEqual(n0.getBinForValue(999).sourceInfos, ['d1']); - - assert.equal(n0.overflowBin.count, 2); - assert.deepEqual(n0.overflowBin.sourceInfos, ['d0', 'd1']); - - assert.equal(n0.numValues, 10); - assert.closeTo(n0.average, 349.7, 0.1); - - assert.equal(2, n0.maxCount); - assert.equal(2, n1.maxCount); - }); - - test('addNumericsInvalid', function() { - var n0 = tr.v.NumericBuilder.createLinear(tr.v.Unit.byName.timeDurationInMs, - tr.b.Range.fromExplicitRange(0, 1000), 10).build(); - var n1 = tr.v.NumericBuilder.createLinear(tr.v.Unit.byName.timeDurationInMs, - tr.b.Range.fromExplicitRange(0, 1001), 10).build(); - var n2 = tr.v.NumericBuilder.createLinear(tr.v.Unit.byName.timeDurationInMs, - tr.b.Range.fromExplicitRange(0, 1000), 11).build(); - - assert.throws(n0.addNumeric.bind(n0, n1), Error); - assert.throws(n0.addNumeric.bind(n0, n1), Error); - }); - - test('getInterpolateCountAt', function() { - var n = tr.v.Numeric.fromDict({ - unit: 'unitless', - min: 0, - max: 100, - centralBinWidth: 10, - underflowBin: {min: -Number.MAX_VALUE, max: 0, count: 11}, - centralBins: [ - {min: 0, max: 10, count: 10}, - {min: 10, max: 20, count: 9}, - {min: 20, max: 30, count: 8}, - {min: 30, max: 40, count: 7}, - {min: 40, max: 50, count: 6}, - {min: 50, max: 60, count: 5}, - {min: 60, max: 70, count: 4}, - {min: 70, max: 80, count: 3}, - {min: 80, max: 90, count: 2}, - {min: 90, max: 100, count: 1} - ], - overflowBin: {min: 100, max: Number.MAX_VALUE, count: 0} - }); - - assert.equal(11, n.maxCount); - assert.equal(11, n.getInterpolatedCountAt(-1)); - assert.equal(0, n.getInterpolatedCountAt(101)); - assert.closeTo(10.8, n.getInterpolatedCountAt(1), 1e-3); - assert.closeTo(9.5, n.getInterpolatedCountAt(10), 1e-3); - assert.closeTo(0.2, n.getInterpolatedCountAt(99), 1e-3); - }); - - test('scalarBasic', function() { - var unit = tr.v.Unit.byName.sizeInBytes; - - var d = { - type: 'scalar', - unit: unit.asJSON(), - value: 42 - }; - - assert.deepEqual(d, tr.v.NumericBase.fromDict(d).asDict()); - }); - - test('numericPercentile', function() { - function check(array, min, max, bins, precision) { - var n = new tr.v.NumericBuilder.createLinear( - tr.v.Unit.byName.timeDurationInMs, - tr.b.Range.fromExplicitRange(min, max), - bins).build(); - array.forEach((x) => n.add(x, 'x')); - [0.25, 0.5, 0.75, 0.8, 0.95, 0.99].forEach(function(percent) { - var expected = tr.b.Statistics.percentile(array, percent); - var actual = n.getApproximatePercentile(percent); - assert.closeTo(expected, actual, precision); - }); - } - check([1, 2, 5, 7], 0.5, 10.5, 10, 1e-3); - check([3, 3, 4, 4], 0.5, 10.5, 10, 1e-3); - check([1, 10], 0.5, 10.5, 10, 1e-3); - check([1, 2, 3, 4, 5], 0.5, 10.5, 10, 1e-3); - check([3, 3, 3, 3, 3], 0.5, 10.5, 10, 1e-3); - check([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 0.5, 10.5, 10, 1e-3); - check([1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10], 0.5, 10.5, 10, 1e-3); - check([0, 11], 0.5, 10.5, 10, 1); - check([0, 6, 11], 0.5, 10.5, 10, 1); - var array = []; - for (var i = 0; i < 1000; i++) - array.push((i * i) % 10 + 1); - check(array, 0.5, 10.5, 10, 1e-3); - // If the real percentile is outside the bin range then the approximation - // error can be high. - check([-10000], 0, 10, 10, 10000); - check([10000], 0, 10, 10, 10000 - 10); - // The result is no more than the bin width away from the real percentile. - check([1, 1], 0, 10, 1, 10); - }); - - test('numericBuilder_empty', function() { - var b = new tr.v.NumericBuilder(tr.v.Unit.byName.sizeInBytes, 0); - - checkBuilder(b, 0, 0, tr.v.Unit.byName.sizeInBytes, [ - tr.b.Range.fromExplicitRange(-Number.MAX_VALUE, 0), - tr.b.Range.fromExplicitRange(0, Number.MAX_VALUE) - ]); - }); - - test('numericBuilder_addBinBoundary', function() { - var b = new tr.v.NumericBuilder(tr.v.Unit.byName.timeDurationInMs, -100); - b.addBinBoundary(50); - - checkBuilder(b, -100, 50, tr.v.Unit.byName.timeDurationInMs, [ - tr.b.Range.fromExplicitRange(-Number.MAX_VALUE, -100), - tr.b.Range.fromExplicitRange(-100, 50), - tr.b.Range.fromExplicitRange(50, Number.MAX_VALUE) - ]); - - b.addBinBoundary(60); - b.addBinBoundary(75); - - checkBuilder(b, -100, 75, tr.v.Unit.byName.timeDurationInMs, [ - tr.b.Range.fromExplicitRange(-Number.MAX_VALUE, -100), - tr.b.Range.fromExplicitRange(-100, 50), - tr.b.Range.fromExplicitRange(50, 60), - tr.b.Range.fromExplicitRange(60, 75), - tr.b.Range.fromExplicitRange(75, Number.MAX_VALUE) - ]); - }); - - test('numericBuilder_addLinearBins', function() { - var b = new tr.v.NumericBuilder(tr.v.Unit.byName.powerInWatts, 1000); - b.addLinearBins(1200, 5); - - checkBuilder(b, 1000, 1200, tr.v.Unit.byName.powerInWatts, [ - tr.b.Range.fromExplicitRange(-Number.MAX_VALUE, 1000), - tr.b.Range.fromExplicitRange(1000, 1040), - tr.b.Range.fromExplicitRange(1040, 1080), - tr.b.Range.fromExplicitRange(1080, 1120), - tr.b.Range.fromExplicitRange(1120, 1160), - tr.b.Range.fromExplicitRange(1160, 1200), - tr.b.Range.fromExplicitRange(1200, Number.MAX_VALUE) - ]); - }); - - test('numericBuilder_addExponentialBins', function() { - var b = new tr.v.NumericBuilder(tr.v.Unit.byName.energyInJoules, 0.5); - b.addExponentialBins(8, 4); - - checkBuilder(b, 0.5, 8, tr.v.Unit.byName.energyInJoules, [ - tr.b.Range.fromExplicitRange(-Number.MAX_VALUE, 0.5), - tr.b.Range.fromExplicitRange(0.5, 1), - tr.b.Range.fromExplicitRange(1, 2), - tr.b.Range.fromExplicitRange(2, 4), - tr.b.Range.fromExplicitRange(4, 8), - tr.b.Range.fromExplicitRange(8, Number.MAX_VALUE) - ]); - }); - - test('numericBuilder_combined', function() { - var b = new tr.v.NumericBuilder(tr.v.Unit.byName.unitlessNumber, -273.15); - b.addBinBoundary(-50); - b.addLinearBins(4, 3); - b.addExponentialBins(16, 2); - b.addLinearBins(17, 4); - b.addBinBoundary(100); - - checkBuilder(b, -273.15, 100, tr.v.Unit.byName.unitlessNumber, [ - tr.b.Range.fromExplicitRange(-Number.MAX_VALUE, -273.15), - tr.b.Range.fromExplicitRange(-273.15, -50), - tr.b.Range.fromExplicitRange(-50, -32), - tr.b.Range.fromExplicitRange(-32, -14), - tr.b.Range.fromExplicitRange(-14, 4), - tr.b.Range.fromExplicitRange(4, 8), - tr.b.Range.fromExplicitRange(8, 16), - tr.b.Range.fromExplicitRange(16, 16.25), - tr.b.Range.fromExplicitRange(16.25, 16.5), - tr.b.Range.fromExplicitRange(16.5, 16.75), - tr.b.Range.fromExplicitRange(16.75, 17), - tr.b.Range.fromExplicitRange(17, 100), - tr.b.Range.fromExplicitRange(100, Number.MAX_VALUE) - ]); - }); - - test('numericBuilder_throws', function() { - var b0 = new tr.v.NumericBuilder(tr.v.Unit.byName.timeStampInMs, -7); - assert.throws(function() { b0.addBinBoundary(-10 /* must be > -7 */); }); - assert.throws(function() { b0.addBinBoundary(-7 /* must be > -7 */); }); - assert.throws(function() { b0.addLinearBins(-10 /* must be > -7 */, 10); }); - assert.throws(function() { b0.addLinearBins(-7 /* must be > -7 */, 100); }); - assert.throws(function() { b0.addLinearBins(10, 0 /* must be > 0 */); }); - assert.throws(function() { - // Current max bin boundary (-7) must be positive. - b0.addExponentialBins(16, 4); - }); - - var b1 = new tr.v.NumericBuilder(tr.v.Unit.byName.sizeInBytes, 8); - assert.throws( - function() { b1.addExponentialBins(20, 0 /* must be > 0 */); }); - assert.throws( - function() { b1.addExponentialBins(5 /* must be > 8 */, 3); }); - assert.throws( - function() { b1.addExponentialBins(8 /* must be > 8 */, 3); }); - }); - - test('getSummarizedScalarNumericsWithNames', function() { - var n = tr.v.NumericBuilder.createLinear( - tr.v.Unit.byName.timeDurationInMs, tr.b.Range.fromExplicitRange(0, 100), - 100).build(); - - n.add(50); - n.add(60); - n.add(70); - - n.customizeSummaryOptions({ - count: true, - min: true, - max: true, - sum: true, - avg: true, - std: true, - percentile: [0.5, 1] - }); - - var results = n.getSummarizedScalarNumericsWithNames(); - var values = {}; - results.forEach(function(x) { - values[x.name] = x.scalar; - }); - - assert.strictEqual(values.count.value, 3); - assert.strictEqual(values.min.value, 50); - assert.strictEqual(values.max.value, 70); - assert.strictEqual(values.sum.value, 180); - assert.strictEqual(values.avg.value, 60); - assert.strictEqual(values.std.value, 10); - assert.closeTo(values.pct_050.value, 60, 1); - assert.closeTo(values.pct_100.value, 70, 1); - }); - - test('getSummarizedScalarNumericsWithNamesNoSummaryOptions', function() { - var n = tr.v.NumericBuilder.createLinear( - tr.v.Unit.byName.timeDurationInMs, tr.b.Range.fromExplicitRange(0, 100), - 100).build(); - - n.add(50); - n.add(60); - n.add(70); - - n.customizeSummaryOptions({ - count: false, - min: false, - max: false, - sum: false, - avg: false, - std: false, - percentile: [] - }); - - var results = n.getSummarizedScalarNumericsWithNames('abc'); - assert.strictEqual(results.length, 0); - }); - - test('getSummarizedScalarNumericsWithNamesEmptyNumericValue', function() { - var n = tr.v.NumericBuilder.createLinear( - tr.v.Unit.byName.timeDurationInMs, tr.b.Range.fromExplicitRange(0, 100), - 100).build(); - - n.customizeSummaryOptions({ - count: true, - min: true, - max: true, - sum: true, - avg: true, - std: true, - percentile: [0, 0.01, 0.1, 0.5, 0.995, 1] - }); - - var results = n.getSummarizedScalarNumericsWithNames(); - var values = {}; - results.forEach(function(x) { - values[x.name] = x.scalar; - }); - - assert.strictEqual(values.count.value, 0); - assert.strictEqual(values.min.value, Infinity); - assert.strictEqual(values.max.value, -Infinity); - assert.strictEqual(values.sum.value, 0); - assert.strictEqual(values.avg, undefined); - assert.strictEqual(values.std, undefined); - assert.strictEqual(values.pct_000.value, 0); - assert.strictEqual(values.pct_001.value, 0); - assert.strictEqual(values.pct_010.value, 0); - assert.strictEqual(values.pct_050.value, 0); - assert.strictEqual(values.pct_099_5.value, 0); - assert.strictEqual(values.pct_100.value, 0); - }); -}); - -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/time_display_mode.html b/chromium/third_party/catapult/tracing/tracing/value/time_display_mode.html deleted file mode 100644 index ae6b4df8cfe..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/time_display_mode.html +++ /dev/null @@ -1,54 +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/value/unit_scale.html"> - -<script> -'use strict'; - -/** - * @fileoverview Time currentDisplayUnit - */ -tr.exportTo('tr.v', function() { - var msDisplayMode = { - scale: 1e-3, - suffix: 'ms', - // Compares a < b with adjustments to precision errors. - roundedLess: function(a, b) { - return Math.round(a * 1000) < Math.round(b * 1000); - }, - formatSpec: { - unit: 's', - unitPrefix: tr.v.UnitScale.MetricTime.MILLI, - minimumFractionDigits: 3, - } - }; - - var nsDisplayMode = { - scale: 1e-9, - suffix: 'ns', - // Compares a < b with adjustments to precision errors. - roundedLess: function(a, b) { - return Math.round(a * 1000000) < Math.round(b * 1000000); - }, - formatSpec: { - unit: 's', - unitPrefix: tr.v.UnitScale.MetricTime.NANO, - maximumFractionDigits: 0 - } - }; - - var TimeDisplayModes = { - ns: nsDisplayMode, - ms: msDisplayMode - }; - - return { - TimeDisplayModes: TimeDisplayModes - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/array_of_numbers_span.html b/chromium/third_party/catapult/tracing/tracing/value/ui/array_of_numbers_span.html deleted file mode 100644 index 9f90e35bdb7..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/array_of_numbers_span.html +++ /dev/null @@ -1,75 +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/statistics.html"> -<script> -'use strict'; -tr.exportTo('tr.v.ui', function() { - var ArrayOfNumbersSummaryModes = { - AVERAGE_MODE: 'average-mode', - TOTAL_MODE: 'total-mode' - }; - return { - ArrayOfNumbersSummaryModes: ArrayOfNumbersSummaryModes - }; -}); -</script> -<polymer-element name="tr-v-ui-array-of-numbers-span"> - <template> - </template> - <script> - 'use strict'; - - Polymer({ - created: function() { - this.numbers_ = undefined; - this.summaryMode_ = tr.v.ui.ArrayOfNumbersSummaryModes.AVERAGE_MODE; - }, - - get summaryMode() { - return this.summaryMode_; - }, - - set summaryMode(summaryMode) { - this.summaryMode_ = summaryMode; - this.updateContents_(); - }, - - get numbers() { - return this.numbers_; - }, - - set numbers(numbers) { - if (numbers === undefined) { - this.numbers_ = undefined; - this.updateContents_(); - return; - } - if (!(numbers instanceof Array)) - throw new Error('Must provide an array'); - this.numbers_ = numbers; - this.updateContents_(); - }, - - updateContents_: function() { - if (this.numbers_ === undefined) { - this.shadowRoot.textContent = '-'; - return; - } - - var ArrayOfNumbersSummaryModes = tr.v.ui.ArrayOfNumbersSummaryModes; - var value; - if (this.summaryMode_ === ArrayOfNumbersSummaryModes.AVERAGE_MODE) - value = tr.b.Statistics.mean(this.numbers_); - else - value = tr.b.Statistics.sum(this.numbers_); - - var valueRounded = Math.round(value * 1000.0) / 1000.0; - this.shadowRoot.textContent = valueRounded; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/array_of_numbers_span_test.html b/chromium/third_party/catapult/tracing/tracing/value/ui/array_of_numbers_span_test.html deleted file mode 100644 index 9847276b8d7..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/array_of_numbers_span_test.html +++ /dev/null @@ -1,28 +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/value/ui/array_of_numbers_span.html"> -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiateInAverageMode', function() { - var span = document.createElement('tr-v-ui-array-of-numbers-span'); - span.numbers = [1, 2, 3]; - span.summaryMode = tr.v.ui.ArrayOfNumbersSummaryModes.AVERAGE_MODE; - this.addHTMLOutput(span); - assert.equal(span.shadowRoot.textContent, '2'); - }); - - test('instantiateInTotalsMode', function() { - var span = document.createElement('tr-v-ui-array-of-numbers-span'); - span.numbers = [1, 2, 3]; - span.summaryMode = tr.v.ui.ArrayOfNumbersSummaryModes.TOTALS_MODE; - this.addHTMLOutput(span); - assert.equal(span.shadowRoot.textContent, '6'); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/diagnostic_map_table.html b/chromium/third_party/catapult/tracing/tracing/value/ui/diagnostic_map_table.html deleted file mode 100644 index 107849c0b01..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/diagnostic_map_table.html +++ /dev/null @@ -1,90 +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/ui/base/table.html"> -<link rel="import" href="/tracing/value/ui/diagnostic_span.html"> - -<polymer-element name="tr-v-ui-diagnostic-map-table"> - <template> - <tr-ui-b-table id="table"></tr-ui-b-table> - </template> - <script> - 'use strict'; - - Polymer({ - ready: function() { - this.titledDiagnosticMaps_ = undefined; - }, - - /** - * The |title| will be used as the heading for the column containing - * diagnostic-spans for |diagnosticMap|'s Diagnostics. - * - * @param {!Array.<!Object>} maps - * @param {!string} maps[].title - * @param {!tr.v.d.DiagnosticMap} maps[].diagnosticMap - */ - set titledDiagnosticMaps(maps) { - this.titledDiagnosticMaps_ = maps; - this.updateContent_(); - }, - - updateContent_: function() { - if (this.titledDiagnosticMaps_ === undefined || - this.titledDiagnosticMaps_.length === 0) { - this.$.table.tableRows = []; - this.$.table.tableColumns = []; - return; - } - - var columns = [{ - title: 'Name', - - value: function(row) { - return row.name; - }, - - cmp: function(a, b) { - return a.name.localeCompare(b.name); - } - }]; - - var rowNames = {}; - var rows = []; - - this.titledDiagnosticMaps_.forEach(function(titledMap) { - var title = titledMap.title; - var diagnosticMap = titledMap.diagnosticMap; - - columns.push({ - title: title, - - value: function(row) { - var diagnostic = diagnosticMap.get(row.name); - if (diagnostic === undefined) - return ''; - - return tr.v.ui.createDiagnosticSpan(diagnostic); - } - }); - - diagnosticMap.forEach(function(name, diagnostic) { - if (rowNames[name] !== true) { - rowNames[name] = true; - rows.push({name: name}); - } - }); - }, this); - - rows.sort(columns[0].cmp); - this.$.table.tableColumns = columns; - this.$.table.tableRows = rows; - this.$.table.rebuild(); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/diagnostic_map_table_test.html b/chromium/third_party/catapult/tracing/tracing/value/ui/diagnostic_map_table_test.html deleted file mode 100644 index 31eafe23413..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/diagnostic_map_table_test.html +++ /dev/null @@ -1,30 +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/value/diagnostics/diagnostic_map.html"> -<link rel="import" href="/tracing/value/ui/diagnostic_map_table.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiate', function() { - var map0 = new tr.v.d.DiagnosticMap(); - map0.add('genericA', new tr.v.d.Generic({a: 0})); - map0.add('genericB', new tr.v.d.Generic({b: 0})); - var map1 = new tr.v.d.DiagnosticMap(); - map1.add('genericA', new tr.v.d.Generic({a: 1})); - map1.add('genericB', new tr.v.d.Generic({b: 1})); - var table = document.createElement('tr-v-ui-diagnostic-map-table'); - table.titledDiagnosticMaps = [ - {title: 'map0', diagnosticMap: map0}, - {title: 'map1', diagnosticMap: map1}, - ]; - this.addHTMLOutput(table); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/diagnostic_span.html b/chromium/third_party/catapult/tracing/tracing/value/ui/diagnostic_span.html deleted file mode 100644 index 23940f0c0dd..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/diagnostic_span.html +++ /dev/null @@ -1,69 +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/ui/base/deep_utils.html"> -<link rel="import" href="/tracing/ui/base/polymer_utils.html"> -<link rel="import" href="/tracing/value/diagnostics/diagnostic.html"> -<link rel="import" href="/tracing/value/ui/generic_diagnostic_span.html"> -<link rel="import" href="/tracing/value/ui/iteration_info_span.html"> -<link rel="import" href="/tracing/value/ui/related_event_set_span.html"> -<link rel="import" href="/tracing/value/ui/related_value_map_span.html"> -<link rel="import" href="/tracing/value/ui/related_value_set_span.html"> - -<script> -'use strict'; -tr.exportTo('tr.v.ui', function() { - /** - * Find the name of a polymer element registered to display |diagnostic| - * or one of its base classes. - * - * @param {!tr.v.d.Diagnostic} diagnostic - * @return {string} - */ - function findElementNameForDiagnostic(diagnostic) { - var typeInfo = undefined; - var curProto = diagnostic.constructor.prototype; - while (curProto) { - typeInfo = tr.v.d.Diagnostic.findTypeInfo(curProto.constructor); - if (typeInfo && typeInfo.metadata.elementName) - break; - typeInfo = undefined; - curProto = curProto.__proto__; - } - - if (typeInfo === undefined) { - throw new Error( - diagnostic.constructor.name + - ' or a base class must have a registered elementName'); - } - - var tagName = typeInfo.metadata.elementName; - - if (!tr.ui.b.getPolymerElementNamed(tagName)) - throw new Error('Element not registered: ' + tagName); - - return tagName; - } - - /** - * Create a visualization for |diagnostic|. - * - * @param {!tr.v.d.Diagnostic} diagnostic - * @return {Element} - */ - function createDiagnosticSpan(diagnostic) { - var tagName = findElementNameForDiagnostic(diagnostic); - var span = document.createElement(tagName); - span.diagnostic = diagnostic; - return span; - } - - return { - createDiagnosticSpan: createDiagnosticSpan - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/generic_diagnostic_span.html b/chromium/third_party/catapult/tracing/tracing/value/ui/generic_diagnostic_span.html deleted file mode 100644 index 502cf020362..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/generic_diagnostic_span.html +++ /dev/null @@ -1,41 +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/ui/analysis/generic_object_view.html"> - -<polymer-element name="tr-v-ui-generic-diagnostic-span"> - <template> - <tr-ui-a-generic-object-view id="generic"></tr-ui-a-generic-object-view> - </template> - - <script> - 'use strict'; - Polymer({ - ready: function() { - this.diagnostic_ = undefined; - }, - - get diagnostic() { - return this.diagnostic_; - }, - - set diagnostic(d) { - this.diagnostic_ = d; - this.updateContents_(); - }, - - updateContents_: function() { - if (this.diagnostic === undefined) { - this.$.generic.object = undefined; - return; - } - - this.$.generic.object = this.diagnostic.value; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/generic_diagnostic_span_test.html b/chromium/third_party/catapult/tracing/tracing/value/ui/generic_diagnostic_span_test.html deleted file mode 100644 index d6b8727381f..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/generic_diagnostic_span_test.html +++ /dev/null @@ -1,22 +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/value/diagnostics/generic.html"> -<link rel="import" href="/tracing/value/ui/diagnostic_span.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiate', function() { - var diagnostic = new tr.v.d.Generic({foo: 'bar', baz: [42]}); - var span = tr.v.ui.createDiagnosticSpan(diagnostic); - assert.strictEqual('TR-V-UI-GENERIC-DIAGNOSTIC-SPAN', span.tagName); - this.addHTMLOutput(span); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/generic_table_view.html b/chromium/third_party/catapult/tracing/tracing/value/ui/generic_table_view.html deleted file mode 100644 index f9becaee0e4..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/generic_table_view.html +++ /dev/null @@ -1,299 +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/base/statistics.html"> -<link rel="import" href="/tracing/ui/analysis/generic_object_view.html"> -<link rel="import" href="/tracing/ui/base/table.html"> -<link rel="import" href="/tracing/value/generic_table.html"> -<link rel="import" href="/tracing/value/ui/array_of_numbers_span.html"> - -<polymer-element name="tr-v-ui-generic-table-view"> - <template> - <style> - :host { - display: flex; - } - #table { - flex: 1 1 auto; - align-self: stretch; - } - </style> - <tr-ui-b-table id="table"></tr-ui-b-table> - </template> -</polymer-element> - -<script> -'use strict'; - -tr.exportTo('tr.v.ui', function() { - var TEXT_COLUMN_MODE = 1; - var NUMERIC_COLUMN_MODE = 2; - var ELEMENT_COLUMN_MODE = 3; - - function isNumeric(value) { - // TODO(nduca): Also consider other units that are numeric. - if ((typeof value) === 'number') - return true; - else if (value instanceof Number) - return true; - return false; - } - - function GenericTableViewTotalsItem(opt_values) { - if (opt_values !== undefined) - this.values = opt_values; - else - this.values = []; - } - - function GenericTableViewColumnDescriptor(fieldName, firstFieldValue) { - this.title = fieldName; - this.fieldName = fieldName; - - this.updateModeGivenValue(firstFieldValue); - } - - GenericTableViewColumnDescriptor.prototype = { - get columnMode() { - return this.columnMode_; - }, - - get isInNumericMode() { - return this.columnMode_ === NUMERIC_COLUMN_MODE; - }, - - cmp: function(a, b) { - if (this.columnMode_ === ELEMENT_COLUMN_MODE) - return 0; - - return tr.b.comparePossiblyUndefinedValues(a, b, function(a, b) { - var vA = a[this.fieldName]; - var vB = b[this.fieldName]; - return tr.b.comparePossiblyUndefinedValues(vA, vB, function(vA, vB) { - if (vA.localeCompare) - return vA.localeCompare(vB); - return vA - vB; - }, this); - }, this); - }, - - updateModeGivenValue: function(fieldValue) { - if (this.columnMode_ === undefined) { - if (fieldValue === undefined || fieldValue === null) - return; - - if (isNumeric(fieldValue)) { - this.columnMode_ = NUMERIC_COLUMN_MODE; - return; - } - - if (fieldValue instanceof HTMLElement) { - this.columnMode_ = ELEMENT_COLUMN_MODE; - return; - } - - this.columnMode_ = TEXT_COLUMN_MODE; - return; - } - - // Undefineds & nulls shouldn't change the mode. - if (fieldValue === undefined || fieldValue === null) - return; - - // If we were already in numeric mode, then we don't - // need to put it into numeric mode again. And, if we were - // previously in text mode, then we can't go into numeric mode now. - if (isNumeric(fieldValue)) - return; - - if (fieldValue instanceof HTMLElement) { - this.columnMode_ = ELEMENT_COLUMN_MODE; - return; - } - - if (this.columnMode_ === NUMERIC_COLUMN_MODE) - this.columnMode_ = TEXT_COLUMN_MODE; - }, - - value: function(item) { - var fieldValue = item[this.fieldName]; - if (fieldValue instanceof GenericTableViewTotalsItem) { - var span = document.createElement('tr-v-ui-array-of-numbers-span'); - span.summaryMode = tr.v.ui.ArrayOfNumbersSummaryModes.TOTAL_MODE; - span.numbers = fieldValue.values; - return span; - } - - if (fieldValue === undefined) - return '-'; - - if (fieldValue instanceof HTMLElement) - return fieldValue; - - if (fieldValue instanceof Object) { - var gov = document.createElement('tr-ui-a-generic-object-view'); - gov.object = fieldValue; - return gov; - } - - // TODO(nduca): Use units objects if applicable. - return fieldValue; - } - }; - - Polymer('tr-v-ui-generic-table-view', { - created: function() { - this.items_ = undefined; - this.importantColumNames_ = []; - }, - - get items() { - return this.items_; - }, - - set items(itemsOrGenericTable) { - if (itemsOrGenericTable === undefined) { - this.items_ = undefined; - } else if (itemsOrGenericTable instanceof Array) { - this.items_ = itemsOrGenericTable; - } else if (itemsOrGenericTable instanceof tr.v.GenericTable) { - this.items_ = itemsOrGenericTable.items; - } - this.updateContents_(); - }, - - get importantColumNames() { - return this.importantColumNames_; - }, - - set importantColumNames(importantColumNames) { - this.importantColumNames_ = importantColumNames; - this.updateContents_(); - }, - - createColumns_: function() { - var columnsByName = {}; - this.items_.forEach(function(item) { - tr.b.iterItems(item, function(itemFieldName, itemFieldValue) { - var colDesc = columnsByName[itemFieldName]; - if (colDesc !== undefined) { - colDesc.updateModeGivenValue(itemFieldValue); - return; - } - - colDesc = new GenericTableViewColumnDescriptor( - itemFieldName, itemFieldValue); - columnsByName[itemFieldName] = colDesc; - }, this); - }, this); - - var columns = tr.b.dictionaryValues(columnsByName); - if (columns.length === 0) - return undefined; - - // Sort by name. - var isColumnNameImportant = {}; - var importantColumNames = this.importantColumNames || []; - importantColumNames.forEach(function(icn) { - isColumnNameImportant[icn] = true; - }); - columns.sort(function(a, b) { - var iA = isColumnNameImportant[a.title] ? 1 : 0; - var iB = isColumnNameImportant[b.title] ? 1 : 0; - if ((iB - iA) !== 0) - return iB - iA; - return a.title.localeCompare(b.title); - }); - - // Set sizes. This is convoluted by the fact that the first - // table column must have fixed size. - var colWidthPercentage; - if (columns.length == 1) - colWidthPercentage = '100%'; - else - colWidthPercentage = (100 / (columns.length - 1)).toFixed(3) + '%'; - columns[0].width = '250px'; - for (var i = 1; i < columns.length; i++) - columns[i].width = colWidthPercentage; - - return columns; - }, - - createFooterRowsIfNeeded_: function(columns) { - // Make totals row if needed. - var hasColumnThatIsNumeric = columns.some(function(column) { - return column.isInNumericMode; - }); - if (!hasColumnThatIsNumeric) - return []; - - var totalsItems = {}; - columns.forEach(function(column) { - if (!column.isInNumericMode) - return; - var totalsItem = new GenericTableViewTotalsItem(); - this.items_.forEach(function(item) { - var fieldValue = item[column.fieldName]; - if (fieldValue === undefined || fieldValue === null) - return; - totalsItem.values.push(fieldValue); - }); - totalsItems[column.fieldName] = totalsItem; - }, this); - - return [totalsItems]; - }, - - updateContents_: function() { - var columns; - if (this.items_ !== undefined) - columns = this.createColumns_(); - - if (!columns) { - this.$.table.tableColumns = []; - this.$.table.tableRows = []; - this.$.table.footerRows = []; - return; - } - - this.$.table.tableColumns = columns; - this.$.table.tableRows = this.items_; - this.$.table.footerRows = this.createFooterRowsIfNeeded_(columns); - this.$.table.rebuild(); - }, - - get selectionMode() { - return this.$.table.selectionMode; - }, - - set selectionMode(selectionMode) { - this.$.table.selectionMode = selectionMode; - }, - - get rowHighlightStyle() { - return this.$.table.rowHighlightStyle; - }, - - set rowHighlightStyle(rowHighlightStyle) { - this.$.table.rowHighlightStyle = rowHighlightStyle; - }, - - get cellHighlightStyle() { - return this.$.table.cellHighlightStyle; - }, - - set cellHighlightStyle(cellHighlightStyle) { - this.$.table.cellHighlightStyle = cellHighlightStyle; - } - }); - - return { - GenericTableViewTotalsItem: GenericTableViewTotalsItem, - GenericTableViewColumnDescriptor: GenericTableViewColumnDescriptor - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/generic_table_view_test.html b/chromium/third_party/catapult/tracing/tracing/value/ui/generic_table_view_test.html deleted file mode 100644 index 85bfe45f2c7..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/generic_table_view_test.html +++ /dev/null @@ -1,199 +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/value/generic_table.html"> -<link rel="import" href="/tracing/value/ui/generic_table_view.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var GenericTableViewColumnDescriptor = - tr.v.ui.GenericTableViewColumnDescriptor; - var GenericTableViewTotalsItem = tr.v.ui.GenericTableViewTotalsItem; - - test('descBasicNumericMode', function() { - var colDesc = new GenericTableViewColumnDescriptor('a'); - assert.isFalse(colDesc.isInNumericMode); - - colDesc.updateModeGivenValue(4); - assert.isTrue(colDesc.isInNumericMode); - - colDesc.updateModeGivenValue(4); - assert.isTrue(colDesc.isInNumericMode); - - colDesc.updateModeGivenValue(undefined); - colDesc.updateModeGivenValue(null); - assert.isTrue(colDesc.isInNumericMode); - - colDesc.updateModeGivenValue('a'); - assert.isFalse(colDesc.isInNumericMode); - }); - - test('descBasicNonNumericMode', function() { - var colDesc = new GenericTableViewColumnDescriptor('a'); - assert.isFalse(colDesc.isInNumericMode); - colDesc.updateModeGivenValue(4); - assert.isTrue(colDesc.isInNumericMode); - colDesc.updateModeGivenValue('a'); - assert.isFalse(colDesc.isInNumericMode); - }); - - test('descCmpWithNumbers', function() { - var colDesc = new GenericTableViewColumnDescriptor('a', 1); - assert.equal(colDesc.cmp({a: 1}, {a: 2}), -1); - assert.equal(colDesc.cmp({a: 1}, undefined), -1); - }); - - test('descCmpWithText', function() { - var colDesc = new GenericTableViewColumnDescriptor('a', 'text'); - assert.equal(colDesc.cmp({a: 'a'}, {a: 'b'}), -1); - assert.equal(colDesc.cmp({a: 'a'}, undefined), -1); - }); - - test('descValue', function() { - var colDesc = new GenericTableViewColumnDescriptor('a', 1); - var value = colDesc.value({a: undefined}); - assert.equal(value, '-'); - - value = colDesc.value({a: 3}); - assert.equal(value, 3); - - var totalsValue = colDesc.value( - {a: new GenericTableViewTotalsItem([1, 2, 3])}); - assert.equal(totalsValue.tagName.toLowerCase(), - 'tr-v-ui-array-of-numbers-span'); - assert.deepEqual(totalsValue.numbers, [1, 2, 3]); - }); - - test('everythingTogether', function() { - var table = document.createElement('tr-v-ui-generic-table-view'); - table.items = [ - { - a: 'someString', - b: 2, - c: 'adsf' - }, - { - a: 'someOtherString', - b: 2, - c: 'adsf' - } - ]; - this.addHTMLOutput(table); - }); - - test('summableColumn', function() { - var table = document.createElement('tr-v-ui-generic-table-view'); - table.items = [ - { - a: 1 - }, - { - a: 2 - }, - { - a: 3 - } - ]; - this.addHTMLOutput(table); - - assert.equal(table.$.table.tableColumns.length, 1); - assert.equal(table.$.table.tableRows.length, 3); - assert.isTrue(table.$.table.tableColumns[0].isInNumericMode); - assert.equal(table.$.table.tableColumns[0].fieldName, 'a'); - var totalsItem = table.$.table.footerRows[0].a; - assert.deepEqual(totalsItem.values, [1, 2, 3]); - }); - - - test('usingGenericTable', function() { - var table = document.createElement('tr-v-ui-generic-table-view'); - table.items = new tr.v.GenericTable([ - { - a: 1 - } - ]); - assert.equal(table.items.length, 1); - }); - - test('valueIsObject', function() { - var table = document.createElement('tr-v-ui-generic-table-view'); - table.items = new tr.v.GenericTable([ - { - a: {x: 1, y: 'string'} - }, - { - a: 'something' - } - ]); - this.addHTMLOutput(table); - assert.equal(table.items.length, 2); - }); - - test('mixedTypeTable', function() { - var table = document.createElement('tr-v-ui-generic-table-view'); - table.items = [ - { - a: 1 - }, - { - a: 2 - }, - { - b: 'c' - } - ]; - this.addHTMLOutput(table); - }); - - test('tableWithElement', function() { - var table = document.createElement('tr-v-ui-generic-table-view'); - table.items = [ - { - a: 1 - }, - { - a: tr.ui.b.createSpan({textContent: 'ohai'}) - }, - { - b: 'c' - } - ]; - this.addHTMLOutput(table); - }); - - - test('emptyTable', function() { - var table = document.createElement('tr-v-ui-generic-table-view'); - table.items = [{}]; - assert.equal(table.$.table.tableColumns.length, 0); - }); - - test('undefinedAndValue', function() { - var table = document.createElement('tr-v-ui-generic-table-view'); - table.items = [ - { - }, - { - a: 2 - } - ]; - this.addHTMLOutput(table); - }); - - test('undefinedOnly', function() { - var table = document.createElement('tr-v-ui-generic-table-view'); - table.items = [ - { - a: undefined - } - ]; - this.addHTMLOutput(table); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/histogram_span.html b/chromium/third_party/catapult/tracing/tracing/value/ui/histogram_span.html deleted file mode 100644 index 2bc489865c7..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/histogram_span.html +++ /dev/null @@ -1,192 +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/statistics.html"> -<link rel="import" href="/tracing/ui/base/bar_chart.html"> -<link rel="import" href="/tracing/value/ui/scalar_span.html"> - -<polymer-element name="tr-v-ui-histogram-span"> - <template> - <style> - :host { - display: flex; - flex-direction: column; - } - - #stats { - display: flex; - flex-direction: row; - flex: 0 0 auto; - font-weight: bold; - } - - #nnans { - color: red; - } - #table { - flex: 1 1 auto; - } - </style> - <div id="stats"> - <span id="nsamples"></span> samples, - <span id="hadnans"><span id="nnans"></span> non-numeric samples, - </span> - average=<tr-v-ui-scalar-span id="average"></tr-v-ui-scalar-span> - </div> - <div id="container"></div> - </template> - <script> - 'use strict'; - - Polymer({ - created: function() { - this.histogram_ = undefined; - this.chart_ = new tr.ui.b.BarChart(); - this.chart_.width = 400; - this.chart_.height = 200; - this.mouseDownBin_ = undefined; - this.brushedBins_ = []; - this.chart_.addEventListener('item-mousedown', - this.onMouseDown_.bind(this)); - this.chart_.addEventListener('item-mousemove', - this.onMouseMove_.bind(this)); - this.chart_.addEventListener('item-mouseup', - this.onMouseUp_.bind(this)); - }, - - ready: function() { - this.$.container.appendChild(this.chart_); - }, - - get brushedBins() { - return this.brushedBins_; - }, - - updateBrushedRange_: function(currentX) { - this.brushedBins_ = [this.histogram_.getBinForValue(currentX)]; - var r = new tr.b.Range(); - r.addValue(this.mouseDownX_); - r.addValue(currentX); - - // Collect bins: - var centralMin = Number.MAX_VALUE; - var centralMax = -Number.MAX_VALUE; - this.histogram_.centralBins.forEach(function(bin) { - centralMin = Math.min(centralMin, bin.range.min); - centralMax = Math.max(centralMax, bin.range.max); - if ((bin.range.max > r.min) && - (bin.range.min < r.max) && - (this.brushedBins_.indexOf(bin) < 0)) - this.brushedBins_.push(bin); - }, this); - if ((this.histogram_.underflowBin.max > r.min) && - (this.brushedBins_.indexOf(this.histogram_.underflowBin) < 0)) { - this.brushedBins_.push(this.histogram_.underflowBin); - } - if ((this.histogram_.overflowBin.min < r.max) && - (this.brushedBins_.indexOf(this.histogram_.overflowBin) < 0)) { - this.brushedBins_.push(this.histogram_.overflowBin); - } - this.brushedBins_.sort(function(a, b) { - return a.range.min - b.range.min; - }); - - // Prevent Infinity: - var minBin = this.histogram_.getBinForValue(r.min); - var maxBin = this.histogram_.getBinForValue(r.max); - var binWidth = this.histogram_.centralBins[0].range.range; - r.min = minBin ? Math.max(centralMin - binWidth, minBin.range.min) : - centralMin - binWidth; - r.max = maxBin ? Math.min(centralMax + binWidth, maxBin.range.max) : - centralMax + binWidth; - - this.chart_.brushedRange = r; - - this.dispatchEvent(new tr.b.Event('brushed-bins-changed')); - }, - - onMouseDown_: function(chartEvent) { - chartEvent.stopPropagation(); - if (!this.histogram_) - return; - this.mouseDownX_ = chartEvent.x; - this.updateBrushedRange_(chartEvent.x); - }, - - onMouseMove_: function(chartEvent) { - chartEvent.stopPropagation(); - if (!this.histogram_) - return; - this.updateBrushedRange_(chartEvent.x); - }, - - onMouseUp_: function(chartEvent) { - chartEvent.stopPropagation(); - if (!this.histogram_) - return; - this.updateBrushedRange_(chartEvent.x); - this.mouseDownX_ = undefined; - }, - - get histogram() { - return this.histogram_; - }, - - set histogram(histogram) { - this.histogram_ = histogram; - this.updateContents_(); - }, - - set isYLogScale(logScale) { - this.chart_.isYLogScale = logScale; - }, - - updateContents_: function() { - this.$.container.style.display = this.histogram_ ? '' : 'none'; - if (!this.histogram_) { - this.$.nsamples.textContent = 0; - this.$.average.setValueAndUnit(undefined, undefined); - return; - } - - this.$.nsamples.textContent = this.histogram_.numValues; - this.$.average.setValueAndUnit(this.histogram_.average, - this.histogram_.unit); - if (this.histogram_.numNans > 0) { - this.$.hadnans.style.display = ''; - this.$.nnans.textContent = this.histogram_.numNans; - } else { - this.$.hadnans.style.display = 'none'; - } - - var maximumBinValue = tr.b.Statistics.max(this.histogram_.allBins, - function(bin) { - return bin.count; - }); - var chartData = []; - var binWidth = this.histogram_.centralBins[0].range.range; - this.histogram_.allBins.forEach(function(bin) { - var x = bin.range.min; - if (x === -Number.MAX_VALUE) { - if (!bin.count) - return; - x = bin.range.max - binWidth; - } - chartData.push({x: x, - y: bin.count}); - }); - chartData.sort(function(x, y) { - return x.x - y.x; - }); - this.$.container.style.display = chartData.length ? '' : 'none'; - this.chart_.data = chartData; - this.brushedBins_ = []; - this.chart_.brushedRange = new tr.b.Range(); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/histogram_span_test.html b/chromium/third_party/catapult/tracing/tracing/value/ui/histogram_span_test.html deleted file mode 100644 index ad550b714f9..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/histogram_span_test.html +++ /dev/null @@ -1,64 +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/value/histogram.html"> -<link rel="import" href="/tracing/value/ui/histogram_span.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var DURATION_NUMERIC_BUILDER = tr.v.NumericBuilder.createLinear( - tr.v.Unit.byName.timeDurationInMs, tr.b.Range.fromExplicitRange(0, 1000), - 10); - - test('basic', function() { - var h = DURATION_NUMERIC_BUILDER.build(); - h.add(-1, 'a'); - h.add(0, 'b'); - h.add(0, 'b'); - h.add(0, 'b'); - h.add(0, 'b'); - h.add(0, 'b'); - h.add(0, 'b'); - h.add(0, 'c'); - h.add(500, 'c'); - h.add(999, 'd'); - h.add(1000, 'd'); - - var span = document.createElement('tr-v-ui-histogram-span'); - span.histogram = h; - this.addHTMLOutput(span); - }); - - test('undefined', function() { - var span = document.createElement('tr-v-ui-histogram-span'); - span.histogram = undefined; - this.addHTMLOutput(span); - }); - - test('emptyHistogram', function() { - var h = DURATION_NUMERIC_BUILDER.build(); - - var span = document.createElement('tr-v-ui-histogram-span'); - span.histogram = h; - this.addHTMLOutput(span); - }); - - test('nans', function() { - var h = DURATION_NUMERIC_BUILDER.build(); - h.add(undefined, 'b'); - h.add(NaN, 'c'); - - var span = document.createElement('tr-v-ui-histogram-span'); - span.histogram = h; - this.addHTMLOutput(span); - }); - -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/iteration_info_span.html b/chromium/third_party/catapult/tracing/tracing/value/ui/iteration_info_span.html deleted file mode 100644 index c8799005dc2..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/iteration_info_span.html +++ /dev/null @@ -1,73 +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/ui/base/table.html"> - -<polymer-element name="tr-v-ui-iteration-info-span"> - <template> - <tr-ui-b-table id="table"></tr-ui-b-table> - </template> - - <script> - 'use strict'; - Polymer({ - ready: function() { - this.diagnostic_ = undefined; - this.$.table.showHeader = false; - this.$.table.tableColumns = [ - { - value: function(row) { - return row[0]; - }, - }, - { - value: function(row) { - return row[1]; - } - } - ]; - }, - - get diagnostic() { - return this.diagnostic_; - }, - - set diagnostic(d) { - this.diagnostic_ = d; - this.updateContents_(); - }, - - updateContents_: function() { - if (this.diagnostic === undefined) { - this.$.table.tableRows = []; - return; - } - - var rows = [ - ['benchmark name', this.diagnostic.benchmarkName], - ['benchmark start', this.diagnostic.benchmarkStart], - ['url', this.diagnostic.storyUrl], - ['story', this.diagnostic.storyDisplayName], - ['storyset repeat', this.diagnostic.storysetRepeatCounter], - ['story repeat', this.diagnostic.storyRepeatCounter], - ]; - - if (this.diagnostic.label) - rows.push(['label', this.diagnostic.label]); - - if (Object.keys(this.diagnostic.storyGroupingKeys).length > 0) { - var gov = document.createElement('tr-ui-a-generic-object-view'); - gov.object = this.diagnostic.storyGroupingKeys; - rows.push(['grouping keys', gov]); - } - - rows.sort((x, y) => x[0].localeCompare(y[0])); - this.$.table.tableRows = rows; - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/preferred_display_unit.html b/chromium/third_party/catapult/tracing/tracing/value/ui/preferred_display_unit.html deleted file mode 100644 index 7e5a94efad1..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/preferred_display_unit.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/value/unit.html"> - -<polymer-element name="tr-v-ui-preferred-display-unit"> - <script> - 'use strict'; - Polymer({ - ready: function() { - this.preferredTimeDisplayMode_ = undefined; - }, - - attached: function() { - tr.v.Unit.didPreferredTimeDisplayUnitChange(); - }, - - detached: function() { - tr.v.Unit.didPreferredTimeDisplayUnitChange(); - }, - - // null means no-preference - get preferredTimeDisplayMode() { - return this.preferredTimeDisplayMode_; - }, - - set preferredTimeDisplayMode(v) { - if (this.preferredTimeDisplayMode_ === v) - return; - this.preferredTimeDisplayMode_ = v; - tr.v.Unit.didPreferredTimeDisplayUnitChange(); - } - - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/preferred_display_unit_test.html b/chromium/third_party/catapult/tracing/tracing/value/ui/preferred_display_unit_test.html deleted file mode 100644 index 742783fc17a..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/preferred_display_unit_test.html +++ /dev/null @@ -1,22 +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/value/time_display_mode.html"> -<link rel="import" href="/tracing/value/ui/preferred_display_unit.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiate', function() { - var unit = document.createElement('tr-v-ui-preferred-display-unit'); - var ms = tr.v.TimeDisplayModes.ms; - unit.preferredDisplayUnit = ms; - assert.equal(unit.preferredDisplayUnit, ms); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/related_event_set_span.html b/chromium/third_party/catapult/tracing/tracing/value/ui/related_event_set_span.html deleted file mode 100644 index 349547f3b85..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/related_event_set_span.html +++ /dev/null @@ -1,37 +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/ui/analysis/analysis_link.html"> - -<polymer-element name="tr-v-ui-related-event-set-span"> - <script> - 'use strict'; - Polymer({ - ready: function() { - this.diagnostic_ = undefined; - }, - - get diagnostic() { - return this.diagnostic_; - }, - - set diagnostic(d) { - this.diagnostic_ = d; - this.updateContents_(); - }, - - updateContents_: function() { - this.textContent = ''; - var events = this.diagnostic.events; - var link = document.createElement('tr-ui-a-analysis-link'); - var label = (events.length === 1) ? 'event' : 'events'; - link.setSelectionAndContent(events, events.length + ' ' + label); - this.appendChild(link); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/related_event_set_span_test.html b/chromium/third_party/catapult/tracing/tracing/value/ui/related_event_set_span_test.html deleted file mode 100644 index 97adc4d708c..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/related_event_set_span_test.html +++ /dev/null @@ -1,57 +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/value/diagnostics/related_event_set.html"> -<link rel="import" href="/tracing/value/ui/diagnostic_span.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiate_RelatedEventSet0', function() { - var diagnostic = new tr.v.d.RelatedEventSet(); - var span = tr.v.ui.createDiagnosticSpan(diagnostic); - assert.strictEqual('TR-V-UI-RELATED-EVENT-SET-SPAN', span.tagName); - this.addHTMLOutput(span); - assert.strictEqual('0 events', span.textContent); - }); - - test('instantiate_RelatedEventSet1', function() { - var diagnostic = new tr.v.d.RelatedEventSet(); - tr.c.TestUtils.newModel(function(model) { - var proc = model.getOrCreateProcess(1); - var thread = proc.getOrCreateThread(2); - var event = tr.c.TestUtils.newSliceEx({start: 0, duration: 1}); - thread.sliceGroup.pushSlice(event); - diagnostic.push(event); - }); - var span = tr.v.ui.createDiagnosticSpan(diagnostic); - assert.strictEqual('TR-V-UI-RELATED-EVENT-SET-SPAN', span.tagName); - this.addHTMLOutput(span); - assert.strictEqual('1 event', span.textContent); - }); - - test('instantiate_RelatedEventSet2', function() { - var diagnostic = new tr.v.d.RelatedEventSet(); - tr.c.TestUtils.newModel(function(model) { - var proc = model.getOrCreateProcess(1); - var thread = proc.getOrCreateThread(2); - var event = tr.c.TestUtils.newSliceEx({start: 0, duration: 1}); - thread.sliceGroup.pushSlice(event); - diagnostic.push(event); - event = tr.c.TestUtils.newSliceEx({start: 1, duration: 1}); - thread.sliceGroup.pushSlice(event); - diagnostic.push(event); - }); - var span = tr.v.ui.createDiagnosticSpan(diagnostic); - assert.strictEqual('TR-V-UI-RELATED-EVENT-SET-SPAN', span.tagName); - this.addHTMLOutput(span); - assert.strictEqual('2 events', span.textContent); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/related_value_map_span.html b/chromium/third_party/catapult/tracing/tracing/value/ui/related_value_map_span.html deleted file mode 100644 index c691c128c07..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/related_value_map_span.html +++ /dev/null @@ -1,38 +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/ui/analysis/analysis_link.html"> - -<polymer-element name="tr-v-ui-related-value-map-span"> - <script> - 'use strict'; - Polymer({ - ready: function() { - this.diagnostic_ = undefined; - }, - - get diagnostic() { - return this.diagnostic_; - }, - - set diagnostic(d) { - this.diagnostic_ = d; - this.updateContents_(); - }, - - updateContents_: function() { - this.textContent = ''; - this.diagnostic.iterItems(function(name, value) { - var link = document.createElement('tr-ui-a-analysis-link'); - link.setSelectionAndContent(value, name); - this.appendChild(link); - this.appendChild(document.createElement('br')); - }, this); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/related_value_map_span_test.html b/chromium/third_party/catapult/tracing/tracing/value/ui/related_value_map_span_test.html deleted file mode 100644 index c63ae6f1134..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/related_value_map_span_test.html +++ /dev/null @@ -1,35 +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/value/diagnostics/related_value_map.html"> -<link rel="import" href="/tracing/value/ui/diagnostic_span.html"> -<link rel="import" href="/tracing/value/value.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiate_RelatedValueMap', function() { - var aValue = new tr.v.SkipValue('a'); - var bValue = new tr.v.SkipValue('b'); - var diagnostic = new tr.v.d.RelatedValueMap(); - diagnostic.set('foo', aValue); - diagnostic.set('bar', bValue); - var span = tr.v.ui.createDiagnosticSpan(diagnostic); - assert.strictEqual('TR-V-UI-RELATED-VALUE-MAP-SPAN', span.tagName); - this.addHTMLOutput(span); - assert.isDefined(tr.b.findDeepElementMatchingPredicate( - span, function(element) { - return element.textContent === 'foo'; - })); - assert.isDefined(tr.b.findDeepElementMatchingPredicate( - span, function(element) { - return element.textContent === 'bar'; - })); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/related_value_set_span.html b/chromium/third_party/catapult/tracing/tracing/value/ui/related_value_set_span.html deleted file mode 100644 index 2edffb9df05..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/related_value_set_span.html +++ /dev/null @@ -1,38 +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/ui/analysis/analysis_link.html"> - -<polymer-element name="tr-v-ui-related-value-set-span"> - <script> - 'use strict'; - Polymer({ - ready: function() { - this.diagnostic_ = undefined; - }, - - get diagnostic() { - return this.diagnostic_; - }, - - set diagnostic(d) { - this.diagnostic_ = d; - this.updateContents_(); - }, - - updateContents_: function() { - this.textContent = ''; - this.diagnostic.values.forEach(function(value) { - var link = document.createElement('tr-ui-a-analysis-link'); - link.setSelectionAndContent(value, value.name); - this.appendChild(link); - this.appendChild(document.createElement('br')); - }, this); - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/related_value_set_span_test.html b/chromium/third_party/catapult/tracing/tracing/value/ui/related_value_set_span_test.html deleted file mode 100644 index 222dee57af6..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/related_value_set_span_test.html +++ /dev/null @@ -1,35 +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/value/diagnostics/composition.html"> -<link rel="import" href="/tracing/value/diagnostics/related_value_set.html"> -<link rel="import" href="/tracing/value/ui/diagnostic_span.html"> -<link rel="import" href="/tracing/value/value.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('instantiate_RelatedValueSet', function() { - var aValue = new tr.v.SkipValue('a'); - var bValue = new tr.v.SkipValue('b'); - var diagnostic = new tr.v.d.RelatedValueSet([aValue, bValue]); - var span = tr.v.ui.createDiagnosticSpan(diagnostic); - assert.strictEqual('TR-V-UI-RELATED-VALUE-SET-SPAN', span.tagName); - this.addHTMLOutput(span); - }); - - test('instantiate_Composition', function() { - var aValue = new tr.v.SkipValue('a'); - var bValue = new tr.v.SkipValue('b'); - var diagnostic = new tr.v.d.Composition([aValue, bValue]); - var span = tr.v.ui.createDiagnosticSpan(diagnostic); - assert.strictEqual('TR-V-UI-RELATED-VALUE-SET-SPAN', span.tagName); - this.addHTMLOutput(span); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/scalar_span.html b/chromium/third_party/catapult/tracing/tracing/value/ui/scalar_span.html deleted file mode 100644 index 7588ee50d48..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/scalar_span.html +++ /dev/null @@ -1,263 +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/ui/base/deep_utils.html"> -<link rel="import" href="/tracing/ui/base/polymer_utils.html"> -<link rel="import" href="/tracing/value/numeric.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<script> -'use strict'; -tr.exportTo('tr.v.ui', function() { - /** - * @param {undefined|tr.v.NumericValue|tr.v.Numeric} value - * @param {Object=} opt_config - * @return {string|Element} - */ - function createScalarSpan(value, opt_config) { - if (value === undefined) - return ''; - - var config = opt_config || {}; - var ownerDocument = config.ownerDocument || document; - - var span = ownerDocument.createElement('tr-v-ui-scalar-span'); - - if (value instanceof tr.v.NumericValue) { - value = value.numeric; - config.unit = value.unit; - } - - var numericValue; - if (value instanceof tr.v.ScalarNumeric) { - span.value = value; - numericValue = value.value; - } else if (value instanceof tr.v.Numeric) { - numericValue = value.average; - span.setValueAndUnit(numericValue, value.unit); - } else { - var unit = config.unit; - if (unit === undefined) { - throw new Error( - 'Unit must be provided in config when value is a number'); - } - span.setValueAndUnit(value, unit); - numericValue = value; - } - - if (config.context) - span.context = config.context; - - if (config.total) - span.percentage = numericValue / config.total; - - if (config.rightAlign) - span.rightAlign = true; - - return span; - } - - tr.v.Unit.addEventListener('display-mode-changed', function(e) { - var scalarSpanTagName = 'tr-v-ui-scalar-span'; - var subclassNames = tr.ui.b.getPolymerElementsThatSubclass( - scalarSpanTagName); - subclassNames.push(scalarSpanTagName); - var isSubclass = {}; - subclassNames.forEach(function(n) { - isSubclass[n.toUpperCase()] = true; - }); - - var m = tr.b.findDeepElementsMatchingPredicate( - document.body, - function(el) { - return isSubclass[el.tagName]; - }); - m.forEach(function(el) { - el.updateContent_(); - }); - }); - - return { - createScalarSpan: createScalarSpan - }; -}); -</script> - -<polymer-element name="tr-v-ui-scalar-span"> - <template> - <style> - :host { - display: block; - position: relative; - } - #content.right-align { - text-align: right; - position: relative; - display: block; - } - #sparkline { - width: 0%; - position: absolute; - bottom: 0; - right: 0; - display: none; - height: 100%; - background-color: hsla(216, 100%, 94.5%, .75); - border-left: 1px solid hsl(216, 100%, 89%); - box-sizing: border-box; - } - #warning { - margin-left: 4px; - font-size: 66%; - } - </style> - <span id="sparkline"></span> - <span id="content"></span> - <span id="warning" style="display:none">⚠</span> - </template> - <script> - 'use strict'; - - Polymer({ - ready: function() { - this.value_ = undefined; - this.unit_ = undefined; - this.context_ = undefined; - - this.warning_ = undefined; - this.percentage_ = undefined; - }, - - set contentTextDecoration(deco) { - this.$.content.style.textDecoration = deco; - }, - - get value() { - return this.value_; - }, - - set value(value) { - if (value instanceof tr.v.ScalarNumeric) { - this.value_ = value.value; - this.unit_ = value.unit; - } else { - this.value_ = value; - } - this.updateContent_(); - }, - - get unit() { - return this.unit_; - }, - - set unit(unit) { - this.unit_ = unit; - this.updateContent_(); - }, - - get context() { - return this.context_; - }, - - set context(context) { - this.context_ = context; - this.updateContent_(); - }, - - setValueAndUnit: function(value, unit) { - this.value_ = value; - this.unit_ = unit; - this.updateContent_(); - }, - - get percentage() { - return this.percentage_; - }, - - set percentage(percentage) { - this.percentage_ = percentage; - this.updateSparkline_(); - }, - - get rightAlign() { - return this.$.content.classList.contains('right-align'); - }, - - set rightAlign(rightAlign) { - if (rightAlign) - this.$.content.classList.add('right-align'); - else - this.$.content.classList.remove('right-align'); - }, - - updateSparkline_: function() { - if (this.percentage_ === undefined) { - this.$.sparkline.style.display = 'none'; - this.$.sparkline.style.width = '0'; - } else { - this.$.sparkline.style.display = 'block'; - this.$.sparkline.style.width = (this.percentage_ * 100) + '%'; - } - }, - - updateContent_: function() { - if (this.unit_ === undefined) { - this.$.content.textContent = ''; - this.$.content.style.color = ''; - return; - } - - this.$.content.textContent = this.unit_.format(this.value, this.context); - - var BIGGER_IS_BETTER = tr.v.ImprovementDirection.BIGGER_IS_BETTER; - var SMALLER_IS_BETTER = tr.v.ImprovementDirection.SMALLER_IS_BETTER; - var color = ''; - if (this.unit_.isDelta) { - var improvementDirection = this.unit_.improvementDirection; - if (this.value > 0) { - // Positive delta. - switch (improvementDirection) { - case BIGGER_IS_BETTER: - color = 'green'; - break; - case SMALLER_IS_BETTER: - color = 'red'; - break; - } - } else if (this.value < 0) { - // Negative delta. - switch (improvementDirection) { - case BIGGER_IS_BETTER: - color = 'red'; - break; - case SMALLER_IS_BETTER: - color = 'green'; - break; - } - } - } - this.$.content.style.color = color; - }, - - get warning() { - return this.warning_; - }, - - set warning(warning) { - this.warning_ = warning; - var warningEl = this.$.warning; - if (this.warning_) { - warningEl.title = warning; - warningEl.style.display = ''; - } else { - warningEl.title = ''; - warningEl.style.display = 'none'; - } - } - }); - </script> -</polymer-element> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/scalar_span_test.html b/chromium/third_party/catapult/tracing/tracing/value/ui/scalar_span_test.html deleted file mode 100644 index 04c266cdc3a..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/scalar_span_test.html +++ /dev/null @@ -1,236 +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/value/numeric.html"> -<link rel="import" href="/tracing/value/time_display_mode.html"> -<link rel="import" href="/tracing/value/ui/scalar_span.html"> -<link rel="import" href="/tracing/value/unit.html"> -<link rel="import" href="/tracing/value/unit_scale.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var ScalarNumeric = tr.v.ScalarNumeric; - var Unit = tr.v.Unit; - var THIS_DOC = document._currentScript.ownerDocument; - - function checkScalarSpan( - test, value, unit, expectedTextContent, opt_expectedColor) { - var span = tr.v.ui.createScalarSpan(new tr.v.ScalarNumeric(unit, value)); - assert.strictEqual(span.$.content.textContent, expectedTextContent); - assert.strictEqual(span.$.content.style.color, opt_expectedColor || ''); - test.addHTMLOutput(span); - } - - test('instantiate', function() { - checkScalarSpan(this, 123.456789, Unit.byName.timeDurationInMs, - '123.457 ms'); - checkScalarSpan(this, 0, Unit.byName.normalizedPercentage, '0.000%'); - checkScalarSpan(this, -2560, Unit.byName.sizeInBytes, '-2.5 KiB'); - }); - - test('instantiate_smallerIsBetter', function() { - checkScalarSpan(this, 45097156608, Unit.byName.sizeInBytes_smallerIsBetter, - '42.0 GiB'); - checkScalarSpan(this, 0, Unit.byName.energyInJoules_smallerIsBetter, - '0.000 J'); - checkScalarSpan(this, -0.25, Unit.byName.unitlessNumber_smallerIsBetter, - '-0.250'); - }); - - test('instantiate_biggerIsBetter', function() { - checkScalarSpan(this, 0.07, Unit.byName.powerInWatts_smallerIsBetter, - '0.070 W'); - checkScalarSpan(this, 0, Unit.byName.timeStampInMs_biggerIsBetter, - '0.000 ms'); - checkScalarSpan(this, -0.00003, - Unit.byName.normalizedPercentage_biggerIsBetter, '-0.003%'); - }); - - test('instantiate_delta', function() { - checkScalarSpan(this, 123.456789, Unit.byName.timeDurationInMsDelta, - '+123.457 ms'); - checkScalarSpan(this, 0, Unit.byName.normalizedPercentageDelta, - '\u00B10.000%'); - checkScalarSpan(this, -2560, Unit.byName.sizeInBytesDelta, - '-2.5 KiB'); - }); - - test('instantiate_delta_smallerIsBetter', function() { - checkScalarSpan(this, 45097156608, - Unit.byName.sizeInBytesDelta_smallerIsBetter, '+42.0 GiB', 'red'); - checkScalarSpan(this, 0, Unit.byName.energyInJoulesDelta_smallerIsBetter, - '\u00B10.000 J'); - checkScalarSpan(this, -0.25, - Unit.byName.unitlessNumberDelta_smallerIsBetter, '-0.250', 'green'); - }); - - test('instantiate_delta_biggerIsBetter', function() { - checkScalarSpan(this, 0.07, Unit.byName.powerInWattsDelta_biggerIsBetter, - '+0.070 W', 'green'); - checkScalarSpan(this, 0, Unit.byName.timeStampInMsDelta_biggerIsBetter, - '\u00B10.000 ms'); - checkScalarSpan(this, -0.00003, - Unit.byName.normalizedPercentageDelta_biggerIsBetter, '-0.003%', 'red'); - }); - - test('createScalarSpan', function() { - // No config. - var span = tr.v.ui.createScalarSpan( - new ScalarNumeric(Unit.byName.powerInWatts, 3.14)); - assert.strictEqual(span.$.content.textContent, '3.140 W'); - assert.strictEqual(span.ownerDocument, document); - assert.strictEqual(span.tagName, 'TR-V-UI-SCALAR-SPAN'); - assert.strictEqual(span.value, 3.14); - assert.strictEqual(span.unit, Unit.byName.powerInWatts); - assert.isUndefined(span.context); - assert.isUndefined(span.percentage); - assert.isUndefined(span.warning); - assert.isFalse(span.rightAlign); - this.addHTMLOutput(span); - - // Custom owner document and right align. - var span = tr.v.ui.createScalarSpan( - new ScalarNumeric(Unit.byName.energyInJoules, 2.72), - { ownerDocument: THIS_DOC, rightAlign: true }); - assert.strictEqual(span.$.content.textContent, '2.720 J'); - assert.strictEqual(span.ownerDocument, THIS_DOC); - assert.strictEqual(span.tagName, 'TR-V-UI-SCALAR-SPAN'); - assert.strictEqual(span.value, 2.72); - assert.strictEqual(span.unit, Unit.byName.energyInJoules); - assert.isUndefined(span.context); - assert.isUndefined(span.percentage); - assert.isUndefined(span.warning); - assert.isTrue(span.rightAlign); - this.addHTMLOutput(span); - - // Unit and sparkline set via config. - var span = tr.v.ui.createScalarSpan(1.62, - { unit: Unit.byName.timeStampInMs, total: 3.24 }); - assert.strictEqual(span.$.content.textContent, '1.620 ms'); - assert.strictEqual(span.ownerDocument, document); - assert.strictEqual(span.tagName, 'TR-V-UI-SCALAR-SPAN'); - assert.strictEqual(span.value, 1.62); - assert.strictEqual(span.unit, Unit.byName.timeStampInMs); - assert.isUndefined(span.context); - assert.strictEqual(span.percentage, 0.5); - assert.isUndefined(span.warning); - assert.isFalse(span.rightAlign); - this.addHTMLOutput(span); - - // Custom context. - var span = tr.v.ui.createScalarSpan( - new ScalarNumeric(Unit.byName.sizeInBytesDelta_smallerIsBetter, - 256 * 1024 * 1024), { context: { - unitPrefix: tr.v.UnitScale.Binary.KIBI, - minimumFractionDigits: 2 - } }); - assert.strictEqual(span.$.content.textContent, '+262,144.00 KiB'); - assert.strictEqual(span.ownerDocument, document); - assert.strictEqual(span.tagName, 'TR-V-UI-SCALAR-SPAN'); - assert.strictEqual(span.value, 256 * 1024 * 1024); - assert.strictEqual(span.unit, Unit.byName.sizeInBytesDelta_smallerIsBetter); - assert.deepEqual(span.context, - { unitPrefix: tr.v.UnitScale.Binary.KIBI, minimumFractionDigits: 2 }); - assert.isUndefined(span.percentage); - assert.isUndefined(span.warning); - assert.isFalse(span.rightAlign); - this.addHTMLOutput(span); - }); - - test('instantiate_withWarning', function() { - var span = document.createElement('tr-v-ui-scalar-span'); - span.value = 400000000; - span.unit = Unit.byName.sizeInBytes; - span.warning = 'There is a problem with this size'; - this.addHTMLOutput(span); - }); - - test('instantiate_withPercentage', function() { - var span = document.createElement('tr-v-ui-scalar-span'); - span.value = new ScalarNumeric(Unit.byName.unitlessNumber, 99); - span.percentage = 0.66; - this.addHTMLOutput(span); - }); - - test('instantiate_withRightAlign', function() { - var span = document.createElement('tr-v-ui-scalar-span'); - span.value = new ScalarNumeric(Unit.byName.timeStampInMs, 5.777); - span.rightAlign = true; - this.addHTMLOutput(span); - }); - - test('instantiate_withContext', function() { - var span = document.createElement('tr-v-ui-scalar-span'); - span.value = new ScalarNumeric( - Unit.byName.unitlessNumberDelta_smallerIsBetter, 42); - span.context = { maximumFractionDigits: 2 }; - assert.strictEqual(span.$.content.textContent, '+42.00'); - this.addHTMLOutput(span); - }); - - test('warningAndNonWarningHaveSimilarHeights', function() { - var spanA = document.createElement('tr-v-ui-scalar-span'); - spanA.setValueAndUnit(400, Unit.byName.timeDurationInMs); - - var spanB = document.createElement('tr-v-ui-scalar-span'); - spanB.setValueAndUnit(400, Unit.byName.timeDurationInMs); - spanB.warning = 'There is a problem with this time'; - - var overall = document.createElement('div'); - overall.style.display = 'flex'; - overall.appendChild(spanA); - spanB.style.marginLeft = '4px'; - overall.appendChild(spanB); - this.addHTMLOutput(overall); - }); - - test('respectCurrentDisplayUnit', function() { - try { - Unit.currentTimeDisplayMode = tr.v.TimeDisplayModes.ns; - - var span = document.createElement('tr-v-ui-scalar-span'); - span.setValueAndUnit(73, Unit.byName.timeStampInMs); - this.addHTMLOutput(span); - - assert.isTrue(span.$.content.textContent.indexOf('ns') > 0); - Unit.currentTimeDisplayMode = tr.v.TimeDisplayModes.ms; - assert.isTrue(span.$.content.textContent.indexOf('ms') > 0); - } finally { - Unit.reset(); - } - }); - - test('displaySparkline', function() { - var div = document.createElement('div'); - div.style.width = '100px'; - this.addHTMLOutput(div); - - function addAndCheckScalarSpan(percentage, expectedDisplay, expectedWidth) { - var span = tr.v.ui.createScalarSpan(new ScalarNumeric( - Unit.byName.timeDurationInMs, 10 * div.children.length)); - if (percentage !== null) - span.percentage = percentage; - - div.appendChild(span); - - var computedStyle = getComputedStyle(span.$.sparkline); - assert.equal(computedStyle.display, expectedDisplay); - assert.equal(parseInt(computedStyle.width), expectedWidth); - } - - addAndCheckScalarSpan(null /* no percentage set */, 'none', 0); - addAndCheckScalarSpan(undefined, 'none', 0); - addAndCheckScalarSpan(0, 'block', 1); - addAndCheckScalarSpan(0.05, 'block', 5); - addAndCheckScalarSpan(0.5, 'block', 50); - addAndCheckScalarSpan(0.95, 'block', 95); - addAndCheckScalarSpan(1, 'block', 100); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/value_set_table.html b/chromium/third_party/catapult/tracing/tracing/value/ui/value_set_table.html deleted file mode 100644 index e9388185408..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/value_set_table.html +++ /dev/null @@ -1,315 +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/raf.html"> -<link rel="import" href="/tracing/ui/base/table.html"> -<link rel="import" href="/tracing/value/ui/diagnostic_span.html"> -<link rel="import" href="/tracing/value/ui/histogram_span.html"> -<link rel="import" href="/tracing/value/ui/scalar_span.html"> -<link rel="import" href="/tracing/value/ui/value_set_view.html"> -<link rel="import" href="/tracing/value/unit.html"> - -<polymer-element name='tr-v-ui-value-set-table'> - <template> - <style> - :host { - display: flex; - flex-direction: column; - } - table-container { - display: flex; - min-height: 0px; - overflow-y: auto; - } - div#error { - color: red; - } - #histogram { - display: none; - } - </style> - - <div id="error"></div> - <table-container> - <tr-ui-b-table id="table"></tr-ui-b-table> - </table-container> - <tr-v-ui-histogram-span id="histogram"></tr-v-ui-histogram-span> - </template> -</polymer-element> - -<script> -'use strict'; -tr.exportTo('tr.ui', function() { - Polymer('tr-v-ui-value-set-table', { - /** - * Return true if this view supports this ValueSet. - * Value-set-table supports all possible metrics, so it always returns true. - * - * @param {!tr.v.ValueSet} values - * @return {boolean} - */ - supportsValueSet: function(values) { - return true; - }, - - /** - * This can optionally depend on the ValueSet. - * - * @return {string} - */ - get tabLabel() { - return 'Table'; - }, - - ready: function() { - this.values_ = undefined; - this.summaryValues_ = {}; - this.columns_ = undefined; - this.$.table.selectionMode = tr.ui.b.TableFormat.SelectionMode.CELL; - this.$.table.addEventListener('selection-changed', - this.onSelectionChanged_.bind(this)); - }, - - onSelectionChanged_: function() { - var row = this.$.table.selectedTableRow; - var col = this.$.table.selectedColumnIndex; - var cell = undefined; - if (row && col && this.columns_) - cell = row[this.columns_[col].title]; - - if ((cell instanceof tr.v.NumericValue) && - (cell.numeric instanceof tr.v.Numeric)) { - this.$.histogram.style.display = 'block'; - this.$.histogram.histogram = cell.numeric; - } else { - this.$.histogram.style.display = 'none'; - } - }, - - handleFailureValues_: function() { - this.values.map(function(value) { - if (value instanceof tr.v.FailureValue) { - this.$.error.textContent = value.description; - this.$.table.style.display = 'none'; - this.style.width = '10em'; - } - }, this); - }, - - addDiagnosticSubRows_: function(value, row, column) { - value.diagnostics.forEach(function(name, diagnostic) { - if (name === tr.v.SUMMARY_VALUE_MAP_DIAGNOSTIC_NAME) - return; - - // If a previous |value| had a diagnostic with the same name, then - // there is already a subRow that should contain this diagnostic. - for (var subRow of row.subRows) { - if (subRow.name === name) { - subRow[column] = diagnostic; - return; - } - } - - // This is the first time that a diagnostic with this name has been - // seen for Values whose name is |value.name|, so create a new subRow. - var subRow = {name: name}; - subRow[column] = diagnostic; - row.subRows.push(subRow); - }); - }, - - get values() { - return this.values_; - }, - - findSummaryValues_: function() { - this.summaryValues_ = {}; - this.values.map(function(value) { - var summaryValueMap = value.diagnostics.get( - tr.v.SUMMARY_VALUE_MAP_DIAGNOSTIC_NAME); - if (!(summaryValueMap instanceof tr.v.d.RelatedValueMap)) - return; - - summaryValueMap.values.forEach(function(summaryValue) { - this.summaryValues_[summaryValue.guid] = summaryValue; - }, this); - }, this); - }, - - /** - * @param {!tr.v.ValueSet} values - */ - set values(values) { - this.values_ = values; - this.style.width = ''; - this.$.table.style.display = ''; - this.$.error.textContent = ''; - - this.handleFailureValues_(); - if (this.$.error.textContent) - return; - - this.findSummaryValues_(); - - /* rows will look something like [ - {name: 'long tasks', - displayLabelA: Value, - displayLabelB: Value, - subRows: [ - {name: 'iteration', - displayLabelA: Diagnostic, - displayLabelB: Diagnostic, - } - ] - } - ] - TODO(benjhayden): After Values are summarized and merged, there will be - more row tiers: value name > benchmark name > story name > benchmark - start > storyset repeat > story repeat > diagnostics. - */ - var rows = []; - - // This will be used to sort the columns by start time. - var startTimesForDisplayLabels = {}; - - tr.b.iterItems(values.organizedByName, function(name, vals) { - var row = {name: name, subRows: []}; - var isEmptyRow = true; - - vals.forEach(function(val) { - if (this.summaryValues_[val.guid]) - return; - - if (!row.description && val.description) - row.description = val.description; - - var displayLabel = 'Value'; - var startMs = 0; - var iteration = val.diagnostics.get( - tr.v.ITERATION_INFO_DIAGNOSTIC_NAME); - if (iteration instanceof tr.v.d.IterationInfo) { - displayLabel = iteration.displayLabel; - startMs = iteration.benchmarkStart.getTime(); - } - - this.addDiagnosticSubRows_(val, row, displayLabel); - - startTimesForDisplayLabels[displayLabel] = Math.min( - startTimesForDisplayLabels[displayLabel] || 0, - startMs); - - if (row[displayLabel] !== undefined) { - console.warn('Multiple Values with same name and displayLabel:', - name, displayLabel, row[displayLabel], val, - 'Sorry, only one will be displayed until summarization and ' + - 'merging are implemented.'); - } - row[displayLabel] = val; - isEmptyRow = false; - }, this); - - if (isEmptyRow) - return; - - rows.push(row); - }, this); - - if (rows.length === 0) { - this.$.error.textContent = 'zero values'; - this.$.table.style.display = 'none'; - this.style.width = '10em'; - return; - } - - this.buildColumns_(startTimesForDisplayLabels); - - this.$.table.tableColumns = this.columns_; - this.$.table.tableRows = rows; - this.$.table.sortColumnIndex = 0; - this.$.table.rebuild(); - this.$.table.selectedTableRow = rows[0]; - this.$.table.selectedColumnIndex = 1; - - tr.b.requestAnimationFrame(function() { - this.style.width = this.$.table.getBoundingClientRect().width; - }, this); - }, - - buildColumns_: function(startTimesForDisplayLabels) { - var displayLabels = Object.keys(startTimesForDisplayLabels); - displayLabels.sort(function(a, b) { - return startTimesForDisplayLabels[a] - startTimesForDisplayLabels[b]; - }); - - this.columns_ = [ - { - title: 'Name', - align: tr.ui.b.TableFormat.ColumnAlignment.LEFT, - - value: function(row) { - var nameEl = document.createElement('span'); - nameEl.textContent = row.name; - if (row.description) - nameEl.title = row.description; - nameEl.style.textOverflow = 'ellipsis'; - return nameEl; - }, - - cmp: function(rowA, rowB) { - rowA = rowA ? rowA.name : ''; - rowB = rowB ? rowB.name : ''; - return rowA.localeCompare(rowB); - }, - } - ]; - - displayLabels.forEach(function(displayLabel) { - this.columns_.push({ - title: displayLabel, - align: tr.ui.b.TableFormat.ColumnAlignment.RIGHT, - supportsCellSelection: true, - - value: function(row) { - var cell = row[displayLabel]; - if (cell instanceof tr.v.d.Diagnostic) { - return tr.v.ui.createDiagnosticSpan(cell); - } else if (cell instanceof tr.v.NumericValue) { - return tr.v.ui.createScalarSpan(cell); - } else if (cell === undefined) { - return ''; - } else { - throw new Error('Invalid cell', cell); - } - }, - - cmp: function(rowA, rowB) { - var cellA = rowA[displayLabel]; - var cellB = rowB[displayLabel]; - if (!(cellA instanceof tr.v.NumericValue) || - !(cellB instanceof tr.v.NumericValue)) - return undefined; - - var numericA = cellA.numeric; - var numericB = cellB.numeric; - - var valueA = (numericA instanceof tr.v.ScalarNumeric) ? - numericA.value : numericA.average; - var valueB = (numericB instanceof tr.v.ScalarNumeric) ? - numericB.value : numericB.average; - - return valueA - valueB; - } - }); - }, this); - } - }); - - tr.ui.registerValueSetView('tr-v-ui-value-set-table'); - - return {}; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/value_set_table_test.html b/chromium/third_party/catapult/tracing/tracing/value/ui/value_set_table_test.html deleted file mode 100644 index 5358e8442f3..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/value_set_table_test.html +++ /dev/null @@ -1,87 +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/value/ui/value_set_table.html"> -<link rel="import" href="/tracing/value/value_set.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var TEST_NUMERIC_BUILDER = tr.v.NumericBuilder.createLinear( - tr.v.Unit.byName.timeDurationInMs, tr.b.Range.fromExplicitRange(0, 1000), - 20); - - test('instantiate', function() { - var table = document.createElement('tr-v-ui-value-set-table'); - var values = new tr.v.ValueSet(); - assert.isTrue(table.supportsValueSet(values)); - - var numeric0a = TEST_NUMERIC_BUILDER.build(); - for (var i = 0; i < 1e2; ++i) { - numeric0a.add(Math.random() * 1000); - } - var fooA = new tr.v.NumericValue('foo', numeric0a, { - description: 'they should have sent a poet' - }); - values.addValue(fooA); - fooA.diagnostics.add( - tr.v.ITERATION_INFO_DIAGNOSTIC_NAME, new tr.v.d.IterationInfo({ - label: 'iteration A', - benchmarkStartMs: new Date().getTime(), - })); - - var numeric1a = TEST_NUMERIC_BUILDER.build(); - for (var i = 0; i < 1e2; ++i) { - numeric1a.add(Math.random() * 1000); - } - var barA = new tr.v.NumericValue('bar', numeric1a, { - description: 'indescribable' - }); - values.addValue(barA); - barA.diagnostics.add( - tr.v.ITERATION_INFO_DIAGNOSTIC_NAME, new tr.v.d.IterationInfo({ - label: 'iteration A', - benchmarkStartMs: new Date().getTime(), - })); - - var numeric0b = TEST_NUMERIC_BUILDER.build(); - for (var i = 0; i < 1e2; ++i) { - numeric0b.add(Math.random() * 1000); - } - var fooB = new tr.v.NumericValue('foo', numeric0b, { - description: 'they should have sent a poet' - }); - values.addValue(fooB); - fooB.diagnostics.add( - tr.v.ITERATION_INFO_DIAGNOSTIC_NAME, new tr.v.d.IterationInfo({ - label: 'iteration B', - benchmarkStartMs: new Date().getTime(), - })); - - var numeric1b = TEST_NUMERIC_BUILDER.build(); - for (var i = 0; i < 1e2; ++i) { - numeric1b.add(Math.random() * 1000); - } - var barB = new tr.v.NumericValue('bar', numeric1b, { - description: 'indescribable' - }); - values.addValue(barB); - barB.diagnostics.add( - tr.v.ITERATION_INFO_DIAGNOSTIC_NAME, new tr.v.d.IterationInfo({ - label: 'iteration B', - benchmarkStartMs: new Date().getTime(), - })); - - table.values = values; - this.addHTMLOutput(table); - // XXX test multi-col - // XXX test selection - // XXX test sorting by name, valueA, valueB - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/ui/value_set_view.html b/chromium/third_party/catapult/tracing/tracing/value/ui/value_set_view.html deleted file mode 100644 index 9a773957e74..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/ui/value_set_view.html +++ /dev/null @@ -1,87 +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/ui/base/polymer_utils.html"> -<link rel="import" href="/tracing/ui/base/tab_view.html"> - -<polymer-element name='tr-v-ui-value-set-view'> - <template> - <tr-ui-a-tab-view id="container"></tr-ui-a-tab-view> - </template> -</polymer-element> - -<script> -'use strict'; -tr.exportTo('tr.ui', function() { - var VALUE_SET_VIEW_ELEMENT_NAMES = []; - - var SELECTED_TAB_SETTINGS_KEY = 'tr-v-ui-value-set-view-element-name'; - - Polymer('tr-v-ui-value-set-view', { - ready: function() { - this.$.container.addEventListener( - 'selected-tab-change', this.onSelectedTabChange_.bind(this)); - }, - - onSelectedTabChange_: function() { - if (!this.$.container.selectedTab) - return; - - tr.b.Settings.set( - SELECTED_TAB_SETTINGS_KEY, - this.$.container.selectedTab.tagName.toLowerCase()); - }, - - /** - * @param {!tr.v.ValueSet} values - */ - set values(values) { - this.$.container.textContent = ''; - - var initialTabElementName = tr.b.Settings.get( - SELECTED_TAB_SETTINGS_KEY, undefined); - - VALUE_SET_VIEW_ELEMENT_NAMES.forEach(function(elementName, index) { - var view = document.createElement(elementName); - if (!view.supportsValueSet(values)) - return; - - view.values = values; - - if (elementName.toLowerCase() === initialTabElementName) - view.setAttribute('selected', true); - - view.setAttribute('tab-label', view.tabLabel); - - this.$.container.appendChild(view); - }, this); - - if (this.$.container.children.length === 1) { - this.$.container.tabsHidden = true; - } else if (this.$.container.selectedTab === undefined) { - this.$.container.children[0].setAttribute('selected', true); - } - } - }); - - /** - * Register the name of a polymer element that supports displaying ValueSets. - * - * @param {string} elementName - */ - function registerValueSetView(elementName) { - if (!tr.ui.b.getPolymerElementNamed(elementName)) - throw new Error('Element not registered: ' + elementName); - - VALUE_SET_VIEW_ELEMENT_NAMES.push(elementName); - } - - return { - registerValueSetView: registerValueSetView - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/unit.html b/chromium/third_party/catapult/tracing/tracing/value/unit.html deleted file mode 100644 index aa4fed27746..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/unit.html +++ /dev/null @@ -1,333 +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/event.html"> -<link rel="import" href="/tracing/base/event_target.html"> -<link rel="import" href="/tracing/base/iteration_helpers.html"> -<link rel="import" href="/tracing/value/time_display_mode.html"> -<link rel="import" href="/tracing/value/unit_scale.html"> - -<script> -'use strict'; - -tr.exportTo('tr.v', function() { - var TimeDisplayModes = tr.v.TimeDisplayModes; - - var PLUS_MINUS_SIGN = String.fromCharCode(177); - - function max(a, b) { - if (a === undefined) - return b; - if (b === undefined) - return a; - return a.scale > b.scale ? a : b; - } - - /** @enum */ - var ImprovementDirection = { - DONT_CARE: 0, - BIGGER_IS_BETTER: 1, - SMALLER_IS_BETTER: 2 - }; - - /** @constructor */ - function Unit(unitName, jsonName, isDelta, improvementDirection, formatSpec) { - this.unitName = unitName; - this.jsonName = jsonName; - this.isDelta = isDelta; - this.improvementDirection = improvementDirection; - this.formatSpec_ = formatSpec; - - // Example: powerInWattsDelta_biggerIsBetter -> powerInWatts. - this.baseUnit = undefined; - - // Example: energyInJoules_smallerIsBetter -> - // energyInJoulesDelta_smallerIsBetter. - this.correspondingDeltaUnit = undefined; - } - - Unit.prototype = { - asJSON: function() { - return this.jsonName; - }, - - format: function(value, opt_context) { - var context = opt_context || {}; - var formatSpec = this.formatSpec_; - if (typeof formatSpec === 'function') - formatSpec = formatSpec(); - - function resolveProperty(propertyName) { - if (propertyName in context) - return context[propertyName]; - else if (propertyName in formatSpec) - return formatSpec[propertyName]; - else - return undefined; - } - - var signString = ''; - if (value < 0) { - signString = '-'; - value = -value; // Treat positive and negative values symmetrically. - } else if (this.isDelta) { - signString = value === 0 ? PLUS_MINUS_SIGN : '+'; - } - - var unitString = ''; - if (formatSpec.unit) { - if (formatSpec.unitHasPrecedingSpace !== false) - unitString += ' '; - var unitPrefix = resolveProperty('unitPrefix'); - if (unitPrefix !== undefined) { - var selectedPrefix; - if (unitPrefix instanceof Array) { - var i = 0; - while (i < unitPrefix.length - 1 && - value / unitPrefix[i + 1].value >= 1) { - i++; - } - selectedPrefix = unitPrefix[i]; - } else { - selectedPrefix = unitPrefix; - } - unitString += selectedPrefix.symbol || ''; - value /= selectedPrefix.value; - } - unitString += formatSpec.unit; - } - - var minimumFractionDigits = resolveProperty('minimumFractionDigits'); - var maximumFractionDigits = resolveProperty('maximumFractionDigits'); - - // If the context overrides only one of the two |*FractionDigits| - // properties and the other one is provided by the unit, we might need to - // shift the other property so that - // |minimumFractionDigits| <= |maximumFractionDigits|. - if (minimumFractionDigits > maximumFractionDigits) { - if ('minimumFractionDigits' in context && - !('maximumFractionDigits' in context)) { - // Only minimumFractionDigits was overriden by context. - maximumFractionDigits = minimumFractionDigits; - } else if ('maximumFractionDigits' in context && - !('minimumFractionDigits' in context)) { - // Only maximumFractionDigits was overriden by context. - minimumFractionDigits = maximumFractionDigits; - } - } - - var numberString = value.toLocaleString(undefined, { - minimumFractionDigits: minimumFractionDigits, - maximumFractionDigits: maximumFractionDigits - }); - - return signString + numberString + unitString; - } - }; - - Unit.reset = function() { - Unit.currentTimeDisplayMode = TimeDisplayModes.ms; - }; - - Unit.timestampFromUs = function(us) { - return us / 1000; - }; - - Unit.maybeTimestampFromUs = function(us) { - return us === undefined ? undefined : us / 1000; - }; - - Object.defineProperty(Unit, 'currentTimeDisplayMode', { - get: function() { - return Unit.currentTimeDisplayMode_; - }, - // Use tr-v-ui-preferred-display-unit element instead of directly setting. - set: function(value) { - if (Unit.currentTimeDisplayMode_ === value) - return; - - Unit.currentTimeDisplayMode_ = value; - Unit.dispatchEvent(new tr.b.Event('display-mode-changed')); - } - }); - - Unit.didPreferredTimeDisplayUnitChange = function() { - var largest = undefined; - var els = tr.b.findDeepElementsMatching(document.body, - 'tr-v-ui-preferred-display-unit'); - els.forEach(function(el) { - largest = max(largest, el.preferredTimeDisplayMode); - }); - - Unit.currentDisplayUnit = largest === undefined ? - TimeDisplayModes.ms : largest; - }; - - Unit.byName = {}; - Unit.byJSONName = {}; - - Unit.fromJSON = function(object) { - var u = Unit.byJSONName[object]; - if (u) { - return u; - } - throw new Error('Unrecognized unit'); - }; - - /** - * Define all combinations of a unit with isDelta and improvementDirection - * flags. For example, the following code: - * - * Unit.define({ - * baseUnitName: 'powerInWatts' - * baseJsonName: 'W' - * formatSpec: { - * // Specification of how the unit should be formatted (unit symbol, - * // unit prefix, fraction digits, etc), or a function returning such - * // a specification. - * } - * }); - * - * generates the following six units (JSON names shown in parentheses): - * - * Unit.byName.powerInWatts (W) - * Unit.byName.powerInWatts_smallerIsBetter (W_smallerIsBetter) - * Unit.byName.powerInWatts_biggerIsBetter (W_biggerIsBetter) - * Unit.byName.powerInWattsDelta (WDelta) - * Unit.byName.powerInWattsDelta_smallerIsBetter (WDelta_smallerIsBetter) - * Unit.byName.powerInWattsDelta_biggerIsBetter (WDelta_biggerIsBetter) - * - * with the appropriate flags and formatting code (including +/- prefixes - * for deltas). - */ - Unit.define = function(params) { - var definedUnits = []; - - tr.b.iterItems(ImprovementDirection, function(_, improvementDirection) { - var regularUnit = - Unit.defineUnitVariant_(params, false, improvementDirection); - var deltaUnit = - Unit.defineUnitVariant_(params, true, improvementDirection); - - regularUnit.correspondingDeltaUnit = deltaUnit; - deltaUnit.correspondingDeltaUnit = deltaUnit; - definedUnits.push(regularUnit, deltaUnit); - }); - - var baseUnit = Unit.byName[params.baseUnitName]; - definedUnits.forEach(u => u.baseUnit = baseUnit); - }; - - Unit.defineUnitVariant_ = function(params, isDelta, improvementDirection) { - var nameSuffix = isDelta ? 'Delta' : ''; - switch (improvementDirection) { - case ImprovementDirection.DONT_CARE: - break; - case ImprovementDirection.BIGGER_IS_BETTER: - nameSuffix += '_biggerIsBetter'; - break; - case ImprovementDirection.SMALLER_IS_BETTER: - nameSuffix += '_smallerIsBetter'; - break; - default: - throw new Error( - 'Unknown improvement direction: ' + improvementDirection); - } - - var unitName = params.baseUnitName + nameSuffix; - var jsonName = params.baseJsonName + nameSuffix; - if (Unit.byName[unitName] !== undefined) - throw new Error('Unit \'' + unitName + '\' already exists'); - if (Unit.byJSONName[jsonName] !== undefined) - throw new Error('JSON unit \'' + jsonName + '\' alread exists'); - - var unit = new Unit( - unitName, jsonName, isDelta, improvementDirection, params.formatSpec); - Unit.byName[unitName] = unit; - Unit.byJSONName[jsonName] = unit; - - return unit; - }; - - tr.b.EventTarget.decorate(Unit); - Unit.reset(); - - // Known display units follow. - ////////////////////////////////////////////////////////////////////////////// - - Unit.define({ - baseUnitName: 'timeDurationInMs', - baseJsonName: 'ms', - formatSpec: function() { - return Unit.currentTimeDisplayMode_.formatSpec; - } - }); - - Unit.define({ - baseUnitName: 'timeStampInMs', - baseJsonName: 'tsMs', - formatSpec: function() { - return Unit.currentTimeDisplayMode_.formatSpec; - } - }); - - Unit.define({ - baseUnitName: 'normalizedPercentage', - baseJsonName: 'n%', - formatSpec: { - unit: '%', - unitPrefix: { value: 0.01 }, - unitHasPrecedingSpace: false, - minimumFractionDigits: 3, - maximumFractionDigits: 3 - } - }); - - Unit.define({ - baseUnitName: 'sizeInBytes', - baseJsonName: 'sizeInBytes', - formatSpec: { - unit: 'B', - unitPrefix: tr.v.UnitScale.Binary.AUTO, - minimumFractionDigits: 1, - maximumFractionDigits: 1 - } - }); - - Unit.define({ - baseUnitName: 'energyInJoules', - baseJsonName: 'J', - formatSpec: { - unit: 'J', - minimumFractionDigits: 3 - } - }); - - Unit.define({ - baseUnitName: 'powerInWatts', - baseJsonName: 'W', - formatSpec: { - unit: 'W', - minimumFractionDigits: 3 - } - }); - - Unit.define({ - baseUnitName: 'unitlessNumber', - baseJsonName: 'unitless', - formatSpec: { - minimumFractionDigits: 3, - maximumFractionDigits: 3 - } - }); - - return { - ImprovementDirection: ImprovementDirection, - Unit: Unit - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/unit_scale.html b/chromium/third_party/catapult/tracing/tracing/value/unit_scale.html deleted file mode 100644 index 236caff9db1..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/unit_scale.html +++ /dev/null @@ -1,56 +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.v', function() { - - var UnitScale = {}; - - function defineUnitScale(name, prefixes) { - if (UnitScale[name] !== undefined) - throw new Error('Unit scale \'' + name + '\' already exists'); - if (prefixes.AUTO !== undefined) { - throw new Error('\'AUTO\' unit prefix will be added automatically ' + - 'for unit scale \'' + name + '\''); - } - - // If the 'AUTO' unit prefix is used, the prefix that results in - // the absolute formatted value being as close to the [1, 1024) interval as - // possible is used. Example: 1023 and 1024 bytes are displayed as - // "1,023.0 B" and "1.0 KiB", respectively. - prefixes.AUTO = tr.b.dictionaryValues(prefixes); - prefixes.AUTO.sort((a, b) => a.value - b.value); - - UnitScale[name] = prefixes; - } - - // See https://en.wikipedia.org/wiki/Binary_prefix. - defineUnitScale('Binary', { - NONE: { value: Math.pow(1024, 0), symbol: '' }, - KIBI: { value: Math.pow(1024, 1), symbol: 'Ki' }, - MEBI: { value: Math.pow(1024, 2), symbol: 'Mi' }, - GIBI: { value: Math.pow(1024, 3), symbol: 'Gi' }, - TEBI: { value: Math.pow(1024, 4), symbol: 'Ti' } - }); - - // See https://en.wikipedia.org/wiki/Metric_prefix. - // The base time unit used in the whole repository is ms (milliseconds), so - // all values are multiplied by 1000. - defineUnitScale('MetricTime', { - NANO: { value: 1e-6, symbol: 'n' }, - MILLI: { value: 1, symbol: 'm' } - }); - - return { - UnitScale: UnitScale - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/unit_test.html b/chromium/third_party/catapult/tracing/tracing/value/unit_test.html deleted file mode 100644 index 2c355f9831a..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/unit_test.html +++ /dev/null @@ -1,224 +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/value/time_display_mode.html"> -<link rel="import" href="/tracing/value/unit.html"> -<link rel="import" href="/tracing/value/unit_scale.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - var Unit = tr.v.Unit; - var UnitScale = tr.v.UnitScale; - var ImprovementDirection = tr.v.ImprovementDirection; - - test('Unit.display-mode-changed', function() { - var Unit = tr.v.Unit; - var TimeDisplayModes = tr.v.TimeDisplayModes; - - var listenerWasCalled = false; - function listener(e) { - listenerWasCalled = true; - } - - try { - Unit.currentTimeDisplayMode = TimeDisplayModes.ms; - Unit.addEventListener('display-mode-changed', listener); - - listenerWasCalled = false; - Unit.currentTimeDisplayMode = TimeDisplayModes.ns; - assert.isTrue(listenerWasCalled); - assert.equal(Unit.currentTimeDisplayMode, TimeDisplayModes.ns); - } finally { - Unit.removeEventListener('display-mode-changed', listener); - Unit.reset(); - } - }); - - function checkTimeUnit(unit) { - try { - // Use milliseconds to display time (default behavior). - Unit.currentTimeDisplayMode = tr.v.TimeDisplayModes.ms; - - assert.strictEqual(unit.format(0), '0.000 ms'); - assert.strictEqual(unit.format(0.02), '0.020 ms'); - assert.strictEqual(unit.format(0.001), '0.001 ms'); - assert.strictEqual(unit.format(0.0005), '0.001 ms'); - assert.strictEqual(unit.format(0.00049), '0.000 ms'); - assert.strictEqual(unit.format(999.999), '999.999 ms'); - assert.strictEqual(unit.format(1000.001), '1,000.001 ms'); - assert.strictEqual(unit.format(123456789), '123,456,789.000 ms'); - assert.strictEqual(unit.format(-0.00051), '-0.001 ms'); - assert.strictEqual(unit.format(-123456789), '-123,456,789.000 ms'); - - // Change the unit to nanoseconds. - Unit.currentTimeDisplayMode = tr.v.TimeDisplayModes.ns; - - assert.strictEqual(unit.format(0), '0 ns'); - assert.strictEqual(unit.format(1), '1,000,000 ns'); - assert.strictEqual(unit.format(0.000042), '42 ns'); - assert.strictEqual(unit.format(0.000001), '1 ns'); - assert.strictEqual(unit.format(0.0000005), '1 ns'); - assert.strictEqual(unit.format(0.00000049), '0 ns'); - assert.strictEqual(unit.format(123.456), '123,456,000 ns'); - assert.strictEqual(unit.format(-0.07), '-70,000 ns'); - } finally { - Unit.reset(); - } - } - - test('timeStampInMs', function() { - assert.strictEqual(Unit.byName.timeStampInMs.unitName, 'timeStampInMs'); - assert.strictEqual(Unit.byName.timeStampInMs.asJSON(), 'tsMs'); - checkTimeUnit(Unit.byName.timeStampInMs); - }); - - test('timeDurationInMs', function() { - assert.strictEqual(Unit.byName.timeDurationInMs.unitName, - 'timeDurationInMs'); - assert.strictEqual(Unit.byName.timeDurationInMs.asJSON(), 'ms'); - checkTimeUnit(Unit.byName.timeDurationInMs); - }); - - test('sizeInBytes', function() { - var SOURCE_VALUES = [0, 1, 1536, 424.5 * 1024 * 1024, - 1025 * 1024 * 1024 * 1024 * 1024, -2.5 * 1024 * 1024]; - var EXPECTED_REGULAR_FORMATTED_VALUES = ['0.0 B', '1.0 B', '1.5 KiB', - '424.5 MiB', '1,025.0 TiB', '-2.5 MiB']; - var EXPECTED_DELTA_FORMATTED_VALUES = ['\u00B10.0 B', '+1.0 B', '+1.5 KiB', - '+424.5 MiB', '+1,025.0 TiB', '-2.5 MiB']; - - function checkSizeUnit(unit, expectation) { - assert.strictEqual(unit.unitName, expectation.unitName); - assert.strictEqual(unit.asJSON(), expectation.asJSON); - assert.strictEqual(unit.isDelta, expectation.isDelta); - assert.strictEqual(unit.baseUnit, expectation.baseUnit); - assert.strictEqual(unit.correspondingDeltaUnit, - expectation.correspondingDeltaUnit); - assert.strictEqual(unit.improvementDirection, - expectation.improvementDirection); - assert.deepEqual(SOURCE_VALUES.map(v => unit.format(v)), - expectation.formattedValues); - } - - // Regular (non-delta). - checkSizeUnit(Unit.byName.sizeInBytes, { - unitName: 'sizeInBytes', - asJSON: 'sizeInBytes', - isDelta: false, - baseUnit: Unit.byName.sizeInBytes, - correspondingDeltaUnit: Unit.byName.sizeInBytesDelta, - improvementDirection: ImprovementDirection.DONT_CARE, - formattedValues: EXPECTED_REGULAR_FORMATTED_VALUES - }); - checkSizeUnit(Unit.byName.sizeInBytes_smallerIsBetter, { - unitName: 'sizeInBytes_smallerIsBetter', - asJSON: 'sizeInBytes_smallerIsBetter', - isDelta: false, - baseUnit: Unit.byName.sizeInBytes, - correspondingDeltaUnit: Unit.byName.sizeInBytesDelta_smallerIsBetter, - improvementDirection: ImprovementDirection.SMALLER_IS_BETTER, - formattedValues: EXPECTED_REGULAR_FORMATTED_VALUES - }); - checkSizeUnit(Unit.byName.sizeInBytes_biggerIsBetter, { - unitName: 'sizeInBytes_biggerIsBetter', - asJSON: 'sizeInBytes_biggerIsBetter', - isDelta: false, - baseUnit: Unit.byName.sizeInBytes, - correspondingDeltaUnit: Unit.byName.sizeInBytesDelta_biggerIsBetter, - improvementDirection: ImprovementDirection.BIGGER_IS_BETTER, - formattedValues: EXPECTED_REGULAR_FORMATTED_VALUES - }); - - // Delta. - checkSizeUnit(Unit.byName.sizeInBytesDelta, { - unitName: 'sizeInBytesDelta', - asJSON: 'sizeInBytesDelta', - isDelta: true, - baseUnit: Unit.byName.sizeInBytes, - correspondingDeltaUnit: Unit.byName.sizeInBytesDelta, - improvementDirection: ImprovementDirection.DONT_CARE, - formattedValues: EXPECTED_DELTA_FORMATTED_VALUES - }); - checkSizeUnit(Unit.byName.sizeInBytesDelta_smallerIsBetter, { - unitName: 'sizeInBytesDelta_smallerIsBetter', - asJSON: 'sizeInBytesDelta_smallerIsBetter', - isDelta: true, - baseUnit: Unit.byName.sizeInBytes, - correspondingDeltaUnit: Unit.byName.sizeInBytesDelta_smallerIsBetter, - improvementDirection: ImprovementDirection.SMALLER_IS_BETTER, - formattedValues: EXPECTED_DELTA_FORMATTED_VALUES - }); - checkSizeUnit(Unit.byName.sizeInBytesDelta_biggerIsBetter, { - unitName: 'sizeInBytesDelta_biggerIsBetter', - asJSON: 'sizeInBytesDelta_biggerIsBetter', - isDelta: true, - baseUnit: Unit.byName.sizeInBytes, - correspondingDeltaUnit: Unit.byName.sizeInBytesDelta_biggerIsBetter, - improvementDirection: ImprovementDirection.BIGGER_IS_BETTER, - formattedValues: EXPECTED_DELTA_FORMATTED_VALUES - }); - }); - - test('context', function() { - assert.strictEqual(Unit.byName.timeStampInMs.format(0, {}), '0.000 ms'); - assert.strictEqual(Unit.byName.normalizedPercentageDelta.format(1.23456, - { maximumFractionDigits: 2 }), '+123.46%'); - assert.strictEqual(Unit.byName.powerInWatts.format(999.999, - { minimumFractionDigits: 5 }), '999.99900 W'); - assert.strictEqual(Unit.byName.powerInWatts_biggerIsBetter.format(8.88, - { minimumFractionDigits: 1 }), '8.88 W'); - assert.strictEqual(Unit.byName.unitlessNumber.format(0.00789, - { maximumFractionDigits: 6 }), '0.00789'); - assert.strictEqual(Unit.byName.unitlessNumber.format(41.9, - { maximumFractionDigits: 0 }), '42'); - assert.strictEqual( - Unit.byName.energyInJoules.format(0.4444, - { minimumFractionDigits: 2, maximumFractionDigits: 3 }), - '0.444 J'); - assert.strictEqual( - Unit.byName.energyInJoules.format(0.6, - { minimumFractionDigits: 2, maximumFractionDigits: 3 }), - '0.60 J'); - assert.strictEqual( - Unit.byName.sizeInBytesDelta_smallerIsBetter.format(0, - { minimumFractionDigits: 1, maximumFractionDigits: 1 }), - '\u00B10.0 B'); - assert.strictEqual( - Unit.byName.sizeInBytes.format(25600000000, - { unitPrefix: UnitScale.Binary.KIBI }), - '25,000,000.0 KiB'); - assert.strictEqual( - Unit.byName.sizeInBytes.format(5243, - { unitPrefix: UnitScale.Binary.MEBI, minimumFractionDigits: 2 }), - '0.01 MiB'); - }); - - test('energyInJoules', function() { - assert.equal(Unit.byName.energyInJoules.format(1000), '1,000.000 J'); - assert.equal(Unit.byName.energyInJoules.format(1), '1.000 J'); - assert.equal(Unit.byName.energyInJoules.format(.005), '0.005 J'); - assert.equal(Unit.byName.energyInJoules.format(.0005), '0.001 J'); - assert.equal(Unit.byName.energyInJoules.format(.0004), '0.000 J'); - }); - - test('powerInWatts', function() { - assert.equal(Unit.byName.powerInWatts.format(1000), '1,000.000 W'); - assert.equal(Unit.byName.powerInWatts.format(1), '1.000 W'); - assert.equal(Unit.byName.powerInWatts.format(.001), '0.001 W'); - assert.equal(Unit.byName.powerInWatts.format(.001005), '0.001 W'); - }); - - test('unitlessNumber', function() { - assert.equal(Unit.byName.unitlessNumber.format(1), '1.000'); - assert.equal(Unit.byName.unitlessNumber.format(1.23), '1.230'); - assert.equal(Unit.byName.unitlessNumber.format(-1.23), '-1.230'); - assert.equal(Unit.byName.unitlessNumber.format(0), '0.000'); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/value.html b/chromium/third_party/catapult/tracing/tracing/value/value.html deleted file mode 100644 index 9b9c79052fb..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/value.html +++ /dev/null @@ -1,232 +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/iteration_helpers.html"> -<link rel="import" href="/tracing/base/utils.html"> -<link rel="import" href="/tracing/value/diagnostics/diagnostic_map.html"> - -<script> -'use strict'; - -tr.exportTo('tr.v', function() { - /** @constructor */ - function Value(name, opt_options) { - if (typeof(name) !== 'string') - throw new Error('name must be a string'); - - this.name_ = name; - - // If this Value is being deserialized, then its guid will be set by - // fromDict(). - // If this Value is being computed by a metric, then its guid will be - // allocated the first time the guid is gotten by asDict(). - this.guid_ = undefined; - - this.diagnostics = new tr.v.d.DiagnosticMap(); - - var options = opt_options || {}; - this.description = options.description; - this.important = options.important !== undefined ? - options.important : false; - } - - Value.fromDict = function(d) { - var value = undefined; - switch (d.type) { - case 'numeric': - value = NumericValue.fromDict(d); - break; - - case 'dict': - value = DictValue.fromDict(d); - break; - - case 'failure': - value = FailureValue.fromDict(d); - break; - - case 'skip': - value = SkipValue.fromDict(d); - break; - - default: - throw new Error('Not implemented'); - } - - value.guid = d.guid; - value.diagnostics.addDicts(d.diagnostics); - return value; - }; - - Value.prototype = { - get guid() { - if (this.guid_ === undefined) - this.guid_ = tr.b.GUID.allocateUUID4(); - - return this.guid_; - }, - - set guid(guid) { - if (this.guid_ !== undefined) - throw new Error('Cannot reset guid'); - - this.guid_ = guid; - }, - - get name() { - return this.name_; - }, - - asDict: function() { - return this.asJSON(); - }, - - asJSON: function() { - var d = { - guid: this.guid, - name: this.name_, - description: this.description, - important: this.important, - diagnostics: this.diagnostics.asDict() - }; - - this.asDictInto_(d); - if (d.type === undefined) - throw new Error('asDictInto_ must set type field'); - return d; - }, - - asDictInto_: function(d) { - throw new Error('Not implemented'); - } - }; - - /** @constructor */ - function NumericValue(name, numeric, opt_options) { - if (!(numeric instanceof tr.v.NumericBase)) - throw new Error('Expected numeric to be instance of tr.v.NumericBase'); - - Value.call(this, name, opt_options); - this.numeric = numeric; - } - - NumericValue.fromDict = function(d) { - if (d.numeric === undefined) - throw new Error('Expected numeric to be provided'); - var numeric = tr.v.NumericBase.fromDict(d.numeric); - var value = new NumericValue(d.name, numeric, d); - return value; - }; - - NumericValue.prototype = { - __proto__: Value.prototype, - - asDictInto_: function(d) { - d.type = 'numeric'; - d.numeric = this.numeric.asDict(); - } - }; - - /** @constructor */ - function DictValue(name, value, opt_options) { - Value.call(this, name, opt_options); - this.value = value; - } - - DictValue.fromDict = function(d) { - if (d.units !== undefined) - throw new Error('Expected units to be undefined'); - if (d.value === undefined) - throw new Error('Expected value to be provided'); - var value = new DictValue(d.name, d.value, d); - return value; - }; - - DictValue.prototype = { - __proto__: Value.prototype, - - asDictInto_: function(d) { - d.type = 'dict'; - d.value = this.value; - } - }; - - /** @constructor */ - function FailureValue(name, opt_options) { - var options = opt_options || {}; - - var stack; - if (options.stack === undefined) { - if (options.stack_str === undefined) { - throw new Error('Expected stack_str or stack to be provided'); - } else { - stack = options.stack_str; - } - } else { - stack = options.stack; - } - - if (typeof stack !== 'string') - throw new Error('stack must be provided as a string'); - - Value.call(this, name, options); - this.stack = stack; - } - - FailureValue.fromError = function(e) { - var ex = tr.b.normalizeException(e); - return new FailureValue(ex.typeName, { - description: ex.message, stack: ex.stack}); - }; - - FailureValue.fromDict = function(d) { - if (d.units !== undefined) - throw new Error('Expected units to be undefined'); - if (d.stack_str === undefined) - throw new Error('Expected stack_str to be provided'); - return new FailureValue(d.name, d); - }; - - FailureValue.prototype = { - __proto__: Value.prototype, - - asDictInto_: function(d) { - d.type = 'failure'; - d.stack_str = this.stack; - } - }; - - /** @constructor */ - function SkipValue(name, opt_options) { - Value.call(this, name, opt_options); - } - - SkipValue.fromDict = function(d) { - if (d.units !== undefined) - throw new Error('Expected units to be undefined'); - return new SkipValue(d.name, d); - }; - - SkipValue.prototype = { - __proto__: Value.prototype, - - asDictInto_: function(d) { - d.type = 'skip'; - } - }; - - - return { - Value: Value, - NumericValue: NumericValue, - DictValue: DictValue, - FailureValue: FailureValue, - SkipValue: SkipValue - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/value_set.html b/chromium/third_party/catapult/tracing/tracing/value/value_set.html deleted file mode 100644 index fe33b1fe898..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/value_set.html +++ /dev/null @@ -1,169 +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"> -<link rel="import" href="/tracing/value/numeric.html"> -<link rel="import" href="/tracing/value/unit.html"> -<link rel="import" href="/tracing/value/value.html"> - -<script> -'use strict'; - -tr.exportTo('tr.v', function() { - var SUMMARY_VALUE_MAP_DIAGNOSTIC_NAME = 'summary values'; - var ITERATION_INFO_DIAGNOSTIC_NAME = 'iteration'; - - function ValueSet(opt_values) { - this.values_ = {}; - - if (opt_values !== undefined) - opt_values.forEach(this.addValue, this); - } - - ValueSet.prototype = { - get valueDicts() { - return this.map(function(v) { - return v.asDict(); - }); - }, - - lookup: function(guid) { - return this.values_[guid]; - }, - - /** - * @param {!function(!tr.v.Value):*} callback - * @param {*=} opt_this - */ - map: function(callback, opt_this) { - return tr.b.dictionaryValues(this.values_).map( - callback, opt_this || this); - }, - - get organizedByName() { - return this.getValuesOrganizedByCallback(function(value) { - return value.name; - }); - }, - - /** - * @param {!function(!tr.v.Value):*} callback - * @param {*=} opt_this - * @return {!Object} - */ - getValuesOrganizedByCallback: function(callback, opt_this) { - var valuesByCallback = {}; - tr.b.iterItems(this.values_, function(guid, value) { - var key = callback.call(opt_this || this, value); - if (key === undefined) - return; - if (valuesByCallback[key] === undefined) - valuesByCallback[key] = []; - valuesByCallback[key].push(value); - }); - return valuesByCallback; - }, - - /** - * Convert Values from dicts and add them. - * Resolve RelatedValueSet references. - * - * @param {Array.<Object>} dicts - */ - addValuesFromDicts: function(dicts) { - dicts.forEach(function(dict) { - var value = tr.v.Value.fromDict(dict); - this.addValue(value); - }, this); - - // Now resolve the RelatedValueSet references between values. - // This resolution process must wait until all new values are added in - // case a value refers to another that comes after it in dicts. - // Iterate over all values, old and new, in case an old value contained a - // reference to a new value. Don't worry, resolve() is idempotent. - // The expected running time is this: for each value (hundreds to - // thousands?), for each diagnostic that is a RelatedValueSet (0-5?), for - // each ValueRef (0-10?), do a hash lookup (constant time?). - tr.b.iterItems(this.values_, function(guid, value) { - value.diagnostics.forEach(function(name, diagnostic) { - if ((diagnostic instanceof tr.v.d.RelatedValueSet) || - (diagnostic instanceof tr.v.d.RelatedValueMap)) - diagnostic.resolve(this); - }, this); - }, this); - }, - - /** - * Find the Values that are not contained in any other Values' - * RelatedValueSet or RelatedValueMap diagnostics. - * - * @return {!Array.<!tr.v.Value>} - */ - get sourceValues() { - var sourceValues = tr.b.cloneDictionary(this.values_); - // If a Value is in a RelatedValueSet or RelatedValueMap, then it is not a - // source Value. - this.map(function(value) { - value.diagnostics.forEach(function(name, diagnostic) { - if ((diagnostic instanceof tr.v.d.RelatedValueSet) || - (diagnostic instanceof tr.v.d.RelatedValueMap)) { - diagnostic.values.forEach(function(relatedValue) { - delete sourceValues[relatedValue.guid]; - }); - } - }, this); - }, this); - return tr.b.dictionaryValues(sourceValues); - }, - - getValuesWithName: function(name) { - return tr.b.dictionaryValues(this.values_).filter(function(value) { - return value.name.indexOf(name) > -1; - }); - }, - - addValue: function(v) { - if (this.values_[v.guid]) { - var err = new Error('Tried to add same value twice'); - err.name = 'ValueError'; - throw err; - } - - this.values_[v.guid] = v; - - if (v.numeric instanceof tr.v.Numeric) { - ValueSet.computeSummaryValuesForNumericValue(v).forEach(function(s) { - this.addValue(s); - }, this); - } - } - }; - - ValueSet.computeSummaryValuesForNumericValue = function(value) { - if (!(value instanceof tr.v.NumericValue && - value.numeric instanceof tr.v.Numeric)) - throw new Error('Tried to compute summary values for non-numeric'); - - var summaryValueMap = new tr.v.d.RelatedValueMap(); - value.diagnostics.add(SUMMARY_VALUE_MAP_DIAGNOSTIC_NAME, summaryValueMap); - var options = {description: value.description}; - var stats = value.numeric.getSummarizedScalarNumericsWithNames(); - return stats.map(function(stat) { - var summaryValue = new tr.v.NumericValue( - value.name + '_' + stat.name, stat.scalar, options); - summaryValueMap.set(stat.name, summaryValue); - return summaryValue; - }); - }; - - return { - SUMMARY_VALUE_MAP_DIAGNOSTIC_NAME: SUMMARY_VALUE_MAP_DIAGNOSTIC_NAME, - ITERATION_INFO_DIAGNOSTIC_NAME: ITERATION_INFO_DIAGNOSTIC_NAME, - ValueSet: ValueSet - }; -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/value_set_test.html b/chromium/third_party/catapult/tracing/tracing/value/value_set_test.html deleted file mode 100644 index a1b48e5e864..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/value_set_test.html +++ /dev/null @@ -1,180 +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/range.html"> -<link rel="import" href="/tracing/value/numeric.html"> -<link rel="import" href="/tracing/value/unit.html"> -<link rel="import" href="/tracing/value/value_set.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('computeSummaryValuesForNumericValue', function() { - var n = tr.v.NumericBuilder.createLinear( - tr.v.Unit.byName.timeDurationInMs, tr.b.Range.fromExplicitRange(0, 100), - 100).build(); - - n.add(50); - n.add(60); - n.add(70); - - n.customizeSummaryOptions({ - count: true, - min: true, - max: true, - sum: true, - avg: true, - std: true, - percentile: [0.5, 1] - }); - - var results = - tr.v.ValueSet.computeSummaryValuesForNumericValue( - new tr.v.NumericValue('abc', n, { description: 'desc' })); - var values = {}; - results.forEach(function(x) { - values[x.name] = x.numeric; - }); - assert.strictEqual(values.abc_count.value, 3); - assert.strictEqual(values.abc_min.value, 50); - assert.strictEqual(values.abc_max.value, 70); - assert.strictEqual(values.abc_sum.value, 180); - assert.strictEqual(values.abc_avg.value, 60); - assert.strictEqual(values.abc_std.value, 10); - assert.closeTo(values.abc_pct_050.value, 60, 1); - assert.closeTo(values.abc_pct_100.value, 70, 1); - }); - - test('relatedValueSetDiagnostic', function() { - var unit = tr.v.Unit.byName.unitlessNumber; - var a = new tr.v.NumericValue('a', new tr.v.ScalarNumeric(unit, 0)); - var b = new tr.v.NumericValue('b', new tr.v.ScalarNumeric(unit, 1)); - var c = new tr.v.NumericValue('c', new tr.v.ScalarNumeric(unit, 2)); - a.diagnostics.add('rvs', new tr.v.d.RelatedValueSet([b, c])); - - // Don't serialize c just yet. - var values = new tr.v.ValueSet([a, b]); - - var sourceValues = values.sourceValues; - assert.lengthOf(sourceValues, 1); - assert.strictEqual(sourceValues[0], a); - - var values2 = new tr.v.ValueSet(); - values2.addValuesFromDicts(values.valueDicts); - - var a2 = values2.getValuesWithName('a'); - assert.lengthOf(a2, 1); - a2 = a2[0]; - assert.strictEqual(a2.guid, a.guid); - assert.instanceOf(a2, tr.v.Value); - assert.notStrictEqual(a2, a); - - var b2 = values2.getValuesWithName('b'); - assert.lengthOf(b2, 1); - b2 = b2[0]; - assert.strictEqual(b2.guid, b.guid); - assert.instanceOf(b2, tr.v.Value); - assert.notStrictEqual(b2, b); - - var rvs2 = a2.diagnostics.get('rvs'); - assert.instanceOf(rvs2, tr.v.d.RelatedValueSet); - assert.lengthOf(rvs2.values, 2); - - // Assert that b and c are in a2's RelatedValueSet. - var rvs2vs = rvs2.values; - var rvs2guids = rvs2vs.map(v => v.guid); - var b2i = rvs2guids.indexOf(b.guid); - assert.strictEqual(rvs2vs[b2i], b2); - - var c2i = rvs2guids.indexOf(c.guid); - assert.strictEqual(rvs2vs[c2i].guid, c.guid); - assert.instanceOf(rvs2vs[c2i], tr.v.d.ValueRef); - - // Now serialize c and add it to values2. - // Related value resolution is idempotent. - // Old values can refer to new values. - values2.addValuesFromDicts([c.asDict()]); - - var c2 = values2.getValuesWithName('c'); - assert.lengthOf(c2, 1); - c2 = c2[0]; - assert.strictEqual(c2.guid, c.guid); - assert.notStrictEqual(c2, c); - - // Now a real c2 Value should be in a2's RelatedValueSet. - rvs2vs = rvs2.values; - rvs2guids = rvs2vs.map(v => v.guid); - b2i = rvs2guids.indexOf(b.guid); - c2i = rvs2guids.indexOf(c.guid); - assert.strictEqual(b2, rvs2vs[b2i]); - assert.strictEqual(c2, rvs2vs[c2i]); - }); - - test('relatedValueMapDiagnostic', function() { - var unit = tr.v.Unit.byName.unitlessNumber; - var a = new tr.v.NumericValue('a', new tr.v.ScalarNumeric(unit, 0)); - var b = new tr.v.NumericValue('b', new tr.v.ScalarNumeric(unit, 1)); - var c = new tr.v.NumericValue('c', new tr.v.ScalarNumeric(unit, 2)); - var rvm = new tr.v.d.RelatedValueMap(); - rvm.set('y', b); - rvm.set('z', c); - a.diagnostics.add('rvm', rvm); - - // Don't serialize c just yet. - var values = new tr.v.ValueSet([a, b]); - - var sourceValues = values.sourceValues; - assert.lengthOf(sourceValues, 1); - assert.strictEqual(sourceValues[0], a); - - var values2 = new tr.v.ValueSet(); - values2.addValuesFromDicts(values.valueDicts); - - var a2 = values2.getValuesWithName('a'); - assert.lengthOf(a2, 1); - a2 = a2[0]; - assert.strictEqual(a2.guid, a.guid); - assert.instanceOf(a2, tr.v.Value); - assert.notStrictEqual(a2, a); - - var b2 = values2.getValuesWithName('b'); - assert.lengthOf(b2, 1); - b2 = b2[0]; - assert.strictEqual(b2.guid, b.guid); - assert.instanceOf(b2, tr.v.Value); - assert.notStrictEqual(b2, b); - - var rvm2 = a2.diagnostics.get('rvm'); - assert.instanceOf(rvm2, tr.v.d.RelatedValueMap); - assert.lengthOf(rvm2.values, 2); - - // Assert that b and c are in a2's RelatedValueMap. - // |c| should still be a ValueRef since it wasn't in values2. - assert.strictEqual(rvm2.get('y'), b2); - assert.instanceOf(rvm2.get('z'), tr.v.d.ValueRef); - - // Now serialize c and add it to values2. - // Related value resolution is idempotent. - // Old values can refer to new values. - values2.addValuesFromDicts([c.asDict()]); - - var c2 = values2.getValuesWithName('c'); - assert.lengthOf(c2, 1); - c2 = c2[0]; - assert.strictEqual(c2.guid, c.guid); - assert.instanceOf(c2, tr.v.Value); - assert.notStrictEqual(c2, c); - - // b2 should still be in a2's RelatedValueMap. - assert.strictEqual(rvm2.get('y'), b2); - - // Now a real c2 Value should be in a2's RelatedValueMap. - assert.strictEqual(rvm2.get('z'), c2); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/value_test.html b/chromium/third_party/catapult/tracing/tracing/value/value_test.html deleted file mode 100644 index 07e73b030ee..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/value_test.html +++ /dev/null @@ -1,92 +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/utils.html"> -<link rel="import" href="/tracing/value/numeric.html"> -<link rel="import" href="/tracing/value/unit.html"> -<link rel="import" href="/tracing/value/value.html"> - -<script> -'use strict'; - -tr.b.unittest.testSuite(function() { - test('numericValueBasic', function() { - var n = new tr.v.ScalarNumeric(tr.v.Unit.byName.sizeInBytes, 314); - var v = new tr.v.NumericValue('MyNumeric', n); - assert.isDefined(v.guid); - var d = v.asDict(); - - var v2 = tr.v.Value.fromDict(d); - assert.instanceOf(v2, tr.v.NumericValue); - assert.equal(v.guid, v2.guid); - assert.equal(v.name, v2.name); - assert.equal(v.numeric.value, v2.numeric.value); - }); - - test('dictValueBasic', function() { - var v = new tr.v.DictValue('MyDict', {my_key: 'my_value'}); - assert.isDefined(v.guid); - var d = v.asDict(); - - var v2 = tr.v.Value.fromDict(d); - assert.instanceOf(v2, tr.v.DictValue); - assert.equal(v.guid, v2.guid); - assert.deepEqual(v.value, v2.value); - }); - - test('failureValueBasic', function() { - var v = new tr.v.FailureValue( - 'MyFailure', - {description: 'Description', stack: tr.b.stackTraceAsString()}); - assert.isDefined(v.guid); - var d = v.asDict(); - - var v2 = tr.v.Value.fromDict(d); - assert.instanceOf(v2, tr.v.FailureValue); - assert.equal(v.guid, v2.guid); - assert.equal(v.name, v2.name); - assert.equal(v.description, v2.description); - assert.equal(v.stack, v2.stack); - }); - - test('skipValueBasic', function() { - var v = new tr.v.SkipValue('MySkip', - {description: 'WhySkipped'}); - assert.isDefined(v.guid); - var d = v.asDict(); - - var v2 = tr.v.Value.fromDict(d); - assert.equal(v.guid, v2.guid); - assert.instanceOf(v2, tr.v.SkipValue); - assert.equal(v.description, v2.description); - }); - - test('genericDiagnostic', function() { - var skip = new tr.v.SkipValue('skip'); - skip.diagnostics.add('foo', new tr.v.d.Generic({ - t: true, - f: false, - z: 0, - o: 1, - ans: 0.42, - s: 'string', - a: [42.42, 'more string'], - d: {a: {b: 'c'}} - })); - var skip2 = tr.v.Value.fromDict(skip.asDict()); - var foo2 = skip2.diagnostics.get('foo'); - assert.strictEqual(true, foo2.value.t); - assert.strictEqual(false, foo2.value.f); - assert.strictEqual(0, foo2.value.z); - assert.strictEqual(1, foo2.value.o); - assert.strictEqual(0.42, foo2.value.ans); - assert.strictEqual('string', foo2.value.s); - assert.deepEqual([42.42, 'more string'], foo2.value.a); - assert.deepEqual({a: {b: 'c'}}, foo2.value.d); - }); -}); -</script> diff --git a/chromium/third_party/catapult/tracing/tracing/value/value_unittest.py b/chromium/third_party/catapult/tracing/tracing/value/value_unittest.py deleted file mode 100644 index 88ffbc32382..00000000000 --- a/chromium/third_party/catapult/tracing/tracing/value/value_unittest.py +++ /dev/null @@ -1,52 +0,0 @@ -# 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. -import unittest - -from tracing import value as value_module - - -class ValueTests(unittest.TestCase): - - def testScalar(self): - d = { - 'canonical_url': '/a.json', - 'type': 'scalar', - 'name': 'MyScalarValue', - 'important': False, - 'value': {'a': 1, 'b': 'b'} - } - v = value_module.Value.FromDict(d) - self.assertTrue(isinstance(v, value_module.ScalarValue)) - d2 = v.AsDict() - - self.assertEquals(d, d2) - - def testDict(self): - d = { - 'canonical_url': '/a.json', - 'type': 'dict', - 'name': 'MyDictValue', - 'important': False, - 'value': {'a': 1, 'b': 'b'} - } - v = value_module.Value.FromDict(d) - self.assertTrue(isinstance(v, value_module.DictValue)) - d2 = v.AsDict() - - self.assertEquals(d, d2) - - def testFailure(self): - d = { - 'canonical_url': '/a.json', - 'type': 'failure', - 'name': 'Error', - 'important': False, - 'description': 'Some error message', - 'stack_str': 'Some stack string' - } - v = value_module.Value.FromDict(d) - self.assertTrue(isinstance(v, value_module.FailureValue)) - d2 = v.AsDict() - - self.assertEquals(d, d2) |