Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Unified Diff: tracing/tracing/metrics/value_set.html

Issue 2000063006: Define DiagnosticMap and a basic Diagnostic hierarchy (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tracing/tracing/metrics/v8/gc_metric_test.html ('k') | tracing/tracing/metrics/value_set_test.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/metrics/value_set.html
diff --git a/tracing/tracing/metrics/value_set.html b/tracing/tracing/metrics/value_set.html
index b8fce24bb4e8b742ffb2a7d8fe5feeb7812a1f42..b1f2acbffd8e043728b0159414e3089e73e73693 100644
--- a/tracing/tracing/metrics/value_set.html
+++ b/tracing/tracing/metrics/value_set.html
@@ -14,10 +14,11 @@ found in the LICENSE file.
'use strict';
tr.exportTo('tr.metrics', function() {
- function ValueSet(values) {
+ function ValueSet(opt_values) {
this.values_ = {};
- if (values !== undefined)
- values.forEach(this.addValue, this);
+
+ if (opt_values !== undefined)
+ opt_values.forEach(this.addValue, this);
}
ValueSet.prototype = {
@@ -27,15 +28,39 @@ tr.exportTo('tr.metrics', function() {
});
},
+ lookup: function(guid) {
+ return this.values_[guid];
+ },
+
map: function(cb, opt_this) {
return tr.b.dictionaryValues(this.values_).map(cb, opt_this);
},
- addValueDicts: function(dicts) {
+ /**
+ * 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);
- // TODO(TBMv2.1): Patch up RelatedValueSets here.
+ }, 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.resolve(this);
+ }, this);
}, this);
},
@@ -76,7 +101,7 @@ tr.exportTo('tr.metrics', function() {
return value.numeric.getSummarizedScalarNumericsWithNames().map(
function(stat) {
return new tr.v.NumericValue(
- value.canonicalUrl, value.name + '_' + stat.name, stat.scalar,
+ value.name + '_' + stat.name, stat.scalar,
{ description: value.description });
});
};
« no previous file with comments | « tracing/tracing/metrics/v8/gc_metric_test.html ('k') | tracing/tracing/metrics/value_set_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698