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:
Bjørn Erik Pedersen
2017-10-04 22:12:51 +02:00
parent e2e8bcbec3
commit 5800a20a25
5 changed files with 192 additions and 19 deletions

2
deps/deps.go vendored
View File

@@ -135,7 +135,7 @@ func New(cfg DepsCfg) (*Deps, error) {
}
if cfg.Cfg.GetBool("templateMetrics") {
d.Metrics = metrics.NewProvider()
d.Metrics = metrics.NewProvider(cfg.Cfg.GetBool("templateMetricsHints"))
}
return d, nil