Skip to content

Commit

Permalink
web: add back timing stats for the search results page
Browse files Browse the repository at this point in the history
Apparently, the golang template library strips out the comments, so
the <!--samp> block where they were before doesn't preserve them.

Change-Id: I6696a612a4cca54572986be77c388bd9c1d61dc6
  • Loading branch information
hanwen committed Jan 12, 2018
1 parent 315a614 commit 13a8efc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions web/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ func (s *Server) serveSearchErr(w http.ResponseWriter, r *http.Request) error {
SearchOptions: sOpts.String(),
FileMatches: fileMatches,
}
if res.Stats.Wait < res.Stats.Duration/10 {
// Suppress queueing stats if they are neglible.
res.Stats.Wait = 0
}

var buf bytes.Buffer
if err := s.result.Execute(&buf, &res); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion web/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,13 @@ var TemplateText = map[string]string{
{{end}}
<hr>
<p class="text-right">
Took {{.Stats.Duration}}{{if .Stats.Wait}}(queued: {{.Stats.Wait}}){{end}} for
{{HumanUnit .Stats.IndexBytesLoaded}}B index data,
{{.Stats.NgramMatches}} ngram matches,
{{.Stats.FilesConsidered}} docs considered,
{{.Stats.FilesLoaded}} docs ({{HumanUnit .Stats.ContentBytesLoaded}}B) loaded,
{{.Stats.FilesSkipped}} docs skipped
</p>
<!--samp>{{.Query}} with options {{.SearchOptions}} in {{.Stats.Duration}} (queued: {{.Stats.Wait}})</samp-->
</div>
{{ template "jsdep"}}
</body>
Expand Down

0 comments on commit 13a8efc

Please sign in to comment.