Skip to content

Commit

Permalink
Tweaks to performance logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
getvictor committed Jun 29, 2024
1 parent d9eda12 commit d3bb62a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLElement>())
addedNodesFound = mutations.some((mutation) => {
return mutation.addedNodes.length > 0
Expand All @@ -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)
}
}
}
})
Expand Down

0 comments on commit d3bb62a

Please sign in to comment.