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; |
} |
} |