[{"data":1,"prerenderedAt":63},["Reactive",2],{"blog-post-markdown-performance-optimization-complete-guide":3},{"slug":4,"title":5,"description":6,"excerpt":7,"date":8,"category":9,"author":10,"keywords":11,"readingMinutes":12,"html":13,"headings":14,"tools":37,"related":38},"markdown-performance-optimization-complete-guide","Markdown Performance Optimization: Complete Guide for High-Volume Content Processing and Rendering Efficiency","Master advanced Markdown performance optimization techniques for large-scale content processing, rendering efficiency, and high-volume documentation systems. Learn caching strategies, parsing optimization, and performance monitoring for Markdown workflows.","Advanced Markdown performance optimization techniques enable high-volume content processing systems that deliver exceptional rendering speeds, efficient memory usage, and scalable processing…","2025-10-28","Tutorial","Matthew Rathbone","markdown performance optimization, markdown parsing performance, markdown rendering speed, markdown content caching, large scale markdown, markdown processing efficiency, markdown performance monitoring, markdown optimization techniques",22,"\u003Cp>Advanced Markdown performance optimization techniques enable high-volume content processing systems that deliver exceptional rendering speeds, efficient memory usage, and scalable processing capabilities for large documentation repositories. By implementing comprehensive optimization strategies, intelligent caching systems, and performance monitoring, organizations can build Markdown-based platforms that maintain responsiveness and efficiency even when processing thousands of documents, complex content structures, and high-frequency update cycles.\u003C/p>\n\u003Ch2 id=\"why-master-markdown-performance-optimization\">Why Master Markdown Performance Optimization?\u003C/h2>\n\u003Cp>Professional performance optimization provides essential benefits for large-scale content systems:\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cstrong>Rendering Speed\u003C/strong>: Dramatically reduce document processing and rendering times for better user experience\u003C/li>\n\u003Cli>\u003Cstrong>Memory Efficiency\u003C/strong>: Optimize memory usage for processing large document collections without resource exhaustion\u003C/li>\n\u003Cli>\u003Cstrong>Scalability\u003C/strong>: Handle increasing content volumes without proportional performance degradation\u003C/li>\n\u003Cli>\u003Cstrong>Cost Reduction\u003C/strong>: Minimize server resources and processing costs through efficient algorithms and caching\u003C/li>\n\u003Cli>\u003Cstrong>User Experience\u003C/strong>: Provide instant content delivery and responsive interactions in documentation platforms\u003C/li>\n\u003C/ul>\n\u003Ch2 id=\"foundation-performance-analysis\">Foundation Performance Analysis\u003C/h2>\n\u003Ch3 id=\"markdown-processing-bottlenecks\">Markdown Processing Bottlenecks\u003C/h3>\n\u003Cp>Understanding common performance issues in Markdown processing workflows:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-javascript\">\u003Cspan class=\"hljs-comment\">// performance-profiler.js - Comprehensive Markdown performance analysis\u003C/span>\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> fs = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;fs&#x27;\u003C/span>).\u003Cspan class=\"hljs-property\">promises\u003C/span>;\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> path = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;path&#x27;\u003C/span>);\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> { performance } = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;perf_hooks&#x27;\u003C/span>);\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> marked = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;marked&#x27;\u003C/span>);\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> remarkParse = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;remark-parse&#x27;\u003C/span>);\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> remarkStringify = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;remark-stringify&#x27;\u003C/span>);\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> { unified } = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;unified&#x27;\u003C/span>);\n\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">MarkdownPerformanceProfiler\u003C/span> {\n    \u003Cspan class=\"hljs-title function_\">constructor\u003C/span>(\u003Cspan class=\"hljs-params\">options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">enableMemoryTracking\u003C/span>: options.\u003Cspan class=\"hljs-property\">enableMemoryTracking\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">enableTimingAnalysis\u003C/span>: options.\u003Cspan class=\"hljs-property\">enableTimingAnalysis\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">sampleSize\u003C/span>: options.\u003Cspan class=\"hljs-property\">sampleSize\u003C/span> || \u003Cspan class=\"hljs-number\">100\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">warmupRuns\u003C/span>: options.\u003Cspan class=\"hljs-property\">warmupRuns\u003C/span> || \u003Cspan class=\"hljs-number\">10\u003C/span>,\n            ...options\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">parsing\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">rendering\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">memory\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">fileOperations\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>()\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">parsers\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">marked\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">createMarkedParser\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">remark\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">createRemarkParser\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">custom\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">createCustomParser\u003C/span>()\n        };\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">createMarkedParser\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> marked.\u003Cspan class=\"hljs-title function_\">setOptions\u003C/span>({\n            \u003Cspan class=\"hljs-attr\">gfm\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">breaks\u003C/span>: \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">pedantic\u003C/span>: \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">sanitize\u003C/span>: \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">smartLists\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">smartypants\u003C/span>: \u003Cspan class=\"hljs-literal\">false\u003C/span>\n        });\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">createRemarkParser\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-title function_\">unified\u003C/span>()\n            .\u003Cspan class=\"hljs-title function_\">use\u003C/span>(remarkParse)\n            .\u003Cspan class=\"hljs-title function_\">use\u003C/span>(remarkStringify);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">createCustomParser\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Lightweight custom parser for performance comparison\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-attr\">parse\u003C/span>: \u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">markdown\u003C/span>) =&gt;\u003C/span> {\n                \u003Cspan class=\"hljs-comment\">// Simplified parsing for benchmarking\u003C/span>\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> lines = markdown.\u003Cspan class=\"hljs-title function_\">split\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>);\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> tokens = [];\n                \n                \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">let\u003C/span> i = \u003Cspan class=\"hljs-number\">0\u003C/span>; i &lt; lines.\u003Cspan class=\"hljs-property\">length\u003C/span>; i++) {\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> line = lines[i];\n                    \n                    \u003Cspan class=\"hljs-keyword\">if\u003C/span> (line.\u003Cspan class=\"hljs-title function_\">startsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;#&#x27;\u003C/span>)) {\n                        \u003Cspan class=\"hljs-keyword\">const\u003C/span> level = line.\u003Cspan class=\"hljs-title function_\">match\u003C/span>(\u003Cspan class=\"hljs-regexp\">/^#+/\u003C/span>)[\u003Cspan class=\"hljs-number\">0\u003C/span>].\u003Cspan class=\"hljs-property\">length\u003C/span>;\n                        tokens.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                            \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;heading&#x27;\u003C/span>,\n                            level,\n                            \u003Cspan class=\"hljs-attr\">text\u003C/span>: line.\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/^#+\\s*/\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>)\n                        });\n                    } \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (line.\u003Cspan class=\"hljs-title function_\">startsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;```&#x27;\u003C/span>)) {\n                        \u003Cspan class=\"hljs-keyword\">const\u003C/span> codeBlock = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">parseCodeBlock\u003C/span>(lines, i);\n                        tokens.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(codeBlock.\u003Cspan class=\"hljs-property\">token\u003C/span>);\n                        i = codeBlock.\u003Cspan class=\"hljs-property\">endIndex\u003C/span>;\n                    } \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (line.\u003Cspan class=\"hljs-title function_\">trim\u003C/span>() !== \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>) {\n                        tokens.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                            \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;paragraph&#x27;\u003C/span>,\n                            \u003Cspan class=\"hljs-attr\">text\u003C/span>: line\n                        });\n                    }\n                }\n                \n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> tokens;\n            }\n        };\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">parseCodeBlock\u003C/span>(\u003Cspan class=\"hljs-params\">lines, startIndex\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> endIndex = startIndex + \u003Cspan class=\"hljs-number\">1\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> codeLines = [];\n        \n        \u003Cspan class=\"hljs-keyword\">while\u003C/span> (endIndex &lt; lines.\u003Cspan class=\"hljs-property\">length\u003C/span> &amp;&amp; !lines[endIndex].\u003Cspan class=\"hljs-title function_\">startsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;```&#x27;\u003C/span>)) {\n            codeLines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(lines[endIndex]);\n            endIndex++;\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-attr\">token\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;code&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">language\u003C/span>: lines[startIndex].\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;```&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>).\u003Cspan class=\"hljs-title function_\">trim\u003C/span>(),\n                \u003Cspan class=\"hljs-attr\">text\u003C/span>: codeLines.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>)\n            },\n            endIndex\n        };\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">profileDirectory\u003C/span>(\u003Cspan class=\"hljs-params\">directoryPath\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Starting performance analysis of \u003Cspan class=\"hljs-subst\">${directoryPath}\u003C/span>...`\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> markdownFiles = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">findMarkdownFiles\u003C/span>(directoryPath);\n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Found \u003Cspan class=\"hljs-subst\">${markdownFiles.length}\u003C/span> Markdown files`\u003C/span>);\n        \n        \u003Cspan class=\"hljs-comment\">// Sample files for performance testing\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> sampleFiles = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">selectSampleFiles\u003C/span>(markdownFiles);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> results = {\n            \u003Cspan class=\"hljs-attr\">overview\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">totalFiles\u003C/span>: markdownFiles.\u003Cspan class=\"hljs-property\">length\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">sampledFiles\u003C/span>: sampleFiles.\u003Cspan class=\"hljs-property\">length\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">analysisDate\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Date\u003C/span>().\u003Cspan class=\"hljs-title function_\">toISOString\u003C/span>()\n            },\n            \u003Cspan class=\"hljs-attr\">parsing\u003C/span>: \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">benchmarkParsing\u003C/span>(sampleFiles),\n            \u003Cspan class=\"hljs-attr\">rendering\u003C/span>: \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">benchmarkRendering\u003C/span>(sampleFiles),\n            \u003Cspan class=\"hljs-attr\">memory\u003C/span>: \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">analyzeMemoryUsage\u003C/span>(sampleFiles),\n            \u003Cspan class=\"hljs-attr\">recommendations\u003C/span>: []\n        };\n        \n        results.\u003Cspan class=\"hljs-property\">recommendations\u003C/span> = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateRecommendations\u003C/span>(results);\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> results;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">findMarkdownFiles\u003C/span>(\u003Cspan class=\"hljs-params\">directoryPath\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> files = [];\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> \u003Cspan class=\"hljs-title function_\">scan\u003C/span> = \u003Cspan class=\"hljs-keyword\">async\u003C/span> (\u003Cspan class=\"hljs-params\">dir\u003C/span>) =&gt; {\n            \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> entries = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">readdir\u003C/span>(dir, { \u003Cspan class=\"hljs-attr\">withFileTypes\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span> });\n                \n                \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> entry \u003Cspan class=\"hljs-keyword\">of\u003C/span> entries) {\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> fullPath = path.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(dir, entry.\u003Cspan class=\"hljs-property\">name\u003C/span>);\n                    \n                    \u003Cspan class=\"hljs-keyword\">if\u003C/span> (entry.\u003Cspan class=\"hljs-title function_\">isDirectory\u003C/span>() &amp;&amp; !entry.\u003Cspan class=\"hljs-property\">name\u003C/span>.\u003Cspan class=\"hljs-title function_\">startsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.&#x27;\u003C/span>)) {\n                        \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-title function_\">scan\u003C/span>(fullPath);\n                    } \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (entry.\u003Cspan class=\"hljs-title function_\">isFile\u003C/span>() &amp;&amp; entry.\u003Cspan class=\"hljs-property\">name\u003C/span>.\u003Cspan class=\"hljs-title function_\">endsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.md&#x27;\u003C/span>)) {\n                        \u003Cspan class=\"hljs-keyword\">const\u003C/span> stats = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">stat\u003C/span>(fullPath);\n                        files.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                            \u003Cspan class=\"hljs-attr\">path\u003C/span>: fullPath,\n                            \u003Cspan class=\"hljs-attr\">size\u003C/span>: stats.\u003Cspan class=\"hljs-property\">size\u003C/span>,\n                            \u003Cspan class=\"hljs-attr\">modified\u003C/span>: stats.\u003Cspan class=\"hljs-property\">mtime\u003C/span>\n                        });\n                    }\n                }\n            } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">warn\u003C/span>(\u003Cspan class=\"hljs-string\">`Error scanning \u003Cspan class=\"hljs-subst\">${dir}\u003C/span>: \u003Cspan class=\"hljs-subst\">${error.message}\u003C/span>`\u003C/span>);\n            }\n        };\n        \n        \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-title function_\">scan\u003C/span>(directoryPath);\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> files;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">selectSampleFiles\u003C/span>(\u003Cspan class=\"hljs-params\">files\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Sort by size to get a representative sample\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> sortedFiles = files.\u003Cspan class=\"hljs-title function_\">sort\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">a, b\u003C/span>) =&gt;\u003C/span> a.\u003Cspan class=\"hljs-property\">size\u003C/span> - b.\u003Cspan class=\"hljs-property\">size\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> sampleSize = \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">min\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">sampleSize\u003C/span>, files.\u003Cspan class=\"hljs-property\">length\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> interval = \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">floor\u003C/span>(files.\u003Cspan class=\"hljs-property\">length\u003C/span> / sampleSize);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> samples = [];\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">let\u003C/span> i = \u003Cspan class=\"hljs-number\">0\u003C/span>; i &lt; sampleSize; i++) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> index = i * interval;\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (index &lt; sortedFiles.\u003Cspan class=\"hljs-property\">length\u003C/span>) {\n                samples.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(sortedFiles[index]);\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> samples;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">benchmarkParsing\u003C/span>(\u003Cspan class=\"hljs-params\">sampleFiles\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Benchmarking parsing performance...&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> results = {\n            \u003Cspan class=\"hljs-attr\">marked\u003C/span>: { \u003Cspan class=\"hljs-attr\">times\u003C/span>: [], \u003Cspan class=\"hljs-attr\">avgTime\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">throughput\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span> },\n            \u003Cspan class=\"hljs-attr\">remark\u003C/span>: { \u003Cspan class=\"hljs-attr\">times\u003C/span>: [], \u003Cspan class=\"hljs-attr\">avgTime\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">throughput\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span> },\n            \u003Cspan class=\"hljs-attr\">custom\u003C/span>: { \u003Cspan class=\"hljs-attr\">times\u003C/span>: [], \u003Cspan class=\"hljs-attr\">avgTime\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">throughput\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span> }\n        };\n        \n        \u003Cspan class=\"hljs-comment\">// Warmup\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">let\u003C/span> i = \u003Cspan class=\"hljs-number\">0\u003C/span>; i &lt; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">warmupRuns\u003C/span>; i++) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> file = sampleFiles[i % sampleFiles.\u003Cspan class=\"hljs-property\">length\u003C/span>];\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> content = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">readFile\u003C/span>(file.\u003Cspan class=\"hljs-property\">path\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;utf8&#x27;\u003C/span>);\n            \n            \u003Cspan class=\"hljs-title function_\">marked\u003C/span>(content);\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">parsers\u003C/span>.\u003Cspan class=\"hljs-property\">remark\u003C/span>.\u003Cspan class=\"hljs-title function_\">processSync\u003C/span>(content);\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">parsers\u003C/span>.\u003Cspan class=\"hljs-property\">custom\u003C/span>.\u003Cspan class=\"hljs-title function_\">parse\u003C/span>(content);\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Actual benchmarking\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> file \u003Cspan class=\"hljs-keyword\">of\u003C/span> sampleFiles) {\n            \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> content = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">readFile\u003C/span>(file.\u003Cspan class=\"hljs-property\">path\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;utf8&#x27;\u003C/span>);\n                \n                \u003Cspan class=\"hljs-comment\">// Benchmark each parser\u003C/span>\n                \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> [parserName, parser] \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-title class_\">Object\u003C/span>.\u003Cspan class=\"hljs-title function_\">entries\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">parsers\u003C/span>)) {\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> startTime = performance.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n                    \n                    \u003Cspan class=\"hljs-keyword\">if\u003C/span> (parserName === \u003Cspan class=\"hljs-string\">&#x27;marked&#x27;\u003C/span>) {\n                        \u003Cspan class=\"hljs-title function_\">marked\u003C/span>(content);\n                    } \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (parserName === \u003Cspan class=\"hljs-string\">&#x27;remark&#x27;\u003C/span>) {\n                        parser.\u003Cspan class=\"hljs-title function_\">processSync\u003C/span>(content);\n                    } \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (parserName === \u003Cspan class=\"hljs-string\">&#x27;custom&#x27;\u003C/span>) {\n                        parser.\u003Cspan class=\"hljs-title function_\">parse\u003C/span>(content);\n                    }\n                    \n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> endTime = performance.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> duration = endTime - startTime;\n                    \n                    results[parserName].\u003Cspan class=\"hljs-property\">times\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                        \u003Cspan class=\"hljs-attr\">file\u003C/span>: file.\u003Cspan class=\"hljs-property\">path\u003C/span>,\n                        \u003Cspan class=\"hljs-attr\">size\u003C/span>: file.\u003Cspan class=\"hljs-property\">size\u003C/span>,\n                        duration\n                    });\n                }\n                \n            } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">warn\u003C/span>(\u003Cspan class=\"hljs-string\">`Error benchmarking \u003Cspan class=\"hljs-subst\">${file.path}\u003C/span>: \u003Cspan class=\"hljs-subst\">${error.message}\u003C/span>`\u003C/span>);\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Calculate statistics\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> [parserName, data] \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-title class_\">Object\u003C/span>.\u003Cspan class=\"hljs-title function_\">entries\u003C/span>(results)) {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (data.\u003Cspan class=\"hljs-property\">times\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n                data.\u003Cspan class=\"hljs-property\">avgTime\u003C/span> = data.\u003Cspan class=\"hljs-property\">times\u003C/span>.\u003Cspan class=\"hljs-title function_\">reduce\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">sum, t\u003C/span>) =&gt;\u003C/span> sum + t.\u003Cspan class=\"hljs-property\">duration\u003C/span>, \u003Cspan class=\"hljs-number\">0\u003C/span>) / data.\u003Cspan class=\"hljs-property\">times\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span>;\n                data.\u003Cspan class=\"hljs-property\">totalSize\u003C/span> = data.\u003Cspan class=\"hljs-property\">times\u003C/span>.\u003Cspan class=\"hljs-title function_\">reduce\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">sum, t\u003C/span>) =&gt;\u003C/span> sum + t.\u003Cspan class=\"hljs-property\">size\u003C/span>, \u003Cspan class=\"hljs-number\">0\u003C/span>);\n                data.\u003Cspan class=\"hljs-property\">throughput\u003C/span> = data.\u003Cspan class=\"hljs-property\">totalSize\u003C/span> / (data.\u003Cspan class=\"hljs-property\">avgTime\u003C/span> * data.\u003Cspan class=\"hljs-property\">times\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> / \u003Cspan class=\"hljs-number\">1000\u003C/span>); \u003Cspan class=\"hljs-comment\">// bytes per second\u003C/span>\n                \n                \u003Cspan class=\"hljs-comment\">// Calculate percentiles\u003C/span>\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> sortedTimes = data.\u003Cspan class=\"hljs-property\">times\u003C/span>.\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">t\u003C/span> =&gt;\u003C/span> t.\u003Cspan class=\"hljs-property\">duration\u003C/span>).\u003Cspan class=\"hljs-title function_\">sort\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">a, b\u003C/span>) =&gt;\u003C/span> a - b);\n                data.\u003Cspan class=\"hljs-property\">p50\u003C/span> = sortedTimes[\u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">floor\u003C/span>(sortedTimes.\u003Cspan class=\"hljs-property\">length\u003C/span> * \u003Cspan class=\"hljs-number\">0.5\u003C/span>)];\n                data.\u003Cspan class=\"hljs-property\">p90\u003C/span> = sortedTimes[\u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">floor\u003C/span>(sortedTimes.\u003Cspan class=\"hljs-property\">length\u003C/span> * \u003Cspan class=\"hljs-number\">0.9\u003C/span>)];\n                data.\u003Cspan class=\"hljs-property\">p95\u003C/span> = sortedTimes[\u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">floor\u003C/span>(sortedTimes.\u003Cspan class=\"hljs-property\">length\u003C/span> * \u003Cspan class=\"hljs-number\">0.95\u003C/span>)];\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> results;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">benchmarkRendering\u003C/span>(\u003Cspan class=\"hljs-params\">sampleFiles\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Benchmarking rendering performance...&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> results = {\n            \u003Cspan class=\"hljs-attr\">htmlRendering\u003C/span>: { \u003Cspan class=\"hljs-attr\">times\u003C/span>: [], \u003Cspan class=\"hljs-attr\">avgTime\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span> },\n            \u003Cspan class=\"hljs-attr\">domManipulation\u003C/span>: { \u003Cspan class=\"hljs-attr\">times\u003C/span>: [], \u003Cspan class=\"hljs-attr\">avgTime\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span> },\n            \u003Cspan class=\"hljs-attr\">cacheHit\u003C/span>: { \u003Cspan class=\"hljs-attr\">times\u003C/span>: [], \u003Cspan class=\"hljs-attr\">avgTime\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span> },\n            \u003Cspan class=\"hljs-attr\">cacheMiss\u003C/span>: { \u003Cspan class=\"hljs-attr\">times\u003C/span>: [], \u003Cspan class=\"hljs-attr\">avgTime\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span> }\n        };\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> renderCache = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> file \u003Cspan class=\"hljs-keyword\">of\u003C/span> sampleFiles) {\n            \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> content = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">readFile\u003C/span>(file.\u003Cspan class=\"hljs-property\">path\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;utf8&#x27;\u003C/span>);\n                \n                \u003Cspan class=\"hljs-comment\">// Benchmark HTML rendering\u003C/span>\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> htmlStart = performance.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> html = \u003Cspan class=\"hljs-title function_\">marked\u003C/span>(content);\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> htmlEnd = performance.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n                \n                results.\u003Cspan class=\"hljs-property\">htmlRendering\u003C/span>.\u003Cspan class=\"hljs-property\">times\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">file\u003C/span>: file.\u003Cspan class=\"hljs-property\">path\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">duration\u003C/span>: htmlEnd - htmlStart,\n                    \u003Cspan class=\"hljs-attr\">outputSize\u003C/span>: html.\u003Cspan class=\"hljs-property\">length\u003C/span>\n                });\n                \n                \u003Cspan class=\"hljs-comment\">// Benchmark cache performance\u003C/span>\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> cacheKey = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateCacheKey\u003C/span>(content);\n                \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (renderCache.\u003Cspan class=\"hljs-title function_\">has\u003C/span>(cacheKey)) {\n                    \u003Cspan class=\"hljs-comment\">// Cache hit\u003C/span>\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> cacheHitStart = performance.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> cached = renderCache.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(cacheKey);\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> cacheHitEnd = performance.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n                    \n                    results.\u003Cspan class=\"hljs-property\">cacheHit\u003C/span>.\u003Cspan class=\"hljs-property\">times\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                        \u003Cspan class=\"hljs-attr\">file\u003C/span>: file.\u003Cspan class=\"hljs-property\">path\u003C/span>,\n                        \u003Cspan class=\"hljs-attr\">duration\u003C/span>: cacheHitEnd - cacheHitStart\n                    });\n                } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n                    \u003Cspan class=\"hljs-comment\">// Cache miss\u003C/span>\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> cacheMissStart = performance.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> rendered = \u003Cspan class=\"hljs-title function_\">marked\u003C/span>(content);\n                    renderCache.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(cacheKey, rendered);\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> cacheMissEnd = performance.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n                    \n                    results.\u003Cspan class=\"hljs-property\">cacheMiss\u003C/span>.\u003Cspan class=\"hljs-property\">times\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                        \u003Cspan class=\"hljs-attr\">file\u003C/span>: file.\u003Cspan class=\"hljs-property\">path\u003C/span>,\n                        \u003Cspan class=\"hljs-attr\">duration\u003C/span>: cacheMissEnd - cacheMissStart\n                    });\n                }\n                \n            } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">warn\u003C/span>(\u003Cspan class=\"hljs-string\">`Error benchmarking rendering \u003Cspan class=\"hljs-subst\">${file.path}\u003C/span>: \u003Cspan class=\"hljs-subst\">${error.message}\u003C/span>`\u003C/span>);\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Calculate averages\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> [category, data] \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-title class_\">Object\u003C/span>.\u003Cspan class=\"hljs-title function_\">entries\u003C/span>(results)) {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (data.\u003Cspan class=\"hljs-property\">times\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n                data.\u003Cspan class=\"hljs-property\">avgTime\u003C/span> = data.\u003Cspan class=\"hljs-property\">times\u003C/span>.\u003Cspan class=\"hljs-title function_\">reduce\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">sum, t\u003C/span>) =&gt;\u003C/span> sum + t.\u003Cspan class=\"hljs-property\">duration\u003C/span>, \u003Cspan class=\"hljs-number\">0\u003C/span>) / data.\u003Cspan class=\"hljs-property\">times\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span>;\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> results;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">analyzeMemoryUsage\u003C/span>(\u003Cspan class=\"hljs-params\">sampleFiles\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">enableMemoryTracking\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> { \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Memory tracking disabled&#x27;\u003C/span> };\n        }\n        \n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Analyzing memory usage...&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> memoryResults = {\n            \u003Cspan class=\"hljs-attr\">baseline\u003C/span>: process.\u003Cspan class=\"hljs-title function_\">memoryUsage\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">parsing\u003C/span>: [],\n            \u003Cspan class=\"hljs-attr\">rendering\u003C/span>: [],\n            \u003Cspan class=\"hljs-attr\">caching\u003C/span>: [],\n            \u003Cspan class=\"hljs-attr\">peak\u003C/span>: { \u003Cspan class=\"hljs-attr\">heapUsed\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">heapTotal\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">external\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span> }\n        };\n        \n        \u003Cspan class=\"hljs-comment\">// Force garbage collection if available\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">global\u003C/span>.\u003Cspan class=\"hljs-property\">gc\u003C/span>) {\n            \u003Cspan class=\"hljs-variable language_\">global\u003C/span>.\u003Cspan class=\"hljs-title function_\">gc\u003C/span>();\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> baselineMemory = process.\u003Cspan class=\"hljs-title function_\">memoryUsage\u003C/span>();\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> file \u003Cspan class=\"hljs-keyword\">of\u003C/span> sampleFiles) {\n            \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> content = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">readFile\u003C/span>(file.\u003Cspan class=\"hljs-property\">path\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;utf8&#x27;\u003C/span>);\n                \n                \u003Cspan class=\"hljs-comment\">// Memory usage during parsing\u003C/span>\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> preParseMemory = process.\u003Cspan class=\"hljs-title function_\">memoryUsage\u003C/span>();\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> parsed = \u003Cspan class=\"hljs-title function_\">marked\u003C/span>(content);\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> postParseMemory = process.\u003Cspan class=\"hljs-title function_\">memoryUsage\u003C/span>();\n                \n                memoryResults.\u003Cspan class=\"hljs-property\">parsing\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">file\u003C/span>: file.\u003Cspan class=\"hljs-property\">path\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">size\u003C/span>: file.\u003Cspan class=\"hljs-property\">size\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">memoryDelta\u003C/span>: postParseMemory.\u003Cspan class=\"hljs-property\">heapUsed\u003C/span> - preParseMemory.\u003Cspan class=\"hljs-property\">heapUsed\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">heapUsed\u003C/span>: postParseMemory.\u003Cspan class=\"hljs-property\">heapUsed\u003C/span>\n                });\n                \n                \u003Cspan class=\"hljs-comment\">// Track peak memory usage\u003C/span>\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (postParseMemory.\u003Cspan class=\"hljs-property\">heapUsed\u003C/span> &gt; memoryResults.\u003Cspan class=\"hljs-property\">peak\u003C/span>.\u003Cspan class=\"hljs-property\">heapUsed\u003C/span>) {\n                    memoryResults.\u003Cspan class=\"hljs-property\">peak\u003C/span> = postParseMemory;\n                }\n                \n            } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">warn\u003C/span>(\u003Cspan class=\"hljs-string\">`Error analyzing memory for \u003Cspan class=\"hljs-subst\">${file.path}\u003C/span>: \u003Cspan class=\"hljs-subst\">${error.message}\u003C/span>`\u003C/span>);\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Calculate memory efficiency metrics\u003C/span>\n        memoryResults.\u003Cspan class=\"hljs-property\">efficiency\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">avgMemoryPerFile\u003C/span>: memoryResults.\u003Cspan class=\"hljs-property\">parsing\u003C/span>.\u003Cspan class=\"hljs-title function_\">reduce\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">sum, p\u003C/span>) =&gt;\u003C/span> sum + p.\u003Cspan class=\"hljs-property\">memoryDelta\u003C/span>, \u003Cspan class=\"hljs-number\">0\u003C/span>) / memoryResults.\u003Cspan class=\"hljs-property\">parsing\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">memoryGrowthRate\u003C/span>: (memoryResults.\u003Cspan class=\"hljs-property\">peak\u003C/span>.\u003Cspan class=\"hljs-property\">heapUsed\u003C/span> - baselineMemory.\u003Cspan class=\"hljs-property\">heapUsed\u003C/span>) / baselineMemory.\u003Cspan class=\"hljs-property\">heapUsed\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">totalMemoryIncrease\u003C/span>: memoryResults.\u003Cspan class=\"hljs-property\">peak\u003C/span>.\u003Cspan class=\"hljs-property\">heapUsed\u003C/span> - baselineMemory.\u003Cspan class=\"hljs-property\">heapUsed\u003C/span>\n        };\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> memoryResults;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateCacheKey\u003C/span>(\u003Cspan class=\"hljs-params\">content\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Simple hash for cache key generation\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> hash = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">let\u003C/span> i = \u003Cspan class=\"hljs-number\">0\u003C/span>; i &lt; content.\u003Cspan class=\"hljs-property\">length\u003C/span>; i++) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> char = content.\u003Cspan class=\"hljs-title function_\">charCodeAt\u003C/span>(i);\n            hash = ((hash &lt;&lt; \u003Cspan class=\"hljs-number\">5\u003C/span>) - hash) + char;\n            hash = hash &amp; hash; \u003Cspan class=\"hljs-comment\">// Convert to 32-bit integer\u003C/span>\n        }\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> hash.\u003Cspan class=\"hljs-title function_\">toString\u003C/span>(\u003Cspan class=\"hljs-number\">36\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateRecommendations\u003C/span>(\u003Cspan class=\"hljs-params\">results\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> recommendations = [];\n        \n        \u003Cspan class=\"hljs-comment\">// Parser performance recommendations\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> parsingResults = results.\u003Cspan class=\"hljs-property\">parsing\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> bestParser = \u003Cspan class=\"hljs-title class_\">Object\u003C/span>.\u003Cspan class=\"hljs-title function_\">entries\u003C/span>(parsingResults)\n            .\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">[name, data]\u003C/span>) =&gt;\u003C/span> data.\u003Cspan class=\"hljs-property\">times\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">reduce\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">best, [name, data]\u003C/span>) =&gt;\u003C/span> \n                !best || data.\u003Cspan class=\"hljs-property\">avgTime\u003C/span> &lt; best.\u003Cspan class=\"hljs-property\">avgTime\u003C/span> ? { name, ...data } : best, \u003Cspan class=\"hljs-literal\">null\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (bestParser) {\n            recommendations.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">category\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;parsing&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">priority\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;high&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">title\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Optimal Parser Selection&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">description\u003C/span>: \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${bestParser.name}\u003C/span> shows best performance with \u003Cspan class=\"hljs-subst\">${bestParser.avgTime.toFixed(\u003Cspan class=\"hljs-number\">2\u003C/span>)}\u003C/span>ms average processing time`\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">action\u003C/span>: \u003Cspan class=\"hljs-string\">`Consider switching to \u003Cspan class=\"hljs-subst\">${bestParser.name}\u003C/span> parser for better performance`\u003C/span>\n            });\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Memory usage recommendations\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (results.\u003Cspan class=\"hljs-property\">memory\u003C/span>.\u003Cspan class=\"hljs-property\">efficiency\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> memoryGrowth = results.\u003Cspan class=\"hljs-property\">memory\u003C/span>.\u003Cspan class=\"hljs-property\">efficiency\u003C/span>.\u003Cspan class=\"hljs-property\">memoryGrowthRate\u003C/span>;\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (memoryGrowth &gt; \u003Cspan class=\"hljs-number\">0.5\u003C/span>) { \u003Cspan class=\"hljs-comment\">// 50% memory growth\u003C/span>\n                recommendations.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">category\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;memory&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">priority\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;medium&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">title\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;High Memory Usage Detected&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">description\u003C/span>: \u003Cspan class=\"hljs-string\">`Memory usage increases by \u003Cspan class=\"hljs-subst\">${(memoryGrowth * \u003Cspan class=\"hljs-number\">100\u003C/span>).toFixed(\u003Cspan class=\"hljs-number\">1\u003C/span>)}\u003C/span>% during processing`\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">action\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Implement streaming processing or batch processing for large file sets&#x27;\u003C/span>\n                });\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Caching recommendations\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (results.\u003Cspan class=\"hljs-property\">rendering\u003C/span>.\u003Cspan class=\"hljs-property\">cacheHit\u003C/span> &amp;&amp; results.\u003Cspan class=\"hljs-property\">rendering\u003C/span>.\u003Cspan class=\"hljs-property\">cacheMiss\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> cacheHitTime = results.\u003Cspan class=\"hljs-property\">rendering\u003C/span>.\u003Cspan class=\"hljs-property\">cacheHit\u003C/span>.\u003Cspan class=\"hljs-property\">avgTime\u003C/span>;\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> cacheMissTime = results.\u003Cspan class=\"hljs-property\">rendering\u003C/span>.\u003Cspan class=\"hljs-property\">cacheMiss\u003C/span>.\u003Cspan class=\"hljs-property\">avgTime\u003C/span>;\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> cacheEfficiency = (cacheMissTime - cacheHitTime) / cacheMissTime;\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (cacheEfficiency &gt; \u003Cspan class=\"hljs-number\">0.8\u003C/span>) { \u003Cspan class=\"hljs-comment\">// 80% time savings\u003C/span>\n                recommendations.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">category\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;caching&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">priority\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;high&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">title\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;High Cache Efficiency&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">description\u003C/span>: \u003Cspan class=\"hljs-string\">`Caching provides \u003Cspan class=\"hljs-subst\">${(cacheEfficiency * \u003Cspan class=\"hljs-number\">100\u003C/span>).toFixed(\u003Cspan class=\"hljs-number\">1\u003C/span>)}\u003C/span>% performance improvement`\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">action\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Implement comprehensive caching strategy for production systems&#x27;\u003C/span>\n                });\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> recommendations;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">generateReport\u003C/span>(\u003Cspan class=\"hljs-params\">results, outputPath\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> report = {\n            ...results,\n            \u003Cspan class=\"hljs-attr\">generatedAt\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Date\u003C/span>().\u003Cspan class=\"hljs-title function_\">toISOString\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">environment\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">nodeVersion\u003C/span>: process.\u003Cspan class=\"hljs-property\">version\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">platform\u003C/span>: process.\u003Cspan class=\"hljs-property\">platform\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">arch\u003C/span>: process.\u003Cspan class=\"hljs-property\">arch\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">memory\u003C/span>: process.\u003Cspan class=\"hljs-title function_\">memoryUsage\u003C/span>()\n            }\n        };\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (outputPath) {\n            \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">writeFile\u003C/span>(outputPath, \u003Cspan class=\"hljs-title class_\">JSON\u003C/span>.\u003Cspan class=\"hljs-title function_\">stringify\u003C/span>(report, \u003Cspan class=\"hljs-literal\">null\u003C/span>, \u003Cspan class=\"hljs-number\">2\u003C/span>));\n            \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Performance report saved to \u003Cspan class=\"hljs-subst\">${outputPath}\u003C/span>`\u003C/span>);\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> report;\n    }\n}\n\n\u003Cspan class=\"hljs-variable language_\">module\u003C/span>.\u003Cspan class=\"hljs-property\">exports\u003C/span> = \u003Cspan class=\"hljs-title class_\">MarkdownPerformanceProfiler\u003C/span>;\n\u003C/code>\u003C/pre>\u003Ch2 id=\"advanced-caching-strategies\">Advanced Caching Strategies\u003C/h2>\n\u003Ch3 id=\"multi-level-caching-system\">Multi-Level Caching System\u003C/h3>\n\u003Cp>Implementing comprehensive caching for optimal Markdown performance:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-javascript\">\u003Cspan class=\"hljs-comment\">// advanced-markdown-cache.js - Sophisticated caching system\u003C/span>\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> crypto = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;crypto&#x27;\u003C/span>);\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> \u003Cspan class=\"hljs-variable constant_\">LRU\u003C/span> = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;lru-cache&#x27;\u003C/span>);\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> fs = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;fs&#x27;\u003C/span>).\u003Cspan class=\"hljs-property\">promises\u003C/span>;\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> path = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;path&#x27;\u003C/span>);\n\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">AdvancedMarkdownCache\u003C/span> {\n    \u003Cspan class=\"hljs-title function_\">constructor\u003C/span>(\u003Cspan class=\"hljs-params\">options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">enableMemoryCache\u003C/span>: options.\u003Cspan class=\"hljs-property\">enableMemoryCache\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">enableFileCache\u003C/span>: options.\u003Cspan class=\"hljs-property\">enableFileCache\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">enableDistributedCache\u003C/span>: options.\u003Cspan class=\"hljs-property\">enableDistributedCache\u003C/span> || \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">memoryCacheSize\u003C/span>: options.\u003Cspan class=\"hljs-property\">memoryCacheSize\u003C/span> || \u003Cspan class=\"hljs-number\">100\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">fileCacheDir\u003C/span>: options.\u003Cspan class=\"hljs-property\">fileCacheDir\u003C/span> || \u003Cspan class=\"hljs-string\">&#x27;./cache&#x27;\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">cacheTimeout\u003C/span>: options.\u003Cspan class=\"hljs-property\">cacheTimeout\u003C/span> || \u003Cspan class=\"hljs-number\">3600000\u003C/span>, \u003Cspan class=\"hljs-comment\">// 1 hour\u003C/span>\n            \u003Cspan class=\"hljs-attr\">compressionLevel\u003C/span>: options.\u003Cspan class=\"hljs-property\">compressionLevel\u003C/span> || \u003Cspan class=\"hljs-number\">6\u003C/span>,\n            ...options\n        };\n        \n        \u003Cspan class=\"hljs-comment\">// Memory cache (LRU)\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">memoryCache\u003C/span> = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title function_\">LRU\u003C/span>({\n            \u003Cspan class=\"hljs-attr\">max\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">memoryCacheSize\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">ttl\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">cacheTimeout\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">updateAgeOnGet\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span>\n        });\n        \n        \u003Cspan class=\"hljs-comment\">// File system cache\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">fileCache\u003C/span> = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n        \n        \u003Cspan class=\"hljs-comment\">// Performance metrics\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">hits\u003C/span>: { \u003Cspan class=\"hljs-attr\">memory\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">file\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">distributed\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span> },\n            \u003Cspan class=\"hljs-attr\">misses\u003C/span>: { \u003Cspan class=\"hljs-attr\">memory\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">file\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">distributed\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span> },\n            \u003Cspan class=\"hljs-attr\">writes\u003C/span>: { \u003Cspan class=\"hljs-attr\">memory\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">file\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">distributed\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span> },\n            \u003Cspan class=\"hljs-attr\">totalRequests\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">avgResponseTime\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">ensureCacheDirectory\u003C/span>();\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">ensureCacheDirectory\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">enableFileCache\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">mkdir\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">fileCacheDir\u003C/span>, { \u003Cspan class=\"hljs-attr\">recursive\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span> });\n            } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">warn\u003C/span>(\u003Cspan class=\"hljs-string\">`Failed to create cache directory: \u003Cspan class=\"hljs-subst\">${error.message}\u003C/span>`\u003C/span>);\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">enableFileCache\u003C/span> = \u003Cspan class=\"hljs-literal\">false\u003C/span>;\n            }\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateCacheKey\u003C/span>(\u003Cspan class=\"hljs-params\">content, options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> keyData = {\n            \u003Cspan class=\"hljs-attr\">content\u003C/span>: \u003Cspan class=\"hljs-keyword\">typeof\u003C/span> content === \u003Cspan class=\"hljs-string\">&#x27;string&#x27;\u003C/span> ? content : \u003Cspan class=\"hljs-title class_\">JSON\u003C/span>.\u003Cspan class=\"hljs-title function_\">stringify\u003C/span>(content),\n            \u003Cspan class=\"hljs-attr\">options\u003C/span>: \u003Cspan class=\"hljs-title class_\">JSON\u003C/span>.\u003Cspan class=\"hljs-title function_\">stringify\u003C/span>(options),\n            \u003Cspan class=\"hljs-attr\">version\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;1.0&#x27;\u003C/span>\n        };\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> crypto\n            .\u003Cspan class=\"hljs-title function_\">createHash\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;sha256&#x27;\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">update\u003C/span>(\u003Cspan class=\"hljs-title class_\">JSON\u003C/span>.\u003Cspan class=\"hljs-title function_\">stringify\u003C/span>(keyData))\n            .\u003Cspan class=\"hljs-title function_\">digest\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;hex&#x27;\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">substring\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-number\">32\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">get\u003C/span>(\u003Cspan class=\"hljs-params\">key, fallbackFunction, options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> startTime = \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">totalRequests\u003C/span>++;\n        \n        \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n            \u003Cspan class=\"hljs-comment\">// Level 1: Memory cache\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">enableMemoryCache\u003C/span> &amp;&amp; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">memoryCache\u003C/span>.\u003Cspan class=\"hljs-title function_\">has\u003C/span>(key)) {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">hits\u003C/span>.\u003Cspan class=\"hljs-property\">memory\u003C/span>++;\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> cached = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">memoryCache\u003C/span>.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(key);\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">updateMetrics\u003C/span>(startTime);\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> cached.\u003Cspan class=\"hljs-property\">data\u003C/span>;\n            } \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">enableMemoryCache\u003C/span>) {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">misses\u003C/span>.\u003Cspan class=\"hljs-property\">memory\u003C/span>++;\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Level 2: File cache\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">enableFileCache\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> fileResult = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">getFromFileCache\u003C/span>(key);\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (fileResult) {\n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">hits\u003C/span>.\u003Cspan class=\"hljs-property\">file\u003C/span>++;\n                    \n                    \u003Cspan class=\"hljs-comment\">// Populate memory cache\u003C/span>\n                    \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">enableMemoryCache\u003C/span>) {\n                        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">memoryCache\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(key, {\n                            \u003Cspan class=\"hljs-attr\">data\u003C/span>: fileResult.\u003Cspan class=\"hljs-property\">data\u003C/span>,\n                            \u003Cspan class=\"hljs-attr\">timestamp\u003C/span>: fileResult.\u003Cspan class=\"hljs-property\">timestamp\u003C/span>\n                        });\n                        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">writes\u003C/span>.\u003Cspan class=\"hljs-property\">memory\u003C/span>++;\n                    }\n                    \n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">updateMetrics\u003C/span>(startTime);\n                    \u003Cspan class=\"hljs-keyword\">return\u003C/span> fileResult.\u003Cspan class=\"hljs-property\">data\u003C/span>;\n                } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">misses\u003C/span>.\u003Cspan class=\"hljs-property\">file\u003C/span>++;\n                }\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Level 3: Distributed cache (if enabled)\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">enableDistributedCache\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> distributedResult = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">getFromDistributedCache\u003C/span>(key);\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (distributedResult) {\n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">hits\u003C/span>.\u003Cspan class=\"hljs-property\">distributed\u003C/span>++;\n                    \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">populateLocalCaches\u003C/span>(key, distributedResult);\n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">updateMetrics\u003C/span>(startTime);\n                    \u003Cspan class=\"hljs-keyword\">return\u003C/span> distributedResult.\u003Cspan class=\"hljs-property\">data\u003C/span>;\n                } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">misses\u003C/span>.\u003Cspan class=\"hljs-property\">distributed\u003C/span>++;\n                }\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Cache miss: Execute fallback function\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (fallbackFunction) {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> result = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-title function_\">fallbackFunction\u003C/span>();\n                \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(key, result, options);\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">updateMetrics\u003C/span>(startTime);\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> result;\n            }\n            \n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">null\u003C/span>;\n            \n        } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n            \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">`Cache error for key \u003Cspan class=\"hljs-subst\">${key}\u003C/span>: \u003Cspan class=\"hljs-subst\">${error.message}\u003C/span>`\u003C/span>);\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">updateMetrics\u003C/span>(startTime);\n            \n            \u003Cspan class=\"hljs-comment\">// Fallback to direct execution on error\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (fallbackFunction) {\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-title function_\">fallbackFunction\u003C/span>();\n            }\n            \n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">null\u003C/span>;\n        }\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">set\u003C/span>(\u003Cspan class=\"hljs-params\">key, data, options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> cacheEntry = {\n            data,\n            \u003Cspan class=\"hljs-attr\">timestamp\u003C/span>: \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">ttl\u003C/span>: options.\u003Cspan class=\"hljs-property\">ttl\u003C/span> || \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">cacheTimeout\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">metadata\u003C/span>: options.\u003Cspan class=\"hljs-property\">metadata\u003C/span> || {}\n        };\n        \n        \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n            \u003Cspan class=\"hljs-comment\">// Store in memory cache\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">enableMemoryCache\u003C/span>) {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">memoryCache\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(key, cacheEntry);\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">writes\u003C/span>.\u003Cspan class=\"hljs-property\">memory\u003C/span>++;\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Store in file cache\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">enableFileCache\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">setInFileCache\u003C/span>(key, cacheEntry);\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">writes\u003C/span>.\u003Cspan class=\"hljs-property\">file\u003C/span>++;\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Store in distributed cache\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">enableDistributedCache\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">setInDistributedCache\u003C/span>(key, cacheEntry);\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">writes\u003C/span>.\u003Cspan class=\"hljs-property\">distributed\u003C/span>++;\n            }\n            \n        } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n            \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">`Failed to set cache for key \u003Cspan class=\"hljs-subst\">${key}\u003C/span>: \u003Cspan class=\"hljs-subst\">${error.message}\u003C/span>`\u003C/span>);\n        }\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">getFromFileCache\u003C/span>(\u003Cspan class=\"hljs-params\">key\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> filePath = path.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">fileCacheDir\u003C/span>, \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${key}\u003C/span>.json`\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> stats = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">stat\u003C/span>(filePath);\n            \n            \u003Cspan class=\"hljs-comment\">// Check if cache entry is expired\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> now = \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (now - stats.\u003Cspan class=\"hljs-property\">mtime\u003C/span>.\u003Cspan class=\"hljs-title function_\">getTime\u003C/span>() &gt; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">cacheTimeout\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">unlink\u003C/span>(filePath).\u003Cspan class=\"hljs-title function_\">catch\u003C/span>(\u003Cspan class=\"hljs-function\">() =&gt;\u003C/span> {}); \u003Cspan class=\"hljs-comment\">// Clean up expired cache\u003C/span>\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">null\u003C/span>;\n            }\n            \n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> cacheData = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">readFile\u003C/span>(filePath, \u003Cspan class=\"hljs-string\">&#x27;utf8&#x27;\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> parsed = \u003Cspan class=\"hljs-title class_\">JSON\u003C/span>.\u003Cspan class=\"hljs-title function_\">parse\u003C/span>(cacheData);\n            \n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> parsed;\n            \n        } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n            \u003Cspan class=\"hljs-comment\">// File doesn&#x27;t exist or is corrupted\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">null\u003C/span>;\n        }\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">setInFileCache\u003C/span>(\u003Cspan class=\"hljs-params\">key, cacheEntry\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> filePath = path.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">fileCacheDir\u003C/span>, \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${key}\u003C/span>.json`\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> serialized = \u003Cspan class=\"hljs-title class_\">JSON\u003C/span>.\u003Cspan class=\"hljs-title function_\">stringify\u003C/span>(cacheEntry);\n            \n            \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">writeFile\u003C/span>(filePath, serialized);\n            \n        } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n            \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">warn\u003C/span>(\u003Cspan class=\"hljs-string\">`Failed to write file cache: \u003Cspan class=\"hljs-subst\">${error.message}\u003C/span>`\u003C/span>);\n        }\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">getFromDistributedCache\u003C/span>(\u003Cspan class=\"hljs-params\">key\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Placeholder for distributed cache implementation (Redis, Memcached, etc.)\u003C/span>\n        \u003Cspan class=\"hljs-comment\">// Implementation would depend on chosen distributed cache system\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">null\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">setInDistributedCache\u003C/span>(\u003Cspan class=\"hljs-params\">key, cacheEntry\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Placeholder for distributed cache implementation\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">null\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">populateLocalCaches\u003C/span>(\u003Cspan class=\"hljs-params\">key, data\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Populate memory and file caches from distributed cache\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">enableMemoryCache\u003C/span>) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">memoryCache\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(key, data);\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">writes\u003C/span>.\u003Cspan class=\"hljs-property\">memory\u003C/span>++;\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">enableFileCache\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">setInFileCache\u003C/span>(key, data);\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">writes\u003C/span>.\u003Cspan class=\"hljs-property\">file\u003C/span>++;\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">updateMetrics\u003C/span>(\u003Cspan class=\"hljs-params\">startTime\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> responseTime = \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>() - startTime;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">avgResponseTime\u003C/span> = (\n            (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">avgResponseTime\u003C/span> * (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">totalRequests\u003C/span> - \u003Cspan class=\"hljs-number\">1\u003C/span>) + responseTime) \n            / \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">totalRequests\u003C/span>\n        );\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">getCacheStats\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> totalHits = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">hits\u003C/span>.\u003Cspan class=\"hljs-property\">memory\u003C/span> + \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">hits\u003C/span>.\u003Cspan class=\"hljs-property\">file\u003C/span> + \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">hits\u003C/span>.\u003Cspan class=\"hljs-property\">distributed\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> totalMisses = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">misses\u003C/span>.\u003Cspan class=\"hljs-property\">memory\u003C/span> + \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">misses\u003C/span>.\u003Cspan class=\"hljs-property\">file\u003C/span> + \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">misses\u003C/span>.\u003Cspan class=\"hljs-property\">distributed\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> totalRequests = totalHits + totalMisses;\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-attr\">hitRate\u003C/span>: totalRequests &gt; \u003Cspan class=\"hljs-number\">0\u003C/span> ? (totalHits / totalRequests) : \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">totalRequests\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">totalRequests\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">avgResponseTime\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">avgResponseTime\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">cacheBreakdown\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">memory\u003C/span>: {\n                    \u003Cspan class=\"hljs-attr\">hits\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">hits\u003C/span>.\u003Cspan class=\"hljs-property\">memory\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">misses\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">misses\u003C/span>.\u003Cspan class=\"hljs-property\">memory\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">size\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">memoryCache\u003C/span>.\u003Cspan class=\"hljs-property\">size\u003C/span>\n                },\n                \u003Cspan class=\"hljs-attr\">file\u003C/span>: {\n                    \u003Cspan class=\"hljs-attr\">hits\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">hits\u003C/span>.\u003Cspan class=\"hljs-property\">file\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">misses\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">misses\u003C/span>.\u003Cspan class=\"hljs-property\">file\u003C/span>\n                },\n                \u003Cspan class=\"hljs-attr\">distributed\u003C/span>: {\n                    \u003Cspan class=\"hljs-attr\">hits\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">hits\u003C/span>.\u003Cspan class=\"hljs-property\">distributed\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">misses\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">misses\u003C/span>.\u003Cspan class=\"hljs-property\">distributed\u003C/span>\n                }\n            }\n        };\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">warmCache\u003C/span>(\u003Cspan class=\"hljs-params\">contentSources\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Warming cache with \u003Cspan class=\"hljs-subst\">${contentSources.length}\u003C/span> content sources...`\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> warmupPromises = contentSources.\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-keyword\">async\u003C/span> (source) =&gt; {\n            \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">let\u003C/span> content, key;\n                \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-keyword\">typeof\u003C/span> source === \u003Cspan class=\"hljs-string\">&#x27;string&#x27;\u003C/span>) {\n                    \u003Cspan class=\"hljs-comment\">// File path\u003C/span>\n                    content = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">readFile\u003C/span>(source, \u003Cspan class=\"hljs-string\">&#x27;utf8&#x27;\u003C/span>);\n                    key = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateCacheKey\u003C/span>(content);\n                } \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (source.\u003Cspan class=\"hljs-property\">content\u003C/span> &amp;&amp; source.\u003Cspan class=\"hljs-property\">key\u003C/span>) {\n                    \u003Cspan class=\"hljs-comment\">// Pre-processed content with key\u003C/span>\n                    content = source.\u003Cspan class=\"hljs-property\">content\u003C/span>;\n                    key = source.\u003Cspan class=\"hljs-property\">key\u003C/span>;\n                } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n                    \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">warn\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Invalid warmup source:&#x27;\u003C/span>, source);\n                    \u003Cspan class=\"hljs-keyword\">return\u003C/span>;\n                }\n                \n                \u003Cspan class=\"hljs-comment\">// Pre-parse and cache the content\u003C/span>\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> marked = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;marked&#x27;\u003C/span>);\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> parsed = \u003Cspan class=\"hljs-title function_\">marked\u003C/span>(content);\n                \n                \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(key, {\n                    \u003Cspan class=\"hljs-attr\">html\u003C/span>: parsed,\n                    \u003Cspan class=\"hljs-attr\">ast\u003C/span>: \u003Cspan class=\"hljs-literal\">null\u003C/span>, \u003Cspan class=\"hljs-comment\">// Could include AST if needed\u003C/span>\n                    \u003Cspan class=\"hljs-attr\">metadata\u003C/span>: {\n                        \u003Cspan class=\"hljs-attr\">sourceType\u003C/span>: \u003Cspan class=\"hljs-keyword\">typeof\u003C/span> source === \u003Cspan class=\"hljs-string\">&#x27;string&#x27;\u003C/span> ? \u003Cspan class=\"hljs-string\">&#x27;file&#x27;\u003C/span> : \u003Cspan class=\"hljs-string\">&#x27;content&#x27;\u003C/span>,\n                        \u003Cspan class=\"hljs-attr\">warmedAt\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Date\u003C/span>().\u003Cspan class=\"hljs-title function_\">toISOString\u003C/span>()\n                    }\n                });\n                \n            } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">warn\u003C/span>(\u003Cspan class=\"hljs-string\">`Failed to warm cache for source: \u003Cspan class=\"hljs-subst\">${error.message}\u003C/span>`\u003C/span>);\n            }\n        });\n        \n        \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-title class_\">Promise\u003C/span>.\u003Cspan class=\"hljs-title function_\">allSettled\u003C/span>(warmupPromises);\n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Cache warming completed&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">getCacheStats\u003C/span>();\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">invalidatePattern\u003C/span>(\u003Cspan class=\"hljs-params\">pattern\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Invalidate cache entries matching a pattern\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> invalidated = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \n        \u003Cspan class=\"hljs-comment\">// Memory cache\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">enableMemoryCache\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> keys = \u003Cspan class=\"hljs-title class_\">Array\u003C/span>.\u003Cspan class=\"hljs-title function_\">from\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">memoryCache\u003C/span>.\u003Cspan class=\"hljs-title function_\">keys\u003C/span>());\n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> key \u003Cspan class=\"hljs-keyword\">of\u003C/span> keys) {\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (key.\u003Cspan class=\"hljs-title function_\">includes\u003C/span>(pattern)) {\n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">memoryCache\u003C/span>.\u003Cspan class=\"hljs-title function_\">delete\u003C/span>(key);\n                    invalidated++;\n                }\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// File cache\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">enableFileCache\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> files = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">readdir\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">fileCacheDir\u003C/span>);\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> matchingFiles = files.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">file\u003C/span> =&gt;\u003C/span> file.\u003Cspan class=\"hljs-title function_\">includes\u003C/span>(pattern));\n                \n                \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> file \u003Cspan class=\"hljs-keyword\">of\u003C/span> matchingFiles) {\n                    \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">unlink\u003C/span>(path.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">fileCacheDir\u003C/span>, file));\n                    invalidated++;\n                }\n            } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">warn\u003C/span>(\u003Cspan class=\"hljs-string\">`Error invalidating file cache: \u003Cspan class=\"hljs-subst\">${error.message}\u003C/span>`\u003C/span>);\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> invalidated;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">clearAll\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Clear memory cache\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">memoryCache\u003C/span>.\u003Cspan class=\"hljs-title function_\">clear\u003C/span>();\n        \n        \u003Cspan class=\"hljs-comment\">// Clear file cache\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">enableFileCache\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> files = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">readdir\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">fileCacheDir\u003C/span>);\n                \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> file \u003Cspan class=\"hljs-keyword\">of\u003C/span> files) {\n                    \u003Cspan class=\"hljs-keyword\">if\u003C/span> (file.\u003Cspan class=\"hljs-title function_\">endsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.json&#x27;\u003C/span>)) {\n                        \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">unlink\u003C/span>(path.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">fileCacheDir\u003C/span>, file));\n                    }\n                }\n            } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">warn\u003C/span>(\u003Cspan class=\"hljs-string\">`Error clearing file cache: \u003Cspan class=\"hljs-subst\">${error.message}\u003C/span>`\u003C/span>);\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Reset metrics\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">hits\u003C/span>: { \u003Cspan class=\"hljs-attr\">memory\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">file\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">distributed\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span> },\n            \u003Cspan class=\"hljs-attr\">misses\u003C/span>: { \u003Cspan class=\"hljs-attr\">memory\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">file\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">distributed\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span> },\n            \u003Cspan class=\"hljs-attr\">writes\u003C/span>: { \u003Cspan class=\"hljs-attr\">memory\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">file\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">distributed\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span> },\n            \u003Cspan class=\"hljs-attr\">totalRequests\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">avgResponseTime\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>\n        };\n    }\n}\n\n\u003Cspan class=\"hljs-variable language_\">module\u003C/span>.\u003Cspan class=\"hljs-property\">exports\u003C/span> = \u003Cspan class=\"hljs-title class_\">AdvancedMarkdownCache\u003C/span>;\n\u003C/code>\u003C/pre>\u003Ch3 id=\"intelligent-cache-invalidation\">Intelligent Cache Invalidation\u003C/h3>\n\u003Cp>Implementing smart cache invalidation based on content dependencies:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-javascript\">\u003Cspan class=\"hljs-comment\">// cache-invalidation-system.js - Smart cache invalidation\u003C/span>\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> chokidar = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;chokidar&#x27;\u003C/span>);\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> path = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;path&#x27;\u003C/span>);\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> crypto = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;crypto&#x27;\u003C/span>);\n\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">CacheInvalidationSystem\u003C/span> {\n    \u003Cspan class=\"hljs-title function_\">constructor\u003C/span>(\u003Cspan class=\"hljs-params\">cache, options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">cache\u003C/span> = cache;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">watchDirectories\u003C/span>: options.\u003Cspan class=\"hljs-property\">watchDirectories\u003C/span> || [],\n            \u003Cspan class=\"hljs-attr\">dependencyTracking\u003C/span>: options.\u003Cspan class=\"hljs-property\">dependencyTracking\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">debounceTime\u003C/span>: options.\u003Cspan class=\"hljs-property\">debounceTime\u003C/span> || \u003Cspan class=\"hljs-number\">1000\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">batchInvalidation\u003C/span>: options.\u003Cspan class=\"hljs-property\">batchInvalidation\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            ...options\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">dependencies\u003C/span> = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>(); \u003Cspan class=\"hljs-comment\">// content -&gt; [dependent cache keys]\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">watchers\u003C/span> = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">pendingInvalidations\u003C/span> = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Set\u003C/span>();\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">invalidationTimer\u003C/span> = \u003Cspan class=\"hljs-literal\">null\u003C/span>;\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">startWatching\u003C/span>();\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">startWatching\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> directory \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">watchDirectories\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> watcher = chokidar.\u003Cspan class=\"hljs-title function_\">watch\u003C/span>(directory, {\n                \u003Cspan class=\"hljs-attr\">ignored\u003C/span>: \u003Cspan class=\"hljs-regexp\">/(^|[\\/\\\\])\\../\u003C/span>, \u003Cspan class=\"hljs-comment\">// ignore dotfiles\u003C/span>\n                \u003Cspan class=\"hljs-attr\">persistent\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">ignoreInitial\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span>\n            });\n            \n            watcher\n                .\u003Cspan class=\"hljs-title function_\">on\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;change&#x27;\u003C/span>, \u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">filePath\u003C/span>) =&gt;\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">handleFileChange\u003C/span>(filePath))\n                .\u003Cspan class=\"hljs-title function_\">on\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;add&#x27;\u003C/span>, \u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">filePath\u003C/span>) =&gt;\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">handleFileAdd\u003C/span>(filePath))\n                .\u003Cspan class=\"hljs-title function_\">on\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;unlink&#x27;\u003C/span>, \u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">filePath\u003C/span>) =&gt;\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">handleFileDelete\u003C/span>(filePath));\n            \n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">watchers\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(directory, watcher);\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">registerDependency\u003C/span>(\u003Cspan class=\"hljs-params\">sourceFile, cacheKey, dependentFiles = []\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Track which cache keys depend on which files\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> dependencies = [sourceFile, ...dependentFiles];\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> dep \u003Cspan class=\"hljs-keyword\">of\u003C/span> dependencies) {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">dependencies\u003C/span>.\u003Cspan class=\"hljs-title function_\">has\u003C/span>(dep)) {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">dependencies\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(dep, \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Set\u003C/span>());\n            }\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">dependencies\u003C/span>.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(dep).\u003Cspan class=\"hljs-title function_\">add\u003C/span>(cacheKey);\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">handleFileChange\u003C/span>(\u003Cspan class=\"hljs-params\">filePath\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`File changed: \u003Cspan class=\"hljs-subst\">${filePath}\u003C/span>`\u003C/span>);\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">scheduleInvalidation\u003C/span>(filePath);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">handleFileAdd\u003C/span>(\u003Cspan class=\"hljs-params\">filePath\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`File added: \u003Cspan class=\"hljs-subst\">${filePath}\u003C/span>`\u003C/span>);\n        \u003Cspan class=\"hljs-comment\">// New files might affect existing cached content\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">schedulePatternInvalidation\u003C/span>(path.\u003Cspan class=\"hljs-title function_\">dirname\u003C/span>(filePath));\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">handleFileDelete\u003C/span>(\u003Cspan class=\"hljs-params\">filePath\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`File deleted: \u003Cspan class=\"hljs-subst\">${filePath}\u003C/span>`\u003C/span>);\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">scheduleInvalidation\u003C/span>(filePath);\n        \n        \u003Cspan class=\"hljs-comment\">// Clean up dependency tracking\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">dependencies\u003C/span>.\u003Cspan class=\"hljs-title function_\">delete\u003C/span>(filePath);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">scheduleInvalidation\u003C/span>(\u003Cspan class=\"hljs-params\">filePath\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">pendingInvalidations\u003C/span>.\u003Cspan class=\"hljs-title function_\">add\u003C/span>(filePath);\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">batchInvalidation\u003C/span>) {\n            \u003Cspan class=\"hljs-comment\">// Batch invalidations to reduce overhead\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">invalidationTimer\u003C/span>) {\n                \u003Cspan class=\"hljs-built_in\">clearTimeout\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">invalidationTimer\u003C/span>);\n            }\n            \n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">invalidationTimer\u003C/span> = \u003Cspan class=\"hljs-built_in\">setTimeout\u003C/span>(\u003Cspan class=\"hljs-function\">() =&gt;\u003C/span> {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">executeBatchInvalidation\u003C/span>();\n            }, \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">debounceTime\u003C/span>);\n        } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">invalidateFile\u003C/span>(filePath);\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">schedulePatternInvalidation\u003C/span>(\u003Cspan class=\"hljs-params\">pattern\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">batchInvalidation\u003C/span>) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">pendingInvalidations\u003C/span>.\u003Cspan class=\"hljs-title function_\">add\u003C/span>(\u003Cspan class=\"hljs-string\">`pattern:\u003Cspan class=\"hljs-subst\">${pattern}\u003C/span>`\u003C/span>);\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">invalidationTimer\u003C/span>) {\n                \u003Cspan class=\"hljs-built_in\">clearTimeout\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">invalidationTimer\u003C/span>);\n            }\n            \n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">invalidationTimer\u003C/span> = \u003Cspan class=\"hljs-built_in\">setTimeout\u003C/span>(\u003Cspan class=\"hljs-function\">() =&gt;\u003C/span> {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">executeBatchInvalidation\u003C/span>();\n            }, \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">debounceTime\u003C/span>);\n        } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">cache\u003C/span>.\u003Cspan class=\"hljs-title function_\">invalidatePattern\u003C/span>(pattern);\n        }\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">executeBatchInvalidation\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> invalidations = \u003Cspan class=\"hljs-title class_\">Array\u003C/span>.\u003Cspan class=\"hljs-title function_\">from\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">pendingInvalidations\u003C/span>);\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">pendingInvalidations\u003C/span>.\u003Cspan class=\"hljs-title function_\">clear\u003C/span>();\n        \n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Executing batch invalidation for \u003Cspan class=\"hljs-subst\">${invalidations.length}\u003C/span> items`\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> totalInvalidated = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> item \u003Cspan class=\"hljs-keyword\">of\u003C/span> invalidations) {\n            \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (item.\u003Cspan class=\"hljs-title function_\">startsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;pattern:&#x27;\u003C/span>)) {\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> pattern = item.\u003Cspan class=\"hljs-title function_\">substring\u003C/span>(\u003Cspan class=\"hljs-number\">8\u003C/span>);\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> count = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">cache\u003C/span>.\u003Cspan class=\"hljs-title function_\">invalidatePattern\u003C/span>(pattern);\n                    totalInvalidated += count;\n                } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> count = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">invalidateFile\u003C/span>(item);\n                    totalInvalidated += count;\n                }\n            } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">`Error invalidating \u003Cspan class=\"hljs-subst\">${item}\u003C/span>: \u003Cspan class=\"hljs-subst\">${error.message}\u003C/span>`\u003C/span>);\n            }\n        }\n        \n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Batch invalidation complete: \u003Cspan class=\"hljs-subst\">${totalInvalidated}\u003C/span> cache entries invalidated`\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">invalidateFile\u003C/span>(\u003Cspan class=\"hljs-params\">filePath\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> invalidated = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \n        \u003Cspan class=\"hljs-comment\">// Direct dependencies\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">dependencies\u003C/span>.\u003Cspan class=\"hljs-title function_\">has\u003C/span>(filePath)) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> dependentKeys = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">dependencies\u003C/span>.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(filePath);\n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> key \u003Cspan class=\"hljs-keyword\">of\u003C/span> dependentKeys) {\n                \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">cache\u003C/span>.\u003Cspan class=\"hljs-title function_\">delete\u003C/span>(key);\n                invalidated++;\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Pattern-based invalidation for related files\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> fileName = path.\u003Cspan class=\"hljs-title function_\">basename\u003C/span>(filePath, path.\u003Cspan class=\"hljs-title function_\">extname\u003C/span>(filePath));\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> additionalCount = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">cache\u003C/span>.\u003Cspan class=\"hljs-title function_\">invalidatePattern\u003C/span>(fileName);\n        invalidated += additionalCount;\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> invalidated;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">analyzeContentDependencies\u003C/span>(\u003Cspan class=\"hljs-params\">markdownFiles\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Analyzing content dependencies...&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> dependencyGraph = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> filePath \u003Cspan class=\"hljs-keyword\">of\u003C/span> markdownFiles) {\n            \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> content = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;fs&#x27;\u003C/span>).\u003Cspan class=\"hljs-property\">promises\u003C/span>.\u003Cspan class=\"hljs-title function_\">readFile\u003C/span>(filePath, \u003Cspan class=\"hljs-string\">&#x27;utf8&#x27;\u003C/span>);\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> dependencies = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">extractDependencies\u003C/span>(content, filePath);\n                dependencyGraph.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(filePath, dependencies);\n            } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">warn\u003C/span>(\u003Cspan class=\"hljs-string\">`Error analyzing dependencies for \u003Cspan class=\"hljs-subst\">${filePath}\u003C/span>: \u003Cspan class=\"hljs-subst\">${error.message}\u003C/span>`\u003C/span>);\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Build reverse dependency map\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> [file, deps] \u003Cspan class=\"hljs-keyword\">of\u003C/span> dependencyGraph) {\n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> dep \u003Cspan class=\"hljs-keyword\">of\u003C/span> deps.\u003Cspan class=\"hljs-property\">files\u003C/span>) {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">registerDependency\u003C/span>(dep, \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">cache\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateCacheKey\u003C/span>(file), [file]);\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> dependencyGraph;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">extractDependencies\u003C/span>(\u003Cspan class=\"hljs-params\">content, filePath\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> dependencies = {\n            \u003Cspan class=\"hljs-attr\">files\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Set\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">images\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Set\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">links\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Set\u003C/span>()\n        };\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> baseDir = path.\u003Cspan class=\"hljs-title function_\">dirname\u003C/span>(filePath);\n        \n        \u003Cspan class=\"hljs-comment\">// Extract file references\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> fileReferences = content.\u003Cspan class=\"hljs-title function_\">match\u003C/span>(\u003Cspan class=\"hljs-regexp\">/\\[([^\\]]*)\\]\\(([^)]+)\\)/g\u003C/span>) || [];\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> ref \u003Cspan class=\"hljs-keyword\">of\u003C/span> fileReferences) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> match = ref.\u003Cspan class=\"hljs-title function_\">match\u003C/span>(\u003Cspan class=\"hljs-regexp\">/\\[([^\\]]*)\\]\\(([^)]+)\\)/\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (match) {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> linkPath = match[\u003Cspan class=\"hljs-number\">2\u003C/span>];\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!linkPath.\u003Cspan class=\"hljs-title function_\">startsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;http&#x27;\u003C/span>) &amp;&amp; !linkPath.\u003Cspan class=\"hljs-title function_\">startsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;//&#x27;\u003C/span>)) {\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> resolvedPath = path.\u003Cspan class=\"hljs-title function_\">resolve\u003C/span>(baseDir, linkPath);\n                    \u003Cspan class=\"hljs-keyword\">if\u003C/span> (linkPath.\u003Cspan class=\"hljs-title function_\">endsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.md&#x27;\u003C/span>)) {\n                        dependencies.\u003Cspan class=\"hljs-property\">files\u003C/span>.\u003Cspan class=\"hljs-title function_\">add\u003C/span>(resolvedPath);\n                    } \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-regexp\">/\\.(jpg|jpeg|png|gif|svg|webp)$/i\u003C/span>.\u003Cspan class=\"hljs-title function_\">test\u003C/span>(linkPath)) {\n                        dependencies.\u003Cspan class=\"hljs-property\">images\u003C/span>.\u003Cspan class=\"hljs-title function_\">add\u003C/span>(resolvedPath);\n                    }\n                    dependencies.\u003Cspan class=\"hljs-property\">links\u003C/span>.\u003Cspan class=\"hljs-title function_\">add\u003C/span>(resolvedPath);\n                }\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Extract image references\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> imageReferences = content.\u003Cspan class=\"hljs-title function_\">match\u003C/span>(\u003Cspan class=\"hljs-regexp\">/!\\[([^\\]]*)\\]\\(([^)]+)\\)/g\u003C/span>) || [];\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> ref \u003Cspan class=\"hljs-keyword\">of\u003C/span> imageReferences) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> match = ref.\u003Cspan class=\"hljs-title function_\">match\u003C/span>(\u003Cspan class=\"hljs-regexp\">/!\\[([^\\]]*)\\]\\(([^)]+)\\)/\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (match) {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> imagePath = match[\u003Cspan class=\"hljs-number\">2\u003C/span>];\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!imagePath.\u003Cspan class=\"hljs-title function_\">startsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;http&#x27;\u003C/span>)) {\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> resolvedPath = path.\u003Cspan class=\"hljs-title function_\">resolve\u003C/span>(baseDir, imagePath);\n                    dependencies.\u003Cspan class=\"hljs-property\">images\u003C/span>.\u003Cspan class=\"hljs-title function_\">add\u003C/span>(resolvedPath);\n                }\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-attr\">files\u003C/span>: \u003Cspan class=\"hljs-title class_\">Array\u003C/span>.\u003Cspan class=\"hljs-title function_\">from\u003C/span>(dependencies.\u003Cspan class=\"hljs-property\">files\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">images\u003C/span>: \u003Cspan class=\"hljs-title class_\">Array\u003C/span>.\u003Cspan class=\"hljs-title function_\">from\u003C/span>(dependencies.\u003Cspan class=\"hljs-property\">images\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">links\u003C/span>: \u003Cspan class=\"hljs-title class_\">Array\u003C/span>.\u003Cspan class=\"hljs-title function_\">from\u003C/span>(dependencies.\u003Cspan class=\"hljs-property\">links\u003C/span>)\n        };\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">stop\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> [directory, watcher] \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">watchers\u003C/span>) {\n            watcher.\u003Cspan class=\"hljs-title function_\">close\u003C/span>();\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">invalidationTimer\u003C/span>) {\n            \u003Cspan class=\"hljs-built_in\">clearTimeout\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">invalidationTimer\u003C/span>);\n        }\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">watchers\u003C/span>.\u003Cspan class=\"hljs-title function_\">clear\u003C/span>();\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">dependencies\u003C/span>.\u003Cspan class=\"hljs-title function_\">clear\u003C/span>();\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">pendingInvalidations\u003C/span>.\u003Cspan class=\"hljs-title function_\">clear\u003C/span>();\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">getInvalidationStats\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-attr\">trackedDependencies\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">dependencies\u003C/span>.\u003Cspan class=\"hljs-property\">size\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">watchedDirectories\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">watchers\u003C/span>.\u003Cspan class=\"hljs-property\">size\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">pendingInvalidations\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">pendingInvalidations\u003C/span>.\u003Cspan class=\"hljs-property\">size\u003C/span>\n        };\n    }\n}\n\n\u003Cspan class=\"hljs-variable language_\">module\u003C/span>.\u003Cspan class=\"hljs-property\">exports\u003C/span> = \u003Cspan class=\"hljs-title class_\">CacheInvalidationSystem\u003C/span>;\n\u003C/code>\u003C/pre>\u003Ch2 id=\"streaming-and-batch-processing\">Streaming and Batch Processing\u003C/h2>\n\u003Ch3 id=\"high-volume-document-processing\">High-Volume Document Processing\u003C/h3>\n\u003Cp>Optimizing for processing large volumes of Markdown content:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-javascript\">\u003Cspan class=\"hljs-comment\">// streaming-processor.js - High-performance streaming Markdown processor\u003C/span>\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> { \u003Cspan class=\"hljs-title class_\">Transform\u003C/span>, \u003Cspan class=\"hljs-title class_\">Readable\u003C/span>, \u003Cspan class=\"hljs-title class_\">Writable\u003C/span> } = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;stream&#x27;\u003C/span>);\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> { pipeline } = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;stream/promises&#x27;\u003C/span>);\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> fs = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;fs&#x27;\u003C/span>).\u003Cspan class=\"hljs-property\">promises\u003C/span>;\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> path = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;path&#x27;\u003C/span>);\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> marked = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;marked&#x27;\u003C/span>);\n\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">StreamingMarkdownProcessor\u003C/span> {\n    \u003Cspan class=\"hljs-title function_\">constructor\u003C/span>(\u003Cspan class=\"hljs-params\">options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">batchSize\u003C/span>: options.\u003Cspan class=\"hljs-property\">batchSize\u003C/span> || \u003Cspan class=\"hljs-number\">50\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">maxConcurrency\u003C/span>: options.\u003Cspan class=\"hljs-property\">maxConcurrency\u003C/span> || \u003Cspan class=\"hljs-number\">10\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">enableProfiling\u003C/span>: options.\u003Cspan class=\"hljs-property\">enableProfiling\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">outputFormat\u003C/span>: options.\u003Cspan class=\"hljs-property\">outputFormat\u003C/span> || \u003Cspan class=\"hljs-string\">&#x27;html&#x27;\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">chunkSize\u003C/span>: options.\u003Cspan class=\"hljs-property\">chunkSize\u003C/span> || \u003Cspan class=\"hljs-number\">64\u003C/span> * \u003Cspan class=\"hljs-number\">1024\u003C/span>, \u003Cspan class=\"hljs-comment\">// 64KB chunks\u003C/span>\n            ...options\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">processingStats\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">filesProcessed\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">totalSize\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">totalTime\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">averageSpeed\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">errors\u003C/span>: []\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">activeJobs\u003C/span> = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Set\u003C/span>();\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">processDirectory\u003C/span>(\u003Cspan class=\"hljs-params\">inputDir, outputDir, filter = \u003Cspan class=\"hljs-string\">&#x27;**/*.md&#x27;\u003C/span>\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Starting streaming processing of \u003Cspan class=\"hljs-subst\">${inputDir}\u003C/span>`\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> startTime = \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n        \n        \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n            \u003Cspan class=\"hljs-comment\">// Create file stream\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> fileStream = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">createFileStream\u003C/span>(inputDir, filter);\n            \n            \u003Cspan class=\"hljs-comment\">// Create processing pipeline\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> processingStream = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">createProcessingStream\u003C/span>();\n            \n            \u003Cspan class=\"hljs-comment\">// Create output stream\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> outputStream = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">createOutputStreamStream\u003C/span>(outputDir);\n            \n            \u003Cspan class=\"hljs-comment\">// Execute pipeline\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-title function_\">pipeline\u003C/span>(\n                fileStream,\n                processingStream,\n                outputStream\n            );\n            \n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> endTime = \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">processingStats\u003C/span>.\u003Cspan class=\"hljs-property\">totalTime\u003C/span> = endTime - startTime;\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">processingStats\u003C/span>.\u003Cspan class=\"hljs-property\">averageSpeed\u003C/span> = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">processingStats\u003C/span>.\u003Cspan class=\"hljs-property\">totalSize\u003C/span> / (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">processingStats\u003C/span>.\u003Cspan class=\"hljs-property\">totalTime\u003C/span> / \u003Cspan class=\"hljs-number\">1000\u003C/span>);\n            \n            \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Processing completed: \u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.processingStats.filesProcessed}\u003C/span> files in \u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.processingStats.totalTime}\u003C/span>ms`\u003C/span>);\n            \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Average speed: \u003Cspan class=\"hljs-subst\">${(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.processingStats.averageSpeed / \u003Cspan class=\"hljs-number\">1024\u003C/span> / \u003Cspan class=\"hljs-number\">1024\u003C/span>).toFixed(\u003Cspan class=\"hljs-number\">2\u003C/span>)}\u003C/span> MB/s`\u003C/span>);\n            \n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">processingStats\u003C/span>;\n            \n        } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n            \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Streaming processing failed:&#x27;\u003C/span>, error);\n            \u003Cspan class=\"hljs-keyword\">throw\u003C/span> error;\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">createFileStream\u003C/span>(\u003Cspan class=\"hljs-params\">inputDir, filter\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Readable\u003C/span>({\n            \u003Cspan class=\"hljs-attr\">objectMode\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span>,\n            \n            \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">read\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> files = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">findFiles\u003C/span>(inputDir, filter);\n                    \n                    \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> file \u003Cspan class=\"hljs-keyword\">of\u003C/span> files) {\n                        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                            \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;file&#x27;\u003C/span>,\n                            \u003Cspan class=\"hljs-attr\">path\u003C/span>: file.\u003Cspan class=\"hljs-property\">path\u003C/span>,\n                            \u003Cspan class=\"hljs-attr\">size\u003C/span>: file.\u003Cspan class=\"hljs-property\">size\u003C/span>,\n                            \u003Cspan class=\"hljs-attr\">relativePath\u003C/span>: path.\u003Cspan class=\"hljs-title function_\">relative\u003C/span>(inputDir, file.\u003Cspan class=\"hljs-property\">path\u003C/span>)\n                        });\n                    }\n                    \n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-literal\">null\u003C/span>); \u003Cspan class=\"hljs-comment\">// End of stream\u003C/span>\n                } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">emit\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;error&#x27;\u003C/span>, error);\n                }\n            },\n            \n            \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">findFiles\u003C/span>(\u003Cspan class=\"hljs-params\">dir, pattern\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> files = [];\n                \n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> \u003Cspan class=\"hljs-title function_\">scan\u003C/span> = \u003Cspan class=\"hljs-keyword\">async\u003C/span> (\u003Cspan class=\"hljs-params\">currentDir\u003C/span>) =&gt; {\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> entries = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">readdir\u003C/span>(currentDir, { \u003Cspan class=\"hljs-attr\">withFileTypes\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span> });\n                    \n                    \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> entry \u003Cspan class=\"hljs-keyword\">of\u003C/span> entries) {\n                        \u003Cspan class=\"hljs-keyword\">const\u003C/span> fullPath = path.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(currentDir, entry.\u003Cspan class=\"hljs-property\">name\u003C/span>);\n                        \n                        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (entry.\u003Cspan class=\"hljs-title function_\">isDirectory\u003C/span>() &amp;&amp; !entry.\u003Cspan class=\"hljs-property\">name\u003C/span>.\u003Cspan class=\"hljs-title function_\">startsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.&#x27;\u003C/span>)) {\n                            \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-title function_\">scan\u003C/span>(fullPath);\n                        } \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (entry.\u003Cspan class=\"hljs-title function_\">isFile\u003C/span>() &amp;&amp; entry.\u003Cspan class=\"hljs-property\">name\u003C/span>.\u003Cspan class=\"hljs-title function_\">endsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.md&#x27;\u003C/span>)) {\n                            \u003Cspan class=\"hljs-keyword\">const\u003C/span> stats = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">stat\u003C/span>(fullPath);\n                            files.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                                \u003Cspan class=\"hljs-attr\">path\u003C/span>: fullPath,\n                                \u003Cspan class=\"hljs-attr\">size\u003C/span>: stats.\u003Cspan class=\"hljs-property\">size\u003C/span>,\n                                \u003Cspan class=\"hljs-attr\">modified\u003C/span>: stats.\u003Cspan class=\"hljs-property\">mtime\u003C/span>\n                            });\n                        }\n                    }\n                };\n                \n                \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-title function_\">scan\u003C/span>(dir);\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> files;\n            }\n        });\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">createProcessingStream\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> batchBuffer = [];\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> processing = \u003Cspan class=\"hljs-literal\">false\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Transform\u003C/span>({\n            \u003Cspan class=\"hljs-attr\">objectMode\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span>,\n            \n            \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">_transform\u003C/span>(\u003Cspan class=\"hljs-params\">fileInfo, encoding, callback\u003C/span>) {\n                batchBuffer.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(fileInfo);\n                \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (batchBuffer.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt;= \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">batchSize\u003C/span> &amp;&amp; !processing) {\n                    processing = \u003Cspan class=\"hljs-literal\">true\u003C/span>;\n                    \n                    \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                        \u003Cspan class=\"hljs-keyword\">const\u003C/span> batch = batchBuffer.\u003Cspan class=\"hljs-title function_\">splice\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">batchSize\u003C/span>);\n                        \u003Cspan class=\"hljs-keyword\">const\u003C/span> results = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">processBatch\u003C/span>(batch);\n                        \n                        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> result \u003Cspan class=\"hljs-keyword\">of\u003C/span> results) {\n                            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(result);\n                        }\n                        \n                        processing = \u003Cspan class=\"hljs-literal\">false\u003C/span>;\n                        \u003Cspan class=\"hljs-title function_\">callback\u003C/span>();\n                        \n                    } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                        processing = \u003Cspan class=\"hljs-literal\">false\u003C/span>;\n                        \u003Cspan class=\"hljs-title function_\">callback\u003C/span>(error);\n                    }\n                } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n                    \u003Cspan class=\"hljs-title function_\">callback\u003C/span>();\n                }\n            },\n            \n            \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">_flush\u003C/span>(\u003Cspan class=\"hljs-params\">callback\u003C/span>) {\n                \u003Cspan class=\"hljs-comment\">// Process remaining items in batch\u003C/span>\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (batchBuffer.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n                    \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                        \u003Cspan class=\"hljs-keyword\">const\u003C/span> results = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">processBatch\u003C/span>(batchBuffer);\n                        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> result \u003Cspan class=\"hljs-keyword\">of\u003C/span> results) {\n                            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(result);\n                        }\n                        \u003Cspan class=\"hljs-title function_\">callback\u003C/span>();\n                    } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                        \u003Cspan class=\"hljs-title function_\">callback\u003C/span>(error);\n                    }\n                } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n                    \u003Cspan class=\"hljs-title function_\">callback\u003C/span>();\n                }\n            }\n        });\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">processBatch\u003C/span>(\u003Cspan class=\"hljs-params\">batch\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> semaphore = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Semaphore\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">maxConcurrency\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> promises = batch.\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-keyword\">async\u003C/span> (fileInfo) =&gt; {\n            \u003Cspan class=\"hljs-keyword\">await\u003C/span> semaphore.\u003Cspan class=\"hljs-title function_\">acquire\u003C/span>();\n            \n            \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">processFile\u003C/span>(fileInfo);\n            } \u003Cspan class=\"hljs-keyword\">finally\u003C/span> {\n                semaphore.\u003Cspan class=\"hljs-title function_\">release\u003C/span>();\n            }\n        });\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> results = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-title class_\">Promise\u003C/span>.\u003Cspan class=\"hljs-title function_\">allSettled\u003C/span>(promises);\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> results.\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">result, index\u003C/span>) =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (result.\u003Cspan class=\"hljs-property\">status\u003C/span> === \u003Cspan class=\"hljs-string\">&#x27;fulfilled&#x27;\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> result.\u003Cspan class=\"hljs-property\">value\u003C/span>;\n            } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">processingStats\u003C/span>.\u003Cspan class=\"hljs-property\">errors\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">file\u003C/span>: batch[index].\u003Cspan class=\"hljs-property\">path\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">error\u003C/span>: result.\u003Cspan class=\"hljs-property\">reason\u003C/span>.\u003Cspan class=\"hljs-property\">message\u003C/span>\n                });\n                \n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n                    \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;error&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">file\u003C/span>: batch[index].\u003Cspan class=\"hljs-property\">path\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">error\u003C/span>: result.\u003Cspan class=\"hljs-property\">reason\u003C/span>.\u003Cspan class=\"hljs-property\">message\u003C/span>\n                };\n            }\n        });\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">processFile\u003C/span>(\u003Cspan class=\"hljs-params\">fileInfo\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> startTime = \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n        \n        \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n            \u003Cspan class=\"hljs-comment\">// Read file content\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> content = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">readFile\u003C/span>(fileInfo.\u003Cspan class=\"hljs-property\">path\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;utf8&#x27;\u003C/span>);\n            \n            \u003Cspan class=\"hljs-comment\">// Process based on output format\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">let\u003C/span> processed;\n            \u003Cspan class=\"hljs-keyword\">switch\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">outputFormat\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;html&#x27;\u003C/span>:\n                    processed = \u003Cspan class=\"hljs-title function_\">marked\u003C/span>(content);\n                    \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n                \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;tokens&#x27;\u003C/span>:\n                    processed = marked.\u003Cspan class=\"hljs-title function_\">lexer\u003C/span>(content);\n                    \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n                \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;ast&#x27;\u003C/span>:\n                    processed = marked.\u003Cspan class=\"hljs-title function_\">parse\u003C/span>(content, { \u003Cspan class=\"hljs-attr\">async\u003C/span>: \u003Cspan class=\"hljs-literal\">false\u003C/span> });\n                    \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n                \u003Cspan class=\"hljs-attr\">default\u003C/span>:\n                    processed = content;\n            }\n            \n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> endTime = \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n            \n            \u003Cspan class=\"hljs-comment\">// Update statistics\u003C/span>\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">processingStats\u003C/span>.\u003Cspan class=\"hljs-property\">filesProcessed\u003C/span>++;\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">processingStats\u003C/span>.\u003Cspan class=\"hljs-property\">totalSize\u003C/span> += fileInfo.\u003Cspan class=\"hljs-property\">size\u003C/span>;\n            \n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;processed&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">file\u003C/span>: fileInfo.\u003Cspan class=\"hljs-property\">path\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">relativePath\u003C/span>: fileInfo.\u003Cspan class=\"hljs-property\">relativePath\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">content\u003C/span>: processed,\n                \u003Cspan class=\"hljs-attr\">size\u003C/span>: fileInfo.\u003Cspan class=\"hljs-property\">size\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">processingTime\u003C/span>: endTime - startTime,\n                \u003Cspan class=\"hljs-attr\">outputSize\u003C/span>: \u003Cspan class=\"hljs-keyword\">typeof\u003C/span> processed === \u003Cspan class=\"hljs-string\">&#x27;string&#x27;\u003C/span> ? processed.\u003Cspan class=\"hljs-property\">length\u003C/span> : \u003Cspan class=\"hljs-title class_\">JSON\u003C/span>.\u003Cspan class=\"hljs-title function_\">stringify\u003C/span>(processed).\u003Cspan class=\"hljs-property\">length\u003C/span>\n            };\n            \n        } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;error&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">file\u003C/span>: fileInfo.\u003Cspan class=\"hljs-property\">path\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">error\u003C/span>: error.\u003Cspan class=\"hljs-property\">message\u003C/span>\n            };\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">createOutputStream\u003C/span>(\u003Cspan class=\"hljs-params\">outputDir\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Writable\u003C/span>({\n            \u003Cspan class=\"hljs-attr\">objectMode\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span>,\n            \n            \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">write\u003C/span>(\u003Cspan class=\"hljs-params\">result, encoding, callback\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                    \u003Cspan class=\"hljs-keyword\">if\u003C/span> (result.\u003Cspan class=\"hljs-property\">type\u003C/span> === \u003Cspan class=\"hljs-string\">&#x27;processed&#x27;\u003C/span>) {\n                        \u003Cspan class=\"hljs-keyword\">const\u003C/span> outputPath = path.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(outputDir, \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">getOutputFileName\u003C/span>(result.\u003Cspan class=\"hljs-property\">relativePath\u003C/span>));\n                        \n                        \u003Cspan class=\"hljs-comment\">// Ensure output directory exists\u003C/span>\n                        \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">mkdir\u003C/span>(path.\u003Cspan class=\"hljs-title function_\">dirname\u003C/span>(outputPath), { \u003Cspan class=\"hljs-attr\">recursive\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span> });\n                        \n                        \u003Cspan class=\"hljs-comment\">// Write processed content\u003C/span>\n                        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-keyword\">typeof\u003C/span> result.\u003Cspan class=\"hljs-property\">content\u003C/span> === \u003Cspan class=\"hljs-string\">&#x27;string&#x27;\u003C/span>) {\n                            \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">writeFile\u003C/span>(outputPath, result.\u003Cspan class=\"hljs-property\">content\u003C/span>);\n                        } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n                            \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">writeFile\u003C/span>(outputPath, \u003Cspan class=\"hljs-title class_\">JSON\u003C/span>.\u003Cspan class=\"hljs-title function_\">stringify\u003C/span>(result.\u003Cspan class=\"hljs-property\">content\u003C/span>, \u003Cspan class=\"hljs-literal\">null\u003C/span>, \u003Cspan class=\"hljs-number\">2\u003C/span>));\n                        }\n                    }\n                    \n                    \u003Cspan class=\"hljs-title function_\">callback\u003C/span>();\n                } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                    \u003Cspan class=\"hljs-title function_\">callback\u003C/span>(error);\n                }\n            }\n        });\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">getOutputFileName\u003C/span>(\u003Cspan class=\"hljs-params\">relativePath\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> ext = path.\u003Cspan class=\"hljs-title function_\">extname\u003C/span>(relativePath);\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> baseName = path.\u003Cspan class=\"hljs-title function_\">basename\u003C/span>(relativePath, ext);\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> dirName = path.\u003Cspan class=\"hljs-title function_\">dirname\u003C/span>(relativePath);\n        \n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> outputExt;\n        \u003Cspan class=\"hljs-keyword\">switch\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">outputFormat\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;html&#x27;\u003C/span>:\n                outputExt = \u003Cspan class=\"hljs-string\">&#x27;.html&#x27;\u003C/span>;\n                \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n            \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;tokens&#x27;\u003C/span>:\n            \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;ast&#x27;\u003C/span>:\n                outputExt = \u003Cspan class=\"hljs-string\">&#x27;.json&#x27;\u003C/span>;\n                \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n            \u003Cspan class=\"hljs-attr\">default\u003C/span>:\n                outputExt = ext;\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> path.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(dirName, baseName + outputExt);\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">processLargeFile\u003C/span>(\u003Cspan class=\"hljs-params\">filePath, chunkProcessor\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// For very large files, process in chunks\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> fileHandle = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">open\u003C/span>(filePath, \u003Cspan class=\"hljs-string\">&#x27;r&#x27;\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> buffer = \u003Cspan class=\"hljs-title class_\">Buffer\u003C/span>.\u003Cspan class=\"hljs-title function_\">alloc\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">chunkSize\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> position = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> remainingContent = \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">while\u003C/span> (\u003Cspan class=\"hljs-literal\">true\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> { bytesRead } = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fileHandle.\u003Cspan class=\"hljs-title function_\">read\u003C/span>(buffer, \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">chunkSize\u003C/span>, position);\n                \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (bytesRead === \u003Cspan class=\"hljs-number\">0\u003C/span>) \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n                \n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> chunk = buffer.\u003Cspan class=\"hljs-title function_\">subarray\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, bytesRead).\u003Cspan class=\"hljs-title function_\">toString\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;utf8&#x27;\u003C/span>);\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> content = remainingContent + chunk;\n                \n                \u003Cspan class=\"hljs-comment\">// Find complete lines\u003C/span>\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> lines = content.\u003Cspan class=\"hljs-title function_\">split\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>);\n                remainingContent = lines.\u003Cspan class=\"hljs-title function_\">pop\u003C/span>() || \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>; \u003Cspan class=\"hljs-comment\">// Keep incomplete line for next chunk\u003C/span>\n                \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (lines.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> chunkContent = lines.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>);\n                    \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-title function_\">chunkProcessor\u003C/span>(chunkContent, position);\n                }\n                \n                position += bytesRead;\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Process any remaining content\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (remainingContent) {\n                \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-title function_\">chunkProcessor\u003C/span>(remainingContent, position);\n            }\n            \n        } \u003Cspan class=\"hljs-keyword\">finally\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">await\u003C/span> fileHandle.\u003Cspan class=\"hljs-title function_\">close\u003C/span>();\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">getProcessingStats\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            ...\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">processingStats\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">activeJobs\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">activeJobs\u003C/span>.\u003Cspan class=\"hljs-property\">size\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">efficiency\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">processingStats\u003C/span>.\u003Cspan class=\"hljs-property\">totalTime\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span> ? \n                (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">processingStats\u003C/span>.\u003Cspan class=\"hljs-property\">filesProcessed\u003C/span> / (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">processingStats\u003C/span>.\u003Cspan class=\"hljs-property\">totalTime\u003C/span> / \u003Cspan class=\"hljs-number\">1000\u003C/span>)) : \u003Cspan class=\"hljs-number\">0\u003C/span>\n        };\n    }\n}\n\n\u003Cspan class=\"hljs-comment\">// Semaphore for concurrency control\u003C/span>\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">Semaphore\u003C/span> {\n    \u003Cspan class=\"hljs-title function_\">constructor\u003C/span>(\u003Cspan class=\"hljs-params\">maxConcurrent\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">maxConcurrent\u003C/span> = maxConcurrent;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">current\u003C/span> = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">queue\u003C/span> = [];\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">acquire\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">current\u003C/span> &lt; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">maxConcurrent\u003C/span>) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">current\u003C/span>++;\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-title class_\">Promise\u003C/span>.\u003Cspan class=\"hljs-title function_\">resolve\u003C/span>();\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Promise\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">resolve\u003C/span>) =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">queue\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(resolve);\n        });\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">release\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">current\u003C/span>--;\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">queue\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> next = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">queue\u003C/span>.\u003Cspan class=\"hljs-title function_\">shift\u003C/span>();\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">current\u003C/span>++;\n            \u003Cspan class=\"hljs-title function_\">next\u003C/span>();\n        }\n    }\n}\n\n\u003Cspan class=\"hljs-variable language_\">module\u003C/span>.\u003Cspan class=\"hljs-property\">exports\u003C/span> = \u003Cspan class=\"hljs-title class_\">StreamingMarkdownProcessor\u003C/span>;\n\u003C/code>\u003C/pre>\u003Ch2 id=\"integration-with-modern-development-workflows\">Integration with Modern Development Workflows\u003C/h2>\n\u003Cp>Performance optimization integrates seamlessly with comprehensive development workflows. When combined with \u003Ca href=\"/blog/markdown-automation-workflows-complete-guide\">automated testing and validation systems\u003C/a>, performance monitoring becomes part of continuous integration processes, ensuring that content processing efficiency is maintained as systems scale and content volumes increase across development environments.\u003C/p>\n\u003Cp>For sophisticated content management, performance optimization works effectively with \u003Ca href=\"/blog/markdown-link-management-cross-referencing-complete-guide\">link management and cross-referencing systems\u003C/a> to create efficient content relationship processing that maintains performance even as cross-reference complexity grows, enabling real-time content suggestions and automated relationship detection without sacrificing system responsiveness.\u003C/p>\n\u003Cp>When building comprehensive documentation platforms, performance optimization complements \u003Ca href=\"/blog/markdown-progressive-web-app-documentation-complete-guide\">Progressive Web App features and offline capabilities\u003C/a> by ensuring that content processing and caching strategies support instant loading, efficient service worker operations, and responsive user interactions across all device types and network conditions.\u003C/p>\n\u003Ch2 id=\"advanced-performance-monitoring\">Advanced Performance Monitoring\u003C/h2>\n\u003Ch3 id=\"real-time-performance-dashboard\">Real-Time Performance Dashboard\u003C/h3>\n\u003Cpre>\u003Ccode class=\"hljs language-javascript\">\u003Cspan class=\"hljs-comment\">// performance-monitor.js - Real-time performance monitoring system\u003C/span>\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">MarkdownPerformanceDashboard\u003C/span> {\n    \u003Cspan class=\"hljs-title function_\">constructor\u003C/span>(\u003Cspan class=\"hljs-params\">options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">metricsRetention\u003C/span>: options.\u003Cspan class=\"hljs-property\">metricsRetention\u003C/span> || \u003Cspan class=\"hljs-number\">86400000\u003C/span>, \u003Cspan class=\"hljs-comment\">// 24 hours\u003C/span>\n            \u003Cspan class=\"hljs-attr\">samplingRate\u003C/span>: options.\u003Cspan class=\"hljs-property\">samplingRate\u003C/span> || \u003Cspan class=\"hljs-number\">1000\u003C/span>, \u003Cspan class=\"hljs-comment\">// 1 second\u003C/span>\n            \u003Cspan class=\"hljs-attr\">alertThresholds\u003C/span>: options.\u003Cspan class=\"hljs-property\">alertThresholds\u003C/span> || {\n                \u003Cspan class=\"hljs-attr\">responseTime\u003C/span>: \u003Cspan class=\"hljs-number\">5000\u003C/span>, \u003Cspan class=\"hljs-comment\">// 5 seconds\u003C/span>\n                \u003Cspan class=\"hljs-attr\">memoryUsage\u003C/span>: \u003Cspan class=\"hljs-number\">0.8\u003C/span>, \u003Cspan class=\"hljs-comment\">// 80% of available memory\u003C/span>\n                \u003Cspan class=\"hljs-attr\">errorRate\u003C/span>: \u003Cspan class=\"hljs-number\">0.05\u003C/span> \u003Cspan class=\"hljs-comment\">// 5% error rate\u003C/span>\n            },\n            ...options\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">performance\u003C/span>: [],\n            \u003Cspan class=\"hljs-attr\">memory\u003C/span>: [],\n            \u003Cspan class=\"hljs-attr\">errors\u003C/span>: [],\n            \u003Cspan class=\"hljs-attr\">throughput\u003C/span>: []\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">realTimeStats\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">currentRequests\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">avgResponseTime\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">requestCount\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">errorCount\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">startTime\u003C/span>: \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>()\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">startMonitoring\u003C/span>();\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">startMonitoring\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">monitoringInterval\u003C/span> = \u003Cspan class=\"hljs-built_in\">setInterval\u003C/span>(\u003Cspan class=\"hljs-function\">() =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">collectMetrics\u003C/span>();\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">cleanupOldMetrics\u003C/span>();\n        }, \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">samplingRate\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">collectMetrics\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> now = \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> memoryUsage = process.\u003Cspan class=\"hljs-title function_\">memoryUsage\u003C/span>();\n        \n        \u003Cspan class=\"hljs-comment\">// Collect performance metrics\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">performance\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n            \u003Cspan class=\"hljs-attr\">timestamp\u003C/span>: now,\n            \u003Cspan class=\"hljs-attr\">responseTime\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">realTimeStats\u003C/span>.\u003Cspan class=\"hljs-property\">avgResponseTime\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">activeRequests\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">realTimeStats\u003C/span>.\u003Cspan class=\"hljs-property\">currentRequests\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">requestsPerSecond\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">calculateRequestsPerSecond\u003C/span>()\n        });\n        \n        \u003Cspan class=\"hljs-comment\">// Collect memory metrics\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">memory\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n            \u003Cspan class=\"hljs-attr\">timestamp\u003C/span>: now,\n            \u003Cspan class=\"hljs-attr\">heapUsed\u003C/span>: memoryUsage.\u003Cspan class=\"hljs-property\">heapUsed\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">heapTotal\u003C/span>: memoryUsage.\u003Cspan class=\"hljs-property\">heapTotal\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">external\u003C/span>: memoryUsage.\u003Cspan class=\"hljs-property\">external\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">rss\u003C/span>: memoryUsage.\u003Cspan class=\"hljs-property\">rss\u003C/span>\n        });\n        \n        \u003Cspan class=\"hljs-comment\">// Calculate throughput\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> throughput = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">calculateThroughput\u003C/span>();\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">throughput\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n            \u003Cspan class=\"hljs-attr\">timestamp\u003C/span>: now,\n            \u003Cspan class=\"hljs-attr\">documentsPerSecond\u003C/span>: throughput.\u003Cspan class=\"hljs-property\">documentsPerSecond\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">bytesPerSecond\u003C/span>: throughput.\u003Cspan class=\"hljs-property\">bytesPerSecond\u003C/span>\n        });\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">recordRequest\u003C/span>(\u003Cspan class=\"hljs-params\">startTime, endTime, documentSize, success = \u003Cspan class=\"hljs-literal\">true\u003C/span>\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> responseTime = endTime - startTime;\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">realTimeStats\u003C/span>.\u003Cspan class=\"hljs-property\">requestCount\u003C/span>++;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">realTimeStats\u003C/span>.\u003Cspan class=\"hljs-property\">avgResponseTime\u003C/span> = (\n            (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">realTimeStats\u003C/span>.\u003Cspan class=\"hljs-property\">avgResponseTime\u003C/span> * (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">realTimeStats\u003C/span>.\u003Cspan class=\"hljs-property\">requestCount\u003C/span> - \u003Cspan class=\"hljs-number\">1\u003C/span>) + responseTime) \n            / \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">realTimeStats\u003C/span>.\u003Cspan class=\"hljs-property\">requestCount\u003C/span>\n        );\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!success) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">realTimeStats\u003C/span>.\u003Cspan class=\"hljs-property\">errorCount\u003C/span>++;\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">errors\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">timestamp\u003C/span>: \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>(),\n                responseTime,\n                documentSize\n            });\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Check for alerts\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">checkAlerts\u003C/span>(responseTime);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">startRequest\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">realTimeStats\u003C/span>.\u003Cspan class=\"hljs-property\">currentRequests\u003C/span>++;\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">endRequest\u003C/span>(\u003Cspan class=\"hljs-params\">startTime, documentSize, success = \u003Cspan class=\"hljs-literal\">true\u003C/span>\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">realTimeStats\u003C/span>.\u003Cspan class=\"hljs-property\">currentRequests\u003C/span>--;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> endTime = \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">recordRequest\u003C/span>(startTime, endTime, documentSize, success);\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> endTime - startTime;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">calculateRequestsPerSecond\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> timeWindow = \u003Cspan class=\"hljs-number\">60000\u003C/span>; \u003Cspan class=\"hljs-comment\">// 1 minute\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> now = \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> recentMetrics = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">performance\u003C/span>.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\n            \u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">m\u003C/span> =&gt;\u003C/span> now - m.\u003Cspan class=\"hljs-property\">timestamp\u003C/span> &lt; timeWindow\n        );\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> recentMetrics.\u003Cspan class=\"hljs-property\">length\u003C/span> / (timeWindow / \u003Cspan class=\"hljs-number\">1000\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">calculateThroughput\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> timeWindow = \u003Cspan class=\"hljs-number\">60000\u003C/span>; \u003Cspan class=\"hljs-comment\">// 1 minute\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> now = \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n        \n        \u003Cspan class=\"hljs-comment\">// This would need to be tracked separately in practice\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-attr\">documentsPerSecond\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">calculateRequestsPerSecond\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">bytesPerSecond\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">calculateRequestsPerSecond\u003C/span>() * \u003Cspan class=\"hljs-number\">1024\u003C/span> \u003Cspan class=\"hljs-comment\">// Estimated\u003C/span>\n        };\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">checkAlerts\u003C/span>(\u003Cspan class=\"hljs-params\">responseTime\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> memoryUsage = process.\u003Cspan class=\"hljs-title function_\">memoryUsage\u003C/span>();\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> memoryRatio = memoryUsage.\u003Cspan class=\"hljs-property\">heapUsed\u003C/span> / memoryUsage.\u003Cspan class=\"hljs-property\">heapTotal\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> errorRate = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">realTimeStats\u003C/span>.\u003Cspan class=\"hljs-property\">requestCount\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span> ? \n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">realTimeStats\u003C/span>.\u003Cspan class=\"hljs-property\">errorCount\u003C/span> / \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">realTimeStats\u003C/span>.\u003Cspan class=\"hljs-property\">requestCount\u003C/span> : \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \n        \u003Cspan class=\"hljs-comment\">// Response time alert\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (responseTime &gt; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">alertThresholds\u003C/span>.\u003Cspan class=\"hljs-property\">responseTime\u003C/span>) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">triggerAlert\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;high_response_time&#x27;\u003C/span>, {\n                responseTime,\n                \u003Cspan class=\"hljs-attr\">threshold\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">alertThresholds\u003C/span>.\u003Cspan class=\"hljs-property\">responseTime\u003C/span>\n            });\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Memory usage alert\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (memoryRatio &gt; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">alertThresholds\u003C/span>.\u003Cspan class=\"hljs-property\">memoryUsage\u003C/span>) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">triggerAlert\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;high_memory_usage&#x27;\u003C/span>, {\n                memoryRatio,\n                \u003Cspan class=\"hljs-attr\">heapUsed\u003C/span>: memoryUsage.\u003Cspan class=\"hljs-property\">heapUsed\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">threshold\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">alertThresholds\u003C/span>.\u003Cspan class=\"hljs-property\">memoryUsage\u003C/span>\n            });\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Error rate alert\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (errorRate &gt; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">alertThresholds\u003C/span>.\u003Cspan class=\"hljs-property\">errorRate\u003C/span>) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">triggerAlert\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;high_error_rate&#x27;\u003C/span>, {\n                errorRate,\n                \u003Cspan class=\"hljs-attr\">errorCount\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">realTimeStats\u003C/span>.\u003Cspan class=\"hljs-property\">errorCount\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">totalRequests\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">realTimeStats\u003C/span>.\u003Cspan class=\"hljs-property\">requestCount\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">threshold\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">alertThresholds\u003C/span>.\u003Cspan class=\"hljs-property\">errorRate\u003C/span>\n            });\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">triggerAlert\u003C/span>(\u003Cspan class=\"hljs-params\">type, data\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> alert = {\n            type,\n            \u003Cspan class=\"hljs-attr\">timestamp\u003C/span>: \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>(),\n            data\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">warn\u003C/span>(\u003Cspan class=\"hljs-string\">`Performance Alert [\u003Cspan class=\"hljs-subst\">${type}\u003C/span>]:`\u003C/span>, data);\n        \n        \u003Cspan class=\"hljs-comment\">// Emit event for external handling\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">onAlert\u003C/span>) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-title function_\">onAlert\u003C/span>(alert);\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">cleanupOldMetrics\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> cutoff = \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>() - \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">options\u003C/span>.\u003Cspan class=\"hljs-property\">metricsRetention\u003C/span>;\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">performance\u003C/span> = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">performance\u003C/span>.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">m\u003C/span> =&gt;\u003C/span> m.\u003Cspan class=\"hljs-property\">timestamp\u003C/span> &gt; cutoff);\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">memory\u003C/span> = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">memory\u003C/span>.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">m\u003C/span> =&gt;\u003C/span> m.\u003Cspan class=\"hljs-property\">timestamp\u003C/span> &gt; cutoff);\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">errors\u003C/span> = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">errors\u003C/span>.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">m\u003C/span> =&gt;\u003C/span> m.\u003Cspan class=\"hljs-property\">timestamp\u003C/span> &gt; cutoff);\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">throughput\u003C/span> = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">throughput\u003C/span>.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">m\u003C/span> =&gt;\u003C/span> m.\u003Cspan class=\"hljs-property\">timestamp\u003C/span> &gt; cutoff);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">getDashboardData\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> now = \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> uptime = now - \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">realTimeStats\u003C/span>.\u003Cspan class=\"hljs-property\">startTime\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-attr\">realTime\u003C/span>: {\n                ...\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">realTimeStats\u003C/span>,\n                uptime,\n                \u003Cspan class=\"hljs-attr\">errorRate\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">realTimeStats\u003C/span>.\u003Cspan class=\"hljs-property\">requestCount\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span> ? \n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">realTimeStats\u003C/span>.\u003Cspan class=\"hljs-property\">errorCount\u003C/span> / \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">realTimeStats\u003C/span>.\u003Cspan class=\"hljs-property\">requestCount\u003C/span> : \u003Cspan class=\"hljs-number\">0\u003C/span>\n            },\n            \u003Cspan class=\"hljs-attr\">metrics\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">performance\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">performance\u003C/span>.\u003Cspan class=\"hljs-title function_\">slice\u003C/span>(-\u003Cspan class=\"hljs-number\">100\u003C/span>), \u003Cspan class=\"hljs-comment\">// Last 100 data points\u003C/span>\n                \u003Cspan class=\"hljs-attr\">memory\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">memory\u003C/span>.\u003Cspan class=\"hljs-title function_\">slice\u003C/span>(-\u003Cspan class=\"hljs-number\">100\u003C/span>),\n                \u003Cspan class=\"hljs-attr\">throughput\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">throughput\u003C/span>.\u003Cspan class=\"hljs-title function_\">slice\u003C/span>(-\u003Cspan class=\"hljs-number\">100\u003C/span>),\n                \u003Cspan class=\"hljs-attr\">errors\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">errors\u003C/span>.\u003Cspan class=\"hljs-title function_\">slice\u003C/span>(-\u003Cspan class=\"hljs-number\">50\u003C/span>)\n            },\n            \u003Cspan class=\"hljs-attr\">summary\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateSummary\u003C/span>()\n        };\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateSummary\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> timeWindow = \u003Cspan class=\"hljs-number\">3600000\u003C/span>; \u003Cspan class=\"hljs-comment\">// 1 hour\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> now = \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> recentPerformance = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">performance\u003C/span>.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\n            \u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">m\u003C/span> =&gt;\u003C/span> now - m.\u003Cspan class=\"hljs-property\">timestamp\u003C/span> &lt; timeWindow\n        );\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> recentMemory = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">memory\u003C/span>.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\n            \u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">m\u003C/span> =&gt;\u003C/span> now - m.\u003Cspan class=\"hljs-property\">timestamp\u003C/span> &lt; timeWindow\n        );\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> recentErrors = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">errors\u003C/span>.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\n            \u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">m\u003C/span> =&gt;\u003C/span> now - m.\u003Cspan class=\"hljs-property\">timestamp\u003C/span> &lt; timeWindow\n        );\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-attr\">performance\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">avgResponseTime\u003C/span>: recentPerformance.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span> ? \n                    recentPerformance.\u003Cspan class=\"hljs-title function_\">reduce\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">sum, m\u003C/span>) =&gt;\u003C/span> sum + m.\u003Cspan class=\"hljs-property\">responseTime\u003C/span>, \u003Cspan class=\"hljs-number\">0\u003C/span>) / recentPerformance.\u003Cspan class=\"hljs-property\">length\u003C/span> : \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">peakResponseTime\u003C/span>: recentPerformance.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span> ? \n                    \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">max\u003C/span>(...recentPerformance.\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">m\u003C/span> =&gt;\u003C/span> m.\u003Cspan class=\"hljs-property\">responseTime\u003C/span>)) : \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">requestsProcessed\u003C/span>: recentPerformance.\u003Cspan class=\"hljs-property\">length\u003C/span>\n            },\n            \u003Cspan class=\"hljs-attr\">memory\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">avgHeapUsed\u003C/span>: recentMemory.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span> ? \n                    recentMemory.\u003Cspan class=\"hljs-title function_\">reduce\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">sum, m\u003C/span>) =&gt;\u003C/span> sum + m.\u003Cspan class=\"hljs-property\">heapUsed\u003C/span>, \u003Cspan class=\"hljs-number\">0\u003C/span>) / recentMemory.\u003Cspan class=\"hljs-property\">length\u003C/span> : \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">peakHeapUsed\u003C/span>: recentMemory.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span> ? \n                    \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">max\u003C/span>(...recentMemory.\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">m\u003C/span> =&gt;\u003C/span> m.\u003Cspan class=\"hljs-property\">heapUsed\u003C/span>)) : \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">memoryGrowth\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">calculateMemoryGrowth\u003C/span>(recentMemory)\n            },\n            \u003Cspan class=\"hljs-attr\">errors\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">totalErrors\u003C/span>: recentErrors.\u003Cspan class=\"hljs-property\">length\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">errorRate\u003C/span>: recentPerformance.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span> ? \n                    recentErrors.\u003Cspan class=\"hljs-property\">length\u003C/span> / recentPerformance.\u003Cspan class=\"hljs-property\">length\u003C/span> : \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">avgErrorResponseTime\u003C/span>: recentErrors.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span> ? \n                    recentErrors.\u003Cspan class=\"hljs-title function_\">reduce\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">sum, e\u003C/span>) =&gt;\u003C/span> sum + e.\u003Cspan class=\"hljs-property\">responseTime\u003C/span>, \u003Cspan class=\"hljs-number\">0\u003C/span>) / recentErrors.\u003Cspan class=\"hljs-property\">length\u003C/span> : \u003Cspan class=\"hljs-number\">0\u003C/span>\n            }\n        };\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">calculateMemoryGrowth\u003C/span>(\u003Cspan class=\"hljs-params\">memoryData\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (memoryData.\u003Cspan class=\"hljs-property\">length\u003C/span> &lt; \u003Cspan class=\"hljs-number\">2\u003C/span>) \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> first = memoryData[\u003Cspan class=\"hljs-number\">0\u003C/span>];\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> last = memoryData[memoryData.\u003Cspan class=\"hljs-property\">length\u003C/span> - \u003Cspan class=\"hljs-number\">1\u003C/span>];\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> (last.\u003Cspan class=\"hljs-property\">heapUsed\u003C/span> - first.\u003Cspan class=\"hljs-property\">heapUsed\u003C/span>) / first.\u003Cspan class=\"hljs-property\">heapUsed\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">stop\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">monitoringInterval\u003C/span>) {\n            \u003Cspan class=\"hljs-built_in\">clearInterval\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">monitoringInterval\u003C/span>);\n        }\n    }\n}\n\n\u003Cspan class=\"hljs-variable language_\">module\u003C/span>.\u003Cspan class=\"hljs-property\">exports\u003C/span> = \u003Cspan class=\"hljs-title class_\">MarkdownPerformanceDashboard\u003C/span>;\n\u003C/code>\u003C/pre>\u003Ch2 id=\"conclusion\">Conclusion\u003C/h2>\n\u003Cp>Advanced Markdown performance optimization represents a comprehensive approach to building scalable, efficient content processing systems that maintain exceptional performance even under high-volume workloads and complex processing requirements. By implementing sophisticated caching strategies, intelligent invalidation systems, streaming processing capabilities, and real-time monitoring, organizations can create Markdown-based platforms that deliver exceptional user experiences while minimizing resource consumption and operational costs.\u003C/p>\n\u003Cp>The key to successful performance optimization lies in understanding the specific performance characteristics of your content processing workflows, implementing appropriate caching and processing strategies, and continuously monitoring system performance to identify optimization opportunities. Whether you&#39;re building documentation platforms, content management systems, or large-scale publishing workflows, the techniques covered in this guide provide the foundation for creating highly performant Markdown processing systems that scale effectively with your content and user demands.\u003C/p>\n\u003Cp>Remember to implement performance monitoring early in the development process, regularly profile your processing workflows to identify bottlenecks, and continuously optimize your caching and processing strategies based on real-world usage patterns. With proper implementation of advanced performance optimization techniques, your Markdown-based systems can achieve exceptional processing speeds, efficient resource utilization, and responsive user experiences that support both current needs and future growth requirements.\u003C/p>\n",[15,19,22,25,28,31,34],{"id":16,"text":17,"level":18},"why-master-markdown-performance-optimization","Why Master Markdown Performance Optimization?",2,{"id":20,"text":21,"level":18},"foundation-performance-analysis","Foundation Performance Analysis",{"id":23,"text":24,"level":18},"advanced-caching-strategies","Advanced Caching Strategies",{"id":26,"text":27,"level":18},"streaming-and-batch-processing","Streaming and Batch Processing",{"id":29,"text":30,"level":18},"integration-with-modern-development-workflows","Integration with Modern Development Workflows",{"id":32,"text":33,"level":18},"advanced-performance-monitoring","Advanced Performance Monitoring",{"id":35,"text":36,"level":18},"conclusion","Conclusion",[],[39,47,55],{"slug":40,"title":41,"description":42,"excerpt":43,"date":44,"category":9,"author":10,"keywords":45,"readingMinutes":46},"markdown-performance-optimization-rendering-speed-guide","Markdown Performance Optimization and Rendering Speed: Complete Guide for High-Performance Documentation Systems","Master Markdown performance optimization techniques for faster rendering, efficient processing, and scalable documentation systems. Learn caching strategies, parser optimization, and performance monitoring for large-scale content management.","Advanced Markdown performance optimization enables high-speed rendering and efficient processing for large-scale documentation systems that handle thousands of documents with complex content…","2025-09-30","markdown performance, markdown rendering speed, markdown optimization, markdown parser performance, documentation performance, markdown caching, static site performance, markdown processing speed",25,{"slug":48,"title":49,"description":50,"excerpt":51,"date":52,"category":9,"author":10,"keywords":53,"readingMinutes":54},"markdown-performance-optimization-best-practices-complete-guide","Markdown Performance Optimization and Best Practices: Complete Guide for High-Performance Documentation Systems","Master advanced Markdown performance optimization techniques for fast-loading documentation, efficient parsing, and scalable content systems. Learn caching strategies, asset optimization, and performance monitoring for Markdown-based sites.","Advanced Markdown performance optimization and best practices enable high-performance documentation systems that deliver exceptional user experiences while maintaining scalability across large…","2025-11-24","markdown performance optimization, markdown best practices, documentation performance, markdown parsing optimization, static site performance, markdown caching, content delivery optimization, markdown asset management",28,{"slug":56,"title":57,"description":58,"excerpt":59,"date":60,"category":9,"author":10,"keywords":61,"readingMinutes":62},"markdown-table-performance-optimization-complete-guide","Markdown Table Performance Optimization and Responsive Design: Complete Guide for High-Performance Documentation and Data Display","Master advanced Markdown table performance optimization techniques for large datasets, responsive design patterns, and mobile-friendly data presentation. Learn table virtualization, lazy loading, and adaptive design strategies for documentation systems.","Advanced Markdown table performance optimization and responsive design techniques enable sophisticated data presentation systems that maintain performance across large datasets while providing…","2026-01-03","markdown table performance, responsive markdown tables, table optimization, large dataset tables, mobile markdown tables, table virtualization, adaptive table design, data presentation",18,1792184943976]