2 分钟阅读
https://gohugo.io/troubleshooting/build-performance/
An overview of features used for diagnosing and improving performance issues in site builds.
Hugo is a very fast static site generator, but it is possible to write inefficient templates. Hugo’s template metrics feature is extremely helpful in pinpointing which templates are executed most often and how long those executions take in terms of CPU time.
Metric Name | Description |
---|---|
cumulative duration | The cumulative time spent executing a given template. |
average duration | The average time spent executing a given template. |
maximum duration | The maximum time a single execution took for a given template. |
count | The number of times a template was executed. |
template | The template name. |
|
|
A Note About Parallelism
Hugo builds pages in parallel where multiple pages are generated simultaneously. Because of this parallelism, the sum of “cumulative duration” values is usually greater than the actual time it takes to build a site.
Some partial
templates such as sidebars or menus are executed many times during a site build. Depending on the content within the partial
template and the desired output, the template may benefit from caching to reduce the number of executions. The partialCached
template function provides caching capabilities for partial
templates.
Note that you can create cached variants of each partial
by passing additional parameters to partialCached
beyond the initial context. See the partialCached
documentation for more details.