export function printTime (t) { let time = Number(t) let units = ['n', 'μ', 'm', 'c', 's'] let unit = units[0] let unitPower = 1 for (let i = 0; i < units.length; i++) { let power = Math.pow(10, (i + 1) * 3) if (power * 2 > time) { break } unitPower = power unit = units[i] } console.log(t, '=', Number((time / unitPower).toFixed(2)), unit) }