| 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/math/range.html"> | 8 <link rel="import" href="/tracing/base/math/range.html"> |
| 9 <link rel="import" href="/tracing/base/math/running_statistics.html"> | 9 <link rel="import" href="/tracing/base/math/running_statistics.html"> |
| 10 <link rel="import" href="/tracing/base/math/statistics.html"> | 10 <link rel="import" href="/tracing/base/math/statistics.html"> |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 /** | 637 /** |
| 638 * @param {string} statName | 638 * @param {string} statName |
| 639 * @param {!tr.v.Histogram=} opt_referenceHistogram | 639 * @param {!tr.v.Histogram=} opt_referenceHistogram |
| 640 * @param {!HypothesisTestResult=} opt_mwu | 640 * @param {!HypothesisTestResult=} opt_mwu |
| 641 * @return {!tr.b.Scalar} | 641 * @return {!tr.b.Scalar} |
| 642 * @throws {Error} When statName is not recognized, such as delta statistics | 642 * @throws {Error} When statName is not recognized, such as delta statistics |
| 643 * when !this.canCompare(opt_referenceHistograms). | 643 * when !this.canCompare(opt_referenceHistograms). |
| 644 */ | 644 */ |
| 645 getStatisticScalar(statName, opt_referenceHistogram, opt_mwu) { | 645 getStatisticScalar(statName, opt_referenceHistogram, opt_mwu) { |
| 646 if (statName === 'avg') { | 646 if (statName === 'avg') { |
| 647 if (this.running_ === undefined) return undefined; | 647 if (typeof(this.average) !== 'number') return undefined; |
| 648 return new tr.b.Scalar(this.unit, this.average); | 648 return new tr.b.Scalar(this.unit, this.average); |
| 649 } | 649 } |
| 650 if (statName === 'std') { | 650 if (statName === 'std') { |
| 651 if (this.standardDeviation === undefined) return undefined; | 651 if (typeof(this.standardDeviation) !== 'number') return undefined; |
| 652 return new tr.b.Scalar(this.unit, this.standardDeviation); | 652 return new tr.b.Scalar(this.unit, this.standardDeviation); |
| 653 } | 653 } |
| 654 if (statName === 'geometricMean') { | 654 if (statName === 'geometricMean') { |
| 655 if (typeof(this.geometricMean) !== 'number') return undefined; |
| 655 return new tr.b.Scalar(this.unit, this.geometricMean); | 656 return new tr.b.Scalar(this.unit, this.geometricMean); |
| 656 } | 657 } |
| 657 if (statName === 'min' || statName === 'max' || statName === 'sum') { | 658 if (statName === 'min' || statName === 'max' || statName === 'sum') { |
| 658 if (this.running_ === undefined) { | 659 if (this.running_ === undefined) { |
| 659 this.running_ = new tr.b.math.RunningStatistics(); | 660 this.running_ = new tr.b.math.RunningStatistics(); |
| 660 } | 661 } |
| 662 if (typeof(this.running_[statName]) !== 'number') return undefined; |
| 661 return new tr.b.Scalar(this.unit, this.running_[statName]); | 663 return new tr.b.Scalar(this.unit, this.running_[statName]); |
| 662 } | 664 } |
| 663 if (statName === 'nans') { | 665 if (statName === 'nans') { |
| 664 return new tr.b.Scalar( | 666 return new tr.b.Scalar( |
| 665 tr.b.Unit.byName.count_smallerIsBetter, this.numNans); | 667 tr.b.Unit.byName.count_smallerIsBetter, this.numNans); |
| 666 } | 668 } |
| 667 if (statName === 'count') { | 669 if (statName === 'count') { |
| 668 return new tr.b.Scalar( | 670 return new tr.b.Scalar( |
| 669 tr.b.Unit.byName.count_smallerIsBetter, this.numValues); | 671 tr.b.Unit.byName.count_smallerIsBetter, this.numValues); |
| 670 } | 672 } |
| 671 if (statName.substr(0, 4) === 'pct_') { | 673 if (statName.substr(0, 4) === 'pct_') { |
| 672 const percent = percentFromString(statName.substr(4)); | 674 const percent = percentFromString(statName.substr(4)); |
| 673 if (this.numValues === 0) return undefined; | 675 if (this.numValues === 0) return undefined; |
| 674 const percentile = this.getApproximatePercentile(percent); | 676 const percentile = this.getApproximatePercentile(percent); |
| 677 if (typeof(percentile) !== 'number') return undefined; |
| 675 return new tr.b.Scalar(this.unit, percentile); | 678 return new tr.b.Scalar(this.unit, percentile); |
| 676 } | 679 } |
| 677 if (statName.substr(0, 4) === 'ipr_') { | 680 if (statName.substr(0, 4) === 'ipr_') { |
| 678 let lower = percentFromString(statName.substr(4, 3)); | 681 let lower = percentFromString(statName.substr(4, 3)); |
| 679 let upper = percentFromString(statName.substr(8)); | 682 let upper = percentFromString(statName.substr(8)); |
| 680 if (lower >= upper) { | 683 if (lower >= upper) { |
| 681 throw new Error('Invalid inter-percentile range: ' + statName); | 684 throw new Error('Invalid inter-percentile range: ' + statName); |
| 682 } | 685 } |
| 683 lower = this.getApproximatePercentile(lower); | 686 lower = this.getApproximatePercentile(lower); |
| 684 upper = this.getApproximatePercentile(upper); | 687 upper = this.getApproximatePercentile(upper); |
| 685 return new tr.b.Scalar(this.unit, upper - lower); | 688 const ipr = upper - lower; |
| 689 if (typeof(ipr) !== 'number') return undefined; |
| 690 return new tr.b.Scalar(this.unit, ipr); |
| 686 } | 691 } |
| 687 | 692 |
| 688 if (!this.canCompare(opt_referenceHistogram)) { | 693 if (!this.canCompare(opt_referenceHistogram)) { |
| 689 throw new Error( | 694 throw new Error( |
| 690 'Cannot compute ' + statName + | 695 'Cannot compute ' + statName + |
| 691 ' when histograms are not comparable'); | 696 ' when histograms are not comparable'); |
| 692 } | 697 } |
| 693 | 698 |
| 694 const suffix = tr.b.Unit.nameSuffixForImprovementDirection( | 699 const suffix = tr.b.Unit.nameSuffixForImprovementDirection( |
| 695 this.unit.improvementDirection); | 700 this.unit.improvementDirection); |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1420 Histogram, | 1425 Histogram, |
| 1421 HistogramBinBoundaries, | 1426 HistogramBinBoundaries, |
| 1422 P_VALUE_NAME, | 1427 P_VALUE_NAME, |
| 1423 U_STATISTIC_NAME, | 1428 U_STATISTIC_NAME, |
| 1424 Z_SCORE_NAME, | 1429 Z_SCORE_NAME, |
| 1425 percentFromString, | 1430 percentFromString, |
| 1426 percentToString, | 1431 percentToString, |
| 1427 }; | 1432 }; |
| 1428 }); | 1433 }); |
| 1429 </script> | 1434 </script> |
| OLD | NEW |