diff --git a/benchmark/benchresult/main.go b/benchmark/benchresult/main.go index 2dab58ca..587a0f6b 100644 --- a/benchmark/benchresult/main.go +++ b/benchmark/benchresult/main.go @@ -68,6 +68,10 @@ func timeChange(title string, val1, val2 time.Duration) string { val2.String(), float64(val2-val1)*100/float64(val1)) } +func strDiff(title, val1, val2 string) string { + return fmt.Sprintf("%20s %12s %12s\n", title, val1, val2) +} + func compareTwoMap(m1, m2 map[string]stats.BenchResults) { for k2, v2 := range m2 { if v1, ok := m1[k2]; ok { @@ -84,6 +88,8 @@ func compareTwoMap(m1, m2 map[string]stats.BenchResults) { changes += timeChange("90th-Lat", v1.Data.Ninetieth, v2.Data.Ninetieth) changes += timeChange("99th-Lat", v1.Data.NinetyNinth, v2.Data.NinetyNinth) changes += timeChange("Avg-Lat", v1.Data.Average, v2.Data.Average) + changes += strDiff("GoVersion", v1.GoVersion, v2.GoVersion) + changes += strDiff("GrpcVersion", v1.GrpcVersion, v2.GrpcVersion) fmt.Printf("%s\n", changes) } } diff --git a/benchmark/stats/stats.go b/benchmark/stats/stats.go index 6829cd21..a1a21c51 100644 --- a/benchmark/stats/stats.go +++ b/benchmark/stats/stats.go @@ -29,6 +29,8 @@ import ( "strconv" "sync" "time" + + "google.golang.org/grpc" ) // FeatureIndex is an enum for features that usually differ across individual @@ -174,6 +176,10 @@ func (f Features) partialString(b *bytes.Buffer, wantFeatures []bool, sep, delim // benchmark execution, and could later be read for pretty-printing or // comparison with other benchmark results. type BenchResults struct { + // GoVersion is the version of the compiler the benchmark was compiled with. + GoVersion string + // GrpcVersion is the gRPC version being benchmarked. + GrpcVersion string // RunMode is the workload mode for this benchmark run. This could be unary, // stream or unconstrained. RunMode string @@ -262,7 +268,13 @@ func (s *Stats) StartRun(mode string, f Features, sf []bool) { defer s.mu.Unlock() runtime.ReadMemStats(&s.startMS) - s.results = append(s.results, BenchResults{RunMode: mode, Features: f, SharedFeatures: sf}) + s.results = append(s.results, BenchResults{ + GoVersion: runtime.Version(), + GrpcVersion: grpc.Version, + RunMode: mode, + Features: f, + SharedFeatures: sf, + }) } // EndRun is to be invoked to indicate the end of the ongoing benchmark run. It @@ -365,6 +377,10 @@ func (s *Stats) computeLatencies(result *BenchResults) { // dump returns a printable version. func (s *Stats) dump(result *BenchResults) { var b bytes.Buffer + + // Go and gRPC version information. + b.WriteString(fmt.Sprintf("%s/grpc%s\n", result.GoVersion, result.GrpcVersion)) + // This prints the run mode and all features of the bench on a line. b.WriteString(fmt.Sprintf("%s-%s:\n", result.RunMode, result.Features.String()))