analysis/app: sane defaults for viewing CL trybot results

Change-Id: Ibbe3faf5bad9f702b46703a68c612b6e9dbf666d
Reviewed-on: https://go-review.googlesource.com/41250
Reviewed-by: Russ Cox <rsc@golang.org>
diff --git a/analysis/app/compare.go b/analysis/app/compare.go
index 03c3416..b1358e8 100644
--- a/analysis/app/compare.go
+++ b/analysis/app/compare.go
@@ -262,8 +262,12 @@
 	// Attempt to automatically split results.
 	if len(groups) == 1 {
 		group := groups[0]
+		// Matching a single CL -> split by filename
+		switch {
+		case len(group.LabelValues["cl"]) == 1 && len(group.LabelValues["ps"]) == 1 && len(group.LabelValues["upload-file"]) > 1:
+			groups = group.splitOn("upload-file")
 		// Matching a single upload with multiple files -> split by file
-		if len(group.LabelValues["upload"]) == 1 && len(group.LabelValues["upload-part"]) > 1 {
+		case len(group.LabelValues["upload"]) == 1 && len(group.LabelValues["upload-part"]) > 1:
 			groups = group.splitOn("upload-part")
 		}
 	}
@@ -288,7 +292,15 @@
 	// Compute benchstat
 	c := &benchstat.Collection{
 		AddGeoMean: true,
-		SplitBy:    []string{"pkg", "goos", "goarch"},
+		SplitBy:    nil,
+	}
+	for _, label := range []string{"buildlet", "pkg", "goos", "goarch"} {
+		for _, g := range groups {
+			if len(g.LabelValues[label]) > 1 {
+				c.SplitBy = append(c.SplitBy, label)
+				break
+			}
+		}
 	}
 	for _, g := range groups {
 		c.AddResults(g.Q, g.results)