1 Commits

Author SHA1 Message Date
Alex Schroeder
b8429f58ef Add timing log messages for index and search 2023-09-16 14:58:27 +02:00
2 changed files with 10 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"net/http"
"slices"
"time"
"unicode"
"unicode/utf8"
)
@@ -71,9 +72,15 @@ func search(q string) []Page {
if len(q) == 0 {
return make([]Page, 0)
}
start := time.Now()
names := searchDocuments(q)
fmt.Printf("Search for %v found %d pages in %v\n", q, len(names), time.Since(start))
start = time.Now()
items := loadAndSummarize(names, q)
fmt.Printf("Loading and summarizing %d pages took %v\n", len(names), time.Since(start))
start = time.Now()
slices.SortFunc(items, sortItems)
fmt.Printf("Sorting %d pages took %v\n", len(names), time.Since(start))
return items
}

View File

@@ -6,6 +6,7 @@ import (
"net/http"
"os"
"regexp"
"time"
)
// Templates are parsed at startup.
@@ -67,9 +68,10 @@ func getPort() string {
// messages.
func scheduleLoadIndex() {
fmt.Print("Indexing pages\n")
start := time.Now()
n, err := index.load()
if err == nil {
fmt.Printf("Indexed %d pages\n", n)
fmt.Printf("Indexed %d pages in %v\n", n, time.Since(start))
} else {
fmt.Println("Indexing failed")
}