UNPKG

@comyata/run

Version:

Simplify data workflows and management with data templates, for browser and server.

20 lines 1.14 kB
export const walkStats = (fileEvalStats, parents = []) => { let lines = []; lines.push(`evaluated file ${JSON.stringify(fileEvalStats.file)} with ${fileEvalStats.files.size} imports and ${fileEvalStats.totalExpressions} expressions in ${fileEvalStats.dur}ms`); if (parents.length) { lines.push(` import chain: ${parents.map(([p, ps]) => JSON.stringify(`${ps.file}#${p}`)).join(' ⮞ ')} ⮞ .`); } // keeping file stats belonging together in the same output, first print only the own file expr stats for (const [exprPointer, exprStats] of fileEvalStats.evaluated.entries()) { lines.push(` expression at ${JSON.stringify(exprPointer)} with ${exprStats.imports.length} imports and ${exprStats.totalExpressions} expressions was evaluated in ${exprStats.dur}ms`); } // then print stats for all import by each expr for (const [exprPointer, exprStats] of fileEvalStats.evaluated.entries()) { if (exprStats.imports.length) { exprStats.imports.forEach(importEvalStats => { lines = lines.concat(walkStats(importEvalStats, [...parents, [exprPointer, fileEvalStats]])); }); } } return lines; };