Commit graph

12 commits

Author SHA1 Message Date
Bjørn Erik Pedersen dd45e6d7e5 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
2016-09-14 10:57:39 +02:00
Bjørn Erik Pedersen 2079a23dd8 Make it possible to configure Blackfroday per language
See #2309
2016-09-06 18:32:17 +03:00
Hanchen Wang 091915c75d hugolib: Add sort ByExpiryDate function 2016-06-14 15:45:25 +02:00
Bjørn Erik Pedersen 10af906371 Add ByLastmod page sort 2016-04-22 20:43:18 +02:00
Bjørn Erik Pedersen a95426d40c Remove Printf in test 2016-02-06 22:19:58 +01:00
Bjørn Erik Pedersen 88a320fb2d Fix buggy Pages.Limit
Also add missing page sort related tests.
2016-02-06 22:10:36 +01:00
Anthony Fok 8509727fe8 Add copyright header to that source files that don’t have one.
See #1646
2015-12-10 15:19:38 -07:00
Bjørn Erik Pedersen 40efc8677a Fix sort test and title sort
See #1299
2015-07-25 17:22:46 +02:00
Bjørn Erik Pedersen 36e0d005ed Fall back to link title for default page sort
Fixes #1299
2015-07-25 16:34:35 +02:00
Bjørn Erik Pedersen a9c5133a77 Fix data races in sorting and Reverse
The custom sort functions used from the templates had some subtle data race- and related issues,
especially when used in the single page template.

This commit fixes this by making copies and protect the read and writes with a RWMutex.

The results are cached (it will typically be invoked *number of pages* times with exactly the same data).

This is, not surprisingly, also faster:

```
benchmark                           old ns/op     new ns/op     delta
BenchmarkSortByWeightAndReverse     14228         491           -96.55%

benchmark                           old allocs     new allocs     delta
BenchmarkSortByWeightAndReverse     1              0              -100.00%

benchmark                           old bytes     new bytes     delta
BenchmarkSortByWeightAndReverse     32            0             -100.00%
```

Fixes #1293
2015-07-23 12:43:57 +02:00
Bjørn Erik Pedersen ea6ae769dc Fix broken test 2015-07-21 21:12:03 +02:00
Bjørn Erik Pedersen 5cf0aa2fc0 Add benchmark for sort and reverse 2015-07-21 21:08:20 +02:00