From d3bb62af10a277108ae6796970b3bcf5a1d3b0aa Mon Sep 17 00:00:00 2001 From: Victor Lyuboslavsky Date: Sat, 29 Jun 2024 14:40:37 -0500 Subject: [PATCH] Tweaks to performance logging. --- src/content.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/content.ts b/src/content.ts index 8df0fa9..746b1bf 100644 --- a/src/content.ts +++ b/src/content.ts @@ -268,7 +268,8 @@ const observer = new MutationObserver((mutations) => { const startTime = performance.now() let addedNodesFound = false // Performance optimization: for a lot of mutations, we do a full scan instead. - if (mutations.length > 50) { + const mutationsTriggerFullScan = 50 + if (mutations.length >= mutationsTriggerFullScan) { processNode(document, new Set()) addedNodesFound = mutations.some((mutation) => { return mutation.addedNodes.length > 0 @@ -292,7 +293,11 @@ const observer = new MutationObserver((mutations) => { if (performanceLogging) { const duration = performance.now() - startTime if (duration > 2) { - console.log("OpenBlur MutationObserver took %f ms for mutations", duration, mutations) + if (mutations.length >= mutationsTriggerFullScan) { + console.log("OpenBlur MutationObserver took %f ms for full scan", duration) + } else { + console.log("OpenBlur MutationObserver took %f ms for mutations", duration, mutations) + } } } })