Commit fd150b4c authored by Quentin Smith's avatar Quentin Smith

analysis: add readme text on empty search

Change-Id: I1d0d574a78559f08125d8aa03ea4f6ab7912e28c
Reviewed-on: https://go-review.googlesource.com/36028Reviewed-by: default avatarRuss Cox <rsc@golang.org>
parent 68e449c3
...@@ -20,6 +20,7 @@ type App struct { ...@@ -20,6 +20,7 @@ type App struct {
// RegisterOnMux registers the app's URLs on mux. // RegisterOnMux registers the app's URLs on mux.
func (a *App) RegisterOnMux(mux *http.ServeMux) { func (a *App) RegisterOnMux(mux *http.ServeMux) {
mux.HandleFunc("/", a.index)
mux.HandleFunc("/search", a.search) mux.HandleFunc("/search", a.search)
mux.HandleFunc("/compare", a.compare) mux.HandleFunc("/compare", a.compare)
} }
...@@ -37,3 +38,8 @@ func (a *App) search(w http.ResponseWriter, r *http.Request) { ...@@ -37,3 +38,8 @@ func (a *App) search(w http.ResponseWriter, r *http.Request) {
//q := r.Form.Get("q") //q := r.Form.Get("q")
a.compare(w, r) a.compare(w, r)
} }
// index redirects / to /search.
func (a *App) index(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/search", http.StatusSeeOther)
}
...@@ -222,6 +222,10 @@ func elideKeyValues(content string, keys map[string]bool) string { ...@@ -222,6 +222,10 @@ func elideKeyValues(content string, keys map[string]bool) string {
} }
func (a *App) compareQuery(q string) *compareData { func (a *App) compareQuery(q string) *compareData {
if len(q) == 0 {
return &compareData{}
}
// Parse query // Parse query
prefix, queries := parseQueryString(q) prefix, queries := parseQueryString(q)
......
...@@ -89,65 +89,76 @@ td.count { ...@@ -89,65 +89,76 @@ td.count {
</form> </form>
</div> </div>
<div id="results"> <div id="results">
{{with .Error}} {{if not .Q}}
<p>{{.}}</p> <p>The Go Performance Dashboard provides a centralized
resource for sharing and analyzing benchmark results. To get
started, upload benchmark results using
<code>go get -u golang.org/x/perf/cmd/benchsave</code>
and
<code>benchsave old.txt new.txt</code>
or upload via the web at
<a href="https://perfdata-dot-golang-org.appspot.com/upload">https://perfdata-dot-golang-org.appspot.com/upload</a>.</p>
{{else}} {{else}}
<table id="labels"> {{with .Error}}
{{with .CommonLabels}} <p>{{.}}</p>
<tbody> {{else}}
<tr> <table id="labels">
<th>label</th><th>common value</th> {{with .CommonLabels}}
</tr> <tbody>
{{range $label, $value := .}}
<tr> <tr>
<th class="label">{{$label}}</th><td>{{$value}}</td> <th>label</th><th>common value</th>
</tr> </tr>
{{end}} {{range $label, $value := .}}
</tbody> <tr>
{{end}} <th class="label">{{$label}}</th><td>{{$value}}</td>
<tbody class="diff"> </tr>
<tr> {{end}}
<th>label</th> </tbody>
<th>values</th> {{end}}
</tr> <tbody class="diff">
{{range $label, $exists := .Labels}} <tr>
<tr class="diff"> <th>label</th>
<th class="label">{{$label}}</th> <th>values</th>
<td> </tr>
{{range $index, $group := $.Groups}} {{range $label, $exists := .Labels}}
<div class="query">{{$group.Q}}:</div> <tr class="diff">
<table> <th class="label">{{$label}}</th>
{{with index $group.LabelValues $label}} <td>
{{range .TopN 4}} {{range $index, $group := $.Groups}}
<tr> <div class="query">{{$group.Q}}:</div>
<td class="count"> <table>
{{.Count}} {{with index $group.LabelValues $label}}
</td> {{range .TopN 4}}
<td> <tr>
{{if eq .Value ""}} <td class="count">
missing {{.Count}}
{{else if eq .Value "…"}} </td>
{{.Value}} <td>
{{else}} {{if eq .Value ""}}
<a href="/search?q={{addToQuery $.Q (printf "%s:%s" $label .Value)}}"> missing
{{printf "%q" .Value}} {{else if eq .Value "…"}}
</a> {{.Value}}
{{end}} {{else}}
</td> <a href="/search?q={{addToQuery $.Q (printf "%s:%s" $label .Value)}}">
</tr> {{printf "%q" .Value}}
</a>
{{end}}
</td>
</tr>
{{end}}
{{end}} {{end}}
{{end}} </table>
</table> {{end}}
</td>
</tr>
{{end}} {{end}}
</td> </tbody>
</tr> </table>
{{end}} <div id="benchstat">
</tbody> {{.Benchstat}}
</table> </div>
<div id="benchstat"> {{end}}
{{.Benchstat}}
</div>
{{end}} {{end}}
</div> </div>
</body> </body>
</html> </html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment