3 class Metric extends LabeledObject {
4 constructor(id, object)
7 this._aggregatorName = object.aggregator;
8 object.test.addMetric(this);
9 this._test = object.test;
13 aggregatorName() { return this._aggregatorName; }
15 test() { return this._test; }
16 platforms() { return this._platforms; }
20 console.assert(platform instanceof Platform);
21 this._platforms.push(platform);
27 for (var childTest of this._test.childTests()) {
28 for (var childMetric of childTest.metrics())
29 metrics.push(childMetric);
34 path() { return this._test.path().concat([this]); }
36 fullName() { return this._test.fullName() + ' : ' + this.label(); }
41 switch (this._aggregatorName) {
45 suffix = ' : Arithmetic mean';
48 suffix = ' : Geometric mean';
51 suffix = ' : Harmonic mean';
55 suffix = ' : ' + this._aggregatorName;
57 return this.name() + suffix;
60 unit() { return RunsData.unitFromMetricName(this.name()); }
61 isSmallerBetter() { return RunsData.isSmallerBetter(this.unit()); }
63 makeFormatter(sigFig, alwaysShowSign)
65 var unit = this.unit();
66 var isMiliseconds = false;
73 return function (value) { return value.toFixed(2) + ' ' + (unit || ''); }
75 var divisor = unit == 'B' ? 1024 : 1000;
76 var suffix = ['\u03BC', 'm', '', 'K', 'M', 'G', 'T', 'P', 'E'];
77 var threshold = sigFig >= 3 ? divisor : (divisor / 10);
78 return function (value) {
80 var sign = value >= 0 ? (alwaysShowSign ? '+' : '') : '-';
81 value = Math.abs(value);
82 for (i = isMiliseconds ? 1 : 2; value < 1 && i > 0; i--)
84 for (; value >= threshold; i++)
86 return sign + value.toPrecision(Math.max(2, sigFig)) + ' ' + suffix[i] + (unit || '');
91 if (typeof module != 'undefined')
92 module.exports.Metric = Metric;