in resources/perf.webkit.org/public/v3/models/metric.js [114:135]
let formatter = function (value, maxAbsValue = 0) {
var i;
var sign = value >= 0 ? (alwaysShowSign ? '+' : '') : '-';
value = Math.abs(value);
let sigFigForValue = sigFig;
// The number of sig-figs to reduce in order to match that of maxAbsValue
// e.g. 0.5 instead of 0.50 when maxAbsValue is 2.
let adjustment = 0;
if (maxAbsValue && value)
adjustment = Math.max(0, Math.floor(Math.log(maxAbsValue) / Math.log(10)) - Math.floor(Math.log(value) / Math.log(10)));
for (i = isMiliseconds ? 1 : 2; value && value < 1 && i > 0; i--)
value *= divisor;
for (; value >= threshold; i++)
value /= divisor;
if (adjustment) // Make the adjustment only for decimal positions below 1.
adjustment = Math.min(adjustment, Math.max(0, -Math.floor(Math.log(value) / Math.log(10))));
return sign + value.toPrecision(sigFig - adjustment) + ' ' + suffix[i] + (unit || '');
}