Template Metrics and i18n

We just released v0.29 with the new template metrics feature. Being an unilingual American, I didn’t think to test it on a multilingual site before we shipped (to be honest, @bep shipped it way faster than I expected!).

The initial behavior looks like this:

$ hugo -s examples/multilingual --renderToMemory --ignoreCache --templateMetrics 
Started building sites ...

Template Metrics:

     cumulative       average       maximum         
       duration      duration      duration  count  template
     ----------      --------      --------  -----  --------
     1.957281ms      489.32µs     586.032µs      4  _internal/_default/rss.xml
     1.730859ms     865.429µs    1.094891ms      2  _default/single.html
     1.586987ms     528.995µs     935.305µs      3  story/single.html
      739.891µs     739.891µs     739.891µs      1  _internal/_default/sitemap.xml
      568.852µs      113.77µs     161.192µs      5  partials/header.html
      461.227µs      92.245µs     171.877µs      5  partials/head.html
       105.88µs      21.176µs      96.171µs      5  partials/footer.html
       97.706µs      97.706µs      97.706µs      1  index.html

Built site for language en:
0 draft content
0 future content
0 expired content
5 regular pages created
8 other pages created
0 non-page files copied
0 paginator pages created
1 groups created

Template Metrics:

     cumulative       average       maximum         
       duration      duration      duration  count  template
     ----------      --------      --------  -----  --------
     3.724037ms     465.504µs     586.032µs      8  _internal/_default/rss.xml
     2.470122ms      617.53µs    1.094891ms      4  _default/single.html
     1.586987ms     528.995µs     935.305µs      3  story/single.html
     1.433478ms     716.739µs     739.891µs      2  _internal/_default/sitemap.xml
     1.094682ms     109.468µs     184.518µs     10  partials/header.html
     1.033011ms     344.337µs      481.76µs      3  uudis/single.html
      908.694µs      90.869µs     171.877µs     10  partials/head.html
      218.181µs      109.09µs     120.475µs      2  index.html
      161.334µs      16.133µs      96.171µs     10  partials/footer.html

Built site for language et:
0 draft content
0 future content
0 expired content
5 regular pages created
8 other pages created
0 non-page files copied
0 paginator pages created
1 groups created
total in 14 ms

The counters are not reset between languages, so I want to do one of two things:

  1. Print the template metrics only once at the end (after total in 14 ms?).
  2. Reset the metrics between languages.

I like option #1 since I assume changing languages shouldn’t significantly change template performance. Is there a benefit in seeing metrics for each language?

2 Likes

The PR was open for many months. Not sure how fast that sounds, but I get your point :slight_smile:

This is a debug tool, and as such it works fine as is, even for multilingual sites (even if it gets a little noisy).

I would vote for option 1).