summaryrefslogtreecommitdiffstats
path: root/resources/page/pages_sort_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-10-11 13:55:46 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-10-13 12:36:17 +0200
commit653e6856ea1cfc60cc16733807d23b302dbe4bd5 (patch)
treec77d48f3ec9a07a47ae5a8d53b2cf7b6c459f66f /resources/page/pages_sort_test.go
parentf4f566edf4bd6a590cf9cdbd5cfc0026ecd93b14 (diff)
downloadhugo-653e6856ea1cfc60cc16733807d23b302dbe4bd5.tar.gz
hugo-653e6856ea1cfc60cc16733807d23b302dbe4bd5.zip
resources/page: Use binary search in Pages.Prev/Next if possible
This is obviously much faster for lager data sets: ```bash name old time/op new time/op delta SearchPage/ByWeight-100-4 267ns ± 4% 272ns ± 5% ~ (p=0.457 n=4+4) SearchPage/ByWeight-5000-4 10.8µs ± 3% 1.2µs ± 2% -88.99% (p=0.029 n=4+4) SearchPage/ByWeight-10000-4 21.1µs ± 1% 1.4µs ±11% -93.28% (p=0.029 n=4+4) ``` See #4500
Diffstat (limited to 'resources/page/pages_sort_test.go')
-rw-r--r--resources/page/pages_sort_test.go1
1 files changed, 1 insertions, 0 deletions
diff --git a/resources/page/pages_sort_test.go b/resources/page/pages_sort_test.go
index c9eb37c06..670abb90a 100644
--- a/resources/page/pages_sort_test.go
+++ b/resources/page/pages_sort_test.go
@@ -269,6 +269,7 @@ func createSortTestPages(num int) Pages {
for i := 0; i < num; i++ {
p := newTestPage()
p.path = fmt.Sprintf("/x/y/p%d.md", i)
+ p.title = fmt.Sprintf("Title %d", i%(num+1/2))
p.params = map[string]interface{}{
"arbitrarily": map[string]interface{}{
"nested": ("xyz" + fmt.Sprintf("%v", 100-i)),