Lazy calculate WordCount, ReadingTime and FuzzyWordCount
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 17 Aug 2016 11:41:48 +0000 (13:41 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 14 Sep 2016 08:57:39 +0000 (10:57 +0200)
commitdd45e6d7e5406991d8df3a2f9ba4c7e5ae039c34
tree0eaf4d028091ab7ee1c0997eb722442c0328c817
parent4abaec5c045e92ae5f8b3a2dc66606b080ef6ea5
Lazy calculate  WordCount, ReadingTime and FuzzyWordCount

This avoids having to execute these expensive operations for sites not using these values.

This commit sums up a set of wordcounting and autosummary related performance improvements.

The effect of these kind of depends on what features your site use, but a benchmark from 4 Hugo sites in the wild shows promise:

```
benchmark           old ns/op       new ns/op       delta
BenchmarkHugo-4     21293005843     20032857342     -5.92%

benchmark           old allocs     new allocs     delta
BenchmarkHugo-4     65290922       65186032       -0.16%

benchmark           old bytes      new bytes      delta
BenchmarkHugo-4     9771213416     9681866464     -0.91%
```

Closes #2378
helpers/content.go
helpers/content_test.go
hugolib/page.go
hugolib/pageSort_test.go
hugolib/page_test.go
hugolib/pagination_test.go
hugolib/site_test.go