diff --git a/cmd/pkappa2/main.go b/cmd/pkappa2/main.go index 969ff742..78adc45e 100644 --- a/cmd/pkappa2/main.go +++ b/cmd/pkappa2/main.go @@ -534,6 +534,7 @@ func main() { Stream *index.Stream Tags []string } + Elapsed int64 Offset uint MoreResults bool }{ @@ -543,6 +544,7 @@ func main() { Tags []string }{}, } + start := time.Now() v := mgr.GetView() defer v.Release() hasMore, offset, err := v.SearchStreams(r.Context(), qq, func(c manager.StreamContext) error { @@ -563,6 +565,7 @@ func main() { http.Error(w, fmt.Sprintf("SearchStreams failed: %v", err), http.StatusInternalServerError) return } + response.Elapsed = time.Since(start).Microseconds() response.MoreResults = hasMore response.Offset = offset w.Header().Set("Content-Type", "application/json") diff --git a/web/src/apiClient.guard.ts b/web/src/apiClient.guard.ts index bbe0ab17..fa9a40df 100644 --- a/web/src/apiClient.guard.ts +++ b/web/src/apiClient.guard.ts @@ -54,6 +54,7 @@ export function isSearchResult(obj: unknown): obj is SearchResult { typeof e === "string" ) ) && + typeof typedObj["Elapsed"] === "number" && typeof typedObj["Offset"] === "number" && typeof typedObj["MoreResults"] === "boolean" ) diff --git a/web/src/apiClient.ts b/web/src/apiClient.ts index e635097c..5c654429 100644 --- a/web/src/apiClient.ts +++ b/web/src/apiClient.ts @@ -46,6 +46,7 @@ export type Error = { export type SearchResult = { Debug: string[]; Results: Result[]; + Elapsed: number; Offset: number; MoreResults: boolean; }; diff --git a/web/src/components/Results.vue b/web/src/components/Results.vue index 6b6a7893..17dc20d1 100644 --- a/web/src/components/Results.vue +++ b/web/src/components/Results.vue @@ -93,6 +93,12 @@ >Results might be outdated. +
+ + Query took {{ (streams.result.Elapsed / 1_000_000).toFixed(6) }}s + +
+