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

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

Issue 2258583003: Modernize DiagnosticMap to subclass ES6 Map. (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: fix longTasksMetric and Composition Created 4 years, 4 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/value/ui/value_set_table.html ('k') | tracing/tracing/value/value_set_test.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/value/value_set.html
diff --git a/tracing/tracing/value/value_set.html b/tracing/tracing/value/value_set.html
index 90f533a8e0704bef7716576403ba55720ec90432..81c350d1a64d796a8e2d914e2de1eec87e517dc6 100644
--- a/tracing/tracing/value/value_set.html
+++ b/tracing/tracing/value/value_set.html
@@ -20,7 +20,8 @@ tr.exportTo('tr.v', function() {
this.values_ = {};
if (opt_values !== undefined)
- opt_values.forEach(this.addValue, this);
+ for (var value of opt_values)
+ this.addValue(value);
}
get valueDicts() {
@@ -68,10 +69,8 @@ tr.exportTo('tr.v', function() {
* @param {Array.<Object>} dicts
*/
addValuesFromDicts(dicts) {
- dicts.forEach(function(dict) {
- var value = tr.v.Value.fromDict(dict);
- this.addValueInternal_(value);
- }, this);
+ for (var dict of dicts)
+ this.addValueInternal_(tr.v.Value.fromDict(dict));
// Now resolve the RelatedValueSet references between values.
// This resolution process must wait until all new values are added in
@@ -81,26 +80,29 @@ tr.exportTo('tr.v', function() {
// 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) {
+ for (var value of this) {
+ for (var [name, diagnostic] of value.diagnostics) {
if ((diagnostic instanceof tr.v.d.RelatedValueSet) ||
- (diagnostic instanceof tr.v.d.RelatedValueMap))
+ (diagnostic instanceof tr.v.d.RelatedValueMap)) {
diagnostic.resolve(this);
- }, this);
+ }
+ }
- // In addition Values, we must also look inside of Histogram samples.
+ // In addition to Values, we must also look inside of Histogram samples.
if (value instanceof tr.v.NumericValue &&
- value.numeric instanceof tr.v.Histogram)
- value.numeric.allBins.forEach(function(b) {
- b.diagnosticMaps.forEach(function(dm) {
- dm.forEach(function(d) {
+ value.numeric instanceof tr.v.Histogram) {
+ for (var bin of value.numeric.allBins) {
+ for (var dm of bin.diagnosticMaps) {
+ for (var [name, diagnostic] of dm) {
if ((d instanceof tr.v.d.RelatedValueSet) ||
- (d instanceof tr.v.d.RelatedValueMap))
+ (d instanceof tr.v.d.RelatedValueMap)) {
d.resolve(this);
- }, this);
- }, this);
- }, this);
- }, this);
+ }
+ }
+ }
+ }
+ }
+ }
}
/**
@@ -115,14 +117,14 @@ tr.exportTo('tr.v', function() {
// owned either by Values or by numeric samples, then it is not a
// source Value.
function deleteSourceValues(values, diagnosticMap) {
- diagnosticMap.forEach(function(unused_name, diagnostic) {
+ for (var [name, diagnostic] of diagnosticMap) {
if (diagnostic instanceof tr.v.d.RelatedValueSet)
for (var relatedValue of diagnostic)
delete values[relatedValue.guid];
else if (diagnostic instanceof tr.v.d.RelatedValueMap)
for (var [name, relatedValue] of diagnostic)
delete values[relatedValue.guid];
- });
+ }
}
this.map(function(value) {
@@ -160,9 +162,8 @@ tr.exportTo('tr.v', function() {
this.addValueInternal_(v);
if (v.numeric instanceof tr.v.Histogram) {
- ValueSet.computeSummaryValuesForNumericValue(v).forEach(function(s) {
+ for (var s of ValueSet.computeSummaryValuesForNumericValue(v))
this.addValue(s);
- }, this);
}
}
@@ -172,7 +173,7 @@ tr.exportTo('tr.v', function() {
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);
+ value.diagnostics.set(SUMMARY_VALUE_MAP_DIAGNOSTIC_NAME, summaryValueMap);
var options = {description: value.description};
var stats = value.numeric.getSummarizedScalarNumericsWithNames();
return stats.map(function(stat) {
« no previous file with comments | « tracing/tracing/value/ui/value_set_table.html ('k') | tracing/tracing/value/value_set_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698