Skip to content

Conversation

@j9t
Copy link

@j9t j9t commented Oct 24, 2025

Adds timing measurements for TemplateMap:cache, TemplateMap:initDependencyMap, and TemplateMap:setCollectionByTagName when ELEVENTY_PERF=1 is set.

Fell out of the bag after looking for performance improvements in my Eleventy projects—took the local Eleventy source as well and used this for tests. Proposing as it may provide useful beyond those local tests.

AI-generated context:

This PR adds optional performance instrumentation to TemplateMap to help identify build bottlenecks. When enabled via ELEVENTY_PERF=1 environment variable, it measures and reports timing for three key phases: TemplateMap:cache (overall caching phase), TemplateMap:initDependencyMap (dependency initialization), and TemplateMap:setCollectionByTagName (individual collection population).

This instrumentation has zero performance overhead when disabled (the default), uses standard console.time/console.timeEnd APIs, and requires only ~15 lines of code. During testing on large sites (2,000+ files, 500+ collections), this revealed that template rendering—not collection population—accounts for the majority of build time, enabling targeted optimization efforts.

Adds timing measurements for TemplateMap:cache, TemplateMap:initDependencyMap,
and TemplateMap:setCollectionByTagName when ELEVENTY_PERF=1 is set.
@j9t j9t requested a review from zachleat as a code owner October 24, 2025 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant