Skip to content

Commit

Permalink
user timing CLI formatter: more concise output.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Sep 16, 2016
1 parent 9a7a728 commit 73ea8c6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
21 changes: 9 additions & 12 deletions lighthouse-core/formatters/user-timings.js
Expand Up @@ -31,19 +31,16 @@ class UserTimings extends Formatter {
return '';
}

const output = ` - performance.measure events created by the site\n` +
events.reduce((prev, event) => {
let output = prev + ` - ${event.isMark ? 'Mark' : 'Measure'}: ${event.name}\n` +
' - Start Time: ' + event.startTime.toFixed(2) + 'ms\n';
if (!event.isMark) {
output += ' - End Time: ' + event.endTime.toFixed(2) + '\n' +
' - Duration: ' + event.duration.toFixed(2) + 'ms\n';
}

return output;
const measuresStr = events.filter(e => !e.isMark).reduce((prev, event) => {
let output = prev + ` - measure ${event.name}: \t`;
output += `duration: ${event.duration.toFixed(1)}ms,\t`;
output += `start: ${event.startTime.toFixed(1)}ms,\tend: ${event.endTime.toFixed(1)}`;
return output + '\n';
}, '');

return output;
const marksStr = events.filter(e => e.isMark).reduce((prev, event) => {
return prev + ` - mark ${event.name}: \t time: ${event.startTime.toFixed(1)}ms\n`;
}, '');
return measuresStr + marksStr;
};

case 'html':
Expand Down
8 changes: 4 additions & 4 deletions lighthouse-core/test/formatter/user-timings-test.js
Expand Up @@ -43,9 +43,9 @@ describe('Formatter', () => {
endTime: 2500,
duration: 1500
}]);
assert.ok(/Mark/.test(output));
assert.ok(/Start Time: 10/.test(output));
assert.ok(/Measure/.test(output));
assert.ok(/Duration: 1500/.test(output));
assert.ok(/mark/.test(output));
assert.ok(/start: 10/.test(output));
assert.ok(/measure/.test(output));
assert.ok(/duration: 1500/.test(output));
});
});

0 comments on commit 73ea8c6

Please sign in to comment.