summaryrefslogtreecommitdiffhomepage
path: root/tpl/partials
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2017-10-04 22:12:51 +0200
committerBjørn Erik Pedersen <[email protected]>2017-10-07 18:00:07 +0200
commit5800a20a258378440e203a6c4a4343f5077755df (patch)
treedca1bd5030dccd56b4e9ad2dc1e037955aa4e20d /tpl/partials
parente2e8bcbec34702a27047b91b6b007a15f1fc0797 (diff)
downloadhugo-5800a20a258378440e203a6c4a4343f5077755df.tar.gz
hugo-5800a20a258378440e203a6c4a4343f5077755df.zip
metrics: Detect partialCached candidates
This commit adds a "cache potential" column when running `hugo --templateMetrics --templateMetricsHints`. This is only calculated when `--templateMetricsHints` is set, as these calculations has an negative effect on the other timings. This gives a value for partials only, and is a number between 0-100 that indicates if `partial` can be replaced with `partialCached`. 100 means that all execution of the same partial resulted in the same output. You should do some manual research before going "all cache".
Diffstat (limited to 'tpl/partials')
-rw-r--r--tpl/partials/partials.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/tpl/partials/partials.go b/tpl/partials/partials.go
index da131a974..d3a75edad 100644
--- a/tpl/partials/partials.go
+++ b/tpl/partials/partials.go
@@ -77,10 +77,18 @@ func (ns *Namespace) Include(name string, contextList ...interface{}) (interface
}
if _, ok := templ.Template.(*texttemplate.Template); ok {
- return b.String(), nil
+ s := b.String()
+ if ns.deps.Metrics != nil {
+ ns.deps.Metrics.TrackValue(n, s)
+ }
+ return s, nil
}
- return template.HTML(b.String()), nil
+ s := b.String()
+ if ns.deps.Metrics != nil {
+ ns.deps.Metrics.TrackValue(n, s)
+ }
+ return template.HTML(s), nil
}
}