benchstat: add input from benchfmt.Results

Change-Id: Idfc4d6b3cbd1e3c17182fe9565149e77ee1edb46
Reviewed-on: https://go-review.googlesource.com/35943
Reviewed-by: Quentin Smith <quentin@golang.org>
diff --git a/benchstat/data.go b/benchstat/data.go
index 0284216..7f1bf1a 100644
--- a/benchstat/data.go
+++ b/benchstat/data.go
@@ -10,6 +10,7 @@
 	"strings"
 
 	"golang.org/x/perf/internal/stats"
+	"golang.org/x/perf/storage/benchfmt"
 )
 
 // A Collection is a collection of benchmark results.
@@ -135,11 +136,24 @@
 	return m
 }
 
-// AddConfig adds a set of benchmark results from a single configuration to the collection.
-func (c *Collection) AddConfig(config string, data []byte) {
+// AddFile adds the benchmark results in the formatted data
+// to the named configuration.
+func (c *Collection) AddFile(config string, data []byte) {
 	c.Configs = append(c.Configs, config)
 	key := Key{Config: config}
+	c.addText(key, string(data))
+}
 
+// AddResults adds the benchmark results to the named configuration.
+func (c *Collection) AddResults(config string, results []*benchfmt.Result) {
+	c.Configs = append(c.Configs, config)
+	key := Key{Config: config}
+	for _, r := range results {
+		c.addText(key, r.Content)
+	}
+}
+
+func (c *Collection) addText(key Key, data string) {
 	for _, line := range strings.Split(string(data), "\n") {
 		f := strings.Fields(line)
 		if len(f) < 4 {