mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
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".
This commit is contained in:
@@ -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
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user