Forráskód Böngészése

Merge pull request #29301 from overleaf/em-fast-png-copy-metrics

More precise metrics on fast PNG copy

GitOrigin-RevId: 8b3a65a8a70152f1743c45f701448dc97be7ffeb
Eric Mc Sween 9 hónapja
szülő
commit
61d823f946
1 módosított fájl, 18 hozzáadás és 4 törlés
  1. 18 4
      services/clsi/app/js/LatexMetrics.js

+ 18 - 4
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)
       }