Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <!-- | 2 <!-- |
| 3 Copyright 2016 The Chromium Authors. All rights reserved. | 3 Copyright 2016 The Chromium Authors. All rights reserved. |
| 4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
| 5 found in the LICENSE file. | 5 found in the LICENSE file. |
| 6 --> | 6 --> |
| 7 | 7 |
| 8 <link rel="import" href="/tracing/base/base.html"> | 8 <link rel="import" href="/tracing/base/base.html"> |
| 9 | 9 |
| 10 <script> | 10 <script> |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 result.meanlogs_ = undefined; | 131 result.meanlogs_ = undefined; |
| 132 } else { | 132 } else { |
| 133 result.meanlogs_ = (this.count * this.meanlogs_ + | 133 result.meanlogs_ = (this.count * this.meanlogs_ + |
| 134 other.count * other.meanlogs_) / result.count; | 134 other.count * other.meanlogs_) / result.count; |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 return result; | 137 return result; |
| 138 } | 138 } |
| 139 | 139 |
| 140 asDict() { | 140 asDict() { |
| 141 return { | 141 if (!this.count) { |
| 142 mean: this.mean, | 142 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/
| |
| 143 meanlogs: this.meanlogs_, | 143 } |
| 144 count: this.count, | 144 // It's more efficient to serialize these fields in an array. If you |
| 145 max: this.max, | 145 // add any other fields, you should re-evaluate whether it would be more |
| 146 min: this.min, | 146 // efficient to serialize as a dict. |
| 147 sum: this.sum, | 147 return [ |
| 148 variance: this.variance_ | 148 this.count_, |
| 149 }; | 149 this.max_, |
| 150 this.meanlogs_, | |
| 151 this.mean_, | |
| 152 this.min_, | |
| 153 this.sum_, | |
| 154 this.variance_, | |
| 155 ]; | |
| 150 } | 156 } |
| 151 | 157 |
| 152 static fromDict(d) { | 158 static fromDict(dict) { |
| 153 var result = new RunningStatistics(); | 159 var result = new RunningStatistics(); |
| 154 result.mean_ = d.mean; | 160 if (!dict) { |
| 155 result.count_ = d.count; | 161 return result; |
| 156 result.max_ = d.max; | 162 } |
| 157 result.min_ = d.min; | 163 [ |
| 158 result.sum_ = d.sum; | 164 result.count_, |
| 159 result.variance_ = d.variance; | 165 result.max_, |
| 160 result.meanlogs_ = d.meanlogs; | 166 result.meanlogs_, |
| 167 result.mean_, | |
| 168 result.min_, | |
| 169 result.sum_, | |
| 170 result.variance_, | |
| 171 ] = dict; | |
| 161 return result; | 172 return result; |
| 162 } | 173 } |
| 163 } | 174 } |
| 164 | 175 |
| 165 return { | 176 return { |
| 166 RunningStatistics: RunningStatistics | 177 RunningStatistics: RunningStatistics |
| 167 }; | 178 }; |
| 168 }); | 179 }); |
| 169 </script> | 180 </script> |
| OLD | NEW |