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

Unified Diff: tracing/tracing/base/running_statistics.html

Issue 2364243002: Serialize Histograms more efficiently. (Closed)
Patch Set: RunningStatistics.asDict undefined Created 4 years, 3 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
Index: tracing/tracing/base/running_statistics.html
diff --git a/tracing/tracing/base/running_statistics.html b/tracing/tracing/base/running_statistics.html
index 019e40ca4d27ff32ff7577d843b2be2848a94551..25d27e70bc4882a89fa7bb99caf7fdc3f08958ae 100644
--- a/tracing/tracing/base/running_statistics.html
+++ b/tracing/tracing/base/running_statistics.html
@@ -138,26 +138,37 @@ tr.exportTo('tr.b', function() {
}
asDict() {
- return {
- mean: this.mean,
- meanlogs: this.meanlogs_,
- count: this.count,
- max: this.max,
- min: this.min,
- sum: this.sum,
- variance: this.variance_
- };
+ if (!this.count) {
+ return undefined;
nednguyen 2016/09/27 18:48:53 JSON.stringify(undefined) --> undefined, so I thin
benjhayden 2016/09/27 21:50:11 https://github.com/catapult-project/catapult/blob/
+ }
+ // It's more efficient to serialize these fields in an array. If you
+ // add any other fields, you should re-evaluate whether it would be more
+ // efficient to serialize as a dict.
+ return [
+ this.count_,
+ this.max_,
+ this.meanlogs_,
+ this.mean_,
+ this.min_,
+ this.sum_,
+ this.variance_,
+ ];
}
- static fromDict(d) {
+ static fromDict(dict) {
var result = new RunningStatistics();
- result.mean_ = d.mean;
- result.count_ = d.count;
- result.max_ = d.max;
- result.min_ = d.min;
- result.sum_ = d.sum;
- result.variance_ = d.variance;
- result.meanlogs_ = d.meanlogs;
+ if (!dict) {
+ return result;
+ }
+ [
+ result.count_,
+ result.max_,
+ result.meanlogs_,
+ result.mean_,
+ result.min_,
+ result.sum_,
+ result.variance_,
+ ] = dict;
return result;
}
}
« no previous file with comments | « no previous file | tracing/tracing/base/running_statistics_test.html » ('j') | tracing/tracing/value/histogram.html » ('J')

Powered by Google App Engine
This is Rietveld 408576698