Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static _getTiming(artifacts) {
const timingEntriesFromArtifacts = artifacts.Timing || [];
const timingEntriesFromRunner = log.takeTimeEntries();
const timingEntriesKeyValues = [
...timingEntriesFromArtifacts,
...timingEntriesFromRunner,
// As entries can share a name, dedupe based on the startTime timestamp
].map(entry => /** @type {[number, PerformanceEntry]} */ ([entry.startTime, entry]));
const timingEntries = Array.from(new Map(timingEntriesKeyValues).values())
// Truncate timestamps to hundredths of a millisecond saves ~4KB. No need for microsecond
// resolution.
.map(entry => {
return /** @type {PerformanceEntry} */ ({
// Don't spread entry because browser PerformanceEntries can't be spread.
// https://github.com/GoogleChrome/lighthouse/issues/8638
startTime: parseFloat(entry.startTime.toFixed(2)),
name: entry.name,
duration: parseFloat(entry.duration.toFixed(2)),
entryType: entry.entryType,