summaryrefslogtreecommitdiffhomepage
path: root/hugolib
diff options
context:
space:
mode:
authorCameron Moore <[email protected]>2017-09-26 13:03:04 -0500
committerBjørn Erik Pedersen <[email protected]>2017-09-26 20:03:04 +0200
commitb4a14c25fe85c41b79497be27ead128502a4dd7b (patch)
tree99cdbb0d9ab7a7adf137ce492773750aeec8e431 /hugolib
parentcb8eb472602754b310eaf7a10271149d1e1f5d75 (diff)
downloadhugo-b4a14c25fe85c41b79497be27ead128502a4dd7b.tar.gz
hugo-b4a14c25fe85c41b79497be27ead128502a4dd7b.zip
metrics: Add simple template metrics feature
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/hugo_sites_build.go4
-rw-r--r--hugolib/site.go11
2 files changed, 15 insertions, 0 deletions
diff --git a/hugolib/hugo_sites_build.go b/hugolib/hugo_sites_build.go
index fa0eac702..f73989908 100644
--- a/hugolib/hugo_sites_build.go
+++ b/hugolib/hugo_sites_build.go
@@ -25,6 +25,10 @@ import (
// Build builds all sites. If filesystem events are provided,
// this is considered to be a potential partial rebuild.
func (h *HugoSites) Build(config BuildCfg, events ...fsnotify.Event) error {
+ if h.Metrics != nil {
+ h.Metrics.Reset()
+ }
+
t0 := time.Now()
// Need a pointer as this may be modified.
diff --git a/hugolib/site.go b/hugolib/site.go
index 39908d810..8e1090a31 100644
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -14,6 +14,7 @@
package hugolib
import (
+ "bytes"
"errors"
"fmt"
"html/template"
@@ -1730,6 +1731,16 @@ func (s *Site) appendThemeTemplates(in []string) []string {
// Stats prints Hugo builds stats to the console.
// This is what you see after a successful hugo build.
func (s *Site) Stats() {
+ s.Log.FEEDBACK.Println()
+
+ if s.Cfg.GetBool("templateMetrics") {
+ var b bytes.Buffer
+ s.Metrics.WriteMetrics(&b)
+
+ s.Log.FEEDBACK.Printf("Template Metrics:\n\n")
+ s.Log.FEEDBACK.Print(b.String())
+ s.Log.FEEDBACK.Println()
+ }
s.Log.FEEDBACK.Printf("Built site for language %s:\n", s.Language.Lang)
s.Log.FEEDBACK.Println(s.draftStats())