Hi,
I generate sites with a lot of tables, and I find it a little bit slow to generate:
^C[jb@localhost website]$ hugo --templateMetrics
Start building sites …
hugo v0.101.0+extended linux/amd64 BuildDate=unknown
Template Metrics:
cumulative average maximum
duration duration duration count template
---------- -------- -------- ----- --------
17m19.500708831s 282.242929ms 2.270403458s 3683 partials/head.html
16m12.347736008s 286.912875ms 2.272918188s 3389 _default/single.html
1m1.428004769s 238.093041ms 429.822461ms 258 territories/term.html
3.281109666s 17.567µs 44.089726ms 186776 _internal/shortcodes/ref.html
2.87234186s 261.121987ms 324.613851ms 11 _default/list_packages.html
2.778367884s 252.578898ms 349.032017ms 11 _default/list_languages.html
2.696718097s 245.15619ms 368.245192ms 11 _default/release.html
787.941776ms 213.94µs 21.165335ms 3683 partials/footer.html
484.999657ms 131.757µs 28.326031ms 3681 partials/breadcrumb.html
299.981285ms 1.023826ms 60.076021ms 293 _internal/_default/rss.xml
235.470508ms 63.934µs 22.285ms 3683 partials/nav.html
221.143155ms 60.06µs 5.285598ms 3682 partials/header.html
175.73944ms 47.716µs 5.091332ms 3683 partials/head_custom.html
73.239344ms 73.239344ms 73.239344ms 1 territories/list.html
71.06029ms 19.871µs 4.640618ms 3576 shortcodes/resource.html
43.688333ms 43.688333ms 43.688333ms 1 _internal/_default/sitemap.xml
3.940148ms 1.069µs 122.843µs 3683 partials/footer_custom.html
837.897µs 837.897µs 837.897µs 1 index.html
337.724µs 337.724µs 337.724µs 1 404.html
120.328µs 60.164µs 104.463µs 2 partials/page_meta.html
| EN
-------------------+-------
Pages | 3976
Paginator pages | 0
Non-page files | 0
Static files | 3681
Processed images | 0
Aliases | 0
Sitemaps | 1
Cleaned | 0
Total in 132298 ms
when I investigate partials/head.html, I understood it used scratch to guess/adapt description/title depending on where we are on the site.
I removed this and see the impact: 640.929519ms 173.976µs 13.200765ms 3684 partials/head.html
but global time is not that different, I only saved 10 seconds Total in 123739 ms
then I looked at _default/single.html:
{{ define "main" }}
<div class="container" role="main">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
{{ partial "breadcrumb.html" . }}
</div>
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<article role="main" class="blog-post">
{{ if .Params.territories }}
<div class="blog-tags">
Spoken in these territories:
{{ range .Params.territories }}
<a href="{{ $.Site.LanguagePrefix | absURL }}/territories/{{ . | urlize }}/">{{ . }}</a>
{{ end }}
</div>
{{ end }}
{{ .Content }}
</article>
{{ if ne .Type "page" }}
<ul class="pager blog-pager">
{{ if .PrevInSection }}
<li class="previous">
<a href="{{ .PrevInSection.Permalink }}" data-toggle="tooltip" data-placement="top" title="{{ .PrevInSection.Title }}">← {{ "previousPost" }}</a>
</li>
{{ end }}
{{ if .NextInSection }}
<li class="next">
<a href="{{ .NextInSection.Permalink }}" data-toggle="tooltip" data-placement="top" title="{{ .NextInSection.Title }}">{{ "nextPost" }} →</a>
</li>
{{ end }}
</ul>
{{ end }}
</div>
</div>
</div>
{{ end }}
Caching {{ if .Params.territories }}
had no significant impact.
Caching {{ if ne .Type "page" }}
had no significant impact.
So, I decided to move the content in a partial and get this:
[jb@localhost website]$ hugo --templateMetrics
Start building sites …
hugo v0.101.0+extended linux/amd64 BuildDate=unknown
Template Metrics:
cumulative average maximum
duration duration duration count template
---------- -------- -------- ----- --------
14m27.779099304s 256.057568ms 1.97192383s 3389 _default/single.html
14m24.889846979s 255.20503ms 1.968510371s 3389 partials/single_content.html
56.071804807s 216.493454ms 233.423006ms 259 territories/term.html
3.049971629s 10.374053ms 865.049394ms 294 _internal/_default/rss.xml
2.782301896s 14.896µs 58.81876ms 186776 _internal/shortcodes/ref.html
2.434604987s 221.327726ms 261.938264ms 11 _default/list_packages.html
2.415015047s 219.546822ms 224.374233ms 11 _default/list_languages.html
2.390850902s 217.350082ms 222.39913ms 11 _default/release.html
832.809522ms 226.061µs 18.3181ms 3684 partials/footer.html
640.929519ms 173.976µs 13.200765ms 3684 partials/head.html
465.80366ms 126.508µs 38.723489ms 3682 partials/breadcrumb.html
205.405175ms 55.771µs 448.163µs 3683 partials/header.html
187.013134ms 50.763µs 4.57891ms 3684 partials/nav.html
182.711235ms 49.595µs 3.785459ms 3684 partials/head_custom.html
72.418827ms 72.418827ms 72.418827ms 1 territories/list.html
64.812607ms 18.124µs 2.675749ms 3576 shortcodes/resource.html
47.196036ms 47.196036ms 47.196036ms 1 _internal/_default/sitemap.xml
21.75112ms 6.418µs 2.617864ms 3389 partials/territories.html
4.358623ms 1.183µs 58.183µs 3684 partials/footer_custom.html
862.657µs 862.657µs 862.657µs 1 index.html
329.187µs 329.187µs 329.187µs 1 404.html
132.076µs 66.038µs 115.424µs 2 partials/page_meta.html
| EN
-------------------+-------
Pages | 3978
Paginator pages | 0
Non-page files | 0
Static files | 3681
Processed images | 0
Aliases | 0
Sitemaps | 1
Cleaned | 0
Total in 118329 ms
So, does it mean it simply takes time to generate all the content?