From 126f58ad37b94310845bd11114ef20e55e209ab0 Mon Sep 17 00:00:00 2001 From: Eric Mc Sween <5454374+emcsween@users.noreply.github.com> Date: Mon, 27 Oct 2025 09:32:21 -0400 Subject: [PATCH] Merge pull request #29301 from overleaf/em-fast-png-copy-metrics More precise metrics on fast PNG copy GitOrigin-RevId: 8b3a65a8a70152f1743c45f701448dc97be7ffeb --- services/clsi/app/js/LatexMetrics.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/services/clsi/app/js/LatexMetrics.js b/services/clsi/app/js/LatexMetrics.js index 3aa2a0b3e1..1a99813841 100644 --- a/services/clsi/app/js/LatexMetrics.js +++ b/services/clsi/app/js/LatexMetrics.js @@ -104,11 +104,20 @@ const LATEX_MK_METRICS_STDERR = [ [ 'latexmk-img-times', s => { + const pngCategoriesByFile = new Map() const pngCopyMatches = s.matchAll(/^PNG copy: (.*)$/gm) - const pngCopyFiles = new Set() for (const match of pngCopyMatches) { const filename = match[1] - pngCopyFiles.add(filename) + pngCategoriesByFile.set(filename, 'fast-copy') + } + + const pngCopySkipMatches = s.matchAll( + /^PNG copy skipped \((alpha|gamma|palette|interlaced)\): (.*)$/gm + ) + for (const match of pngCopySkipMatches) { + const category = match[1] + const filename = match[2] + pngCategoriesByFile.set(filename, category) } const timingMatches = s.matchAll( @@ -119,9 +128,14 @@ const LATEX_MK_METRICS_STDERR = [ let type = match[1] const timeMs = parseInt(match[2], 10) const filename = match[3] - if (type === 'PNG' && pngCopyFiles.has(filename)) { - type = 'PNG-fast-copy' + + if (type === 'PNG') { + const pngCategory = pngCategoriesByFile.get(filename) + if (pngCategory != null) { + type = `PNG-${pngCategory}` + } } + const accumulatedTime = timingsByType.get(type) ?? 0 timingsByType.set(type, accumulatedTime + timeMs) }