benchmark: include go and grpc version in result files (#3242)
This commit is contained in:

committed by
Doug Fawley

parent
d5c817b906
commit
cb0e11b54f
@ -68,6 +68,10 @@ func timeChange(title string, val1, val2 time.Duration) string {
|
|||||||
val2.String(), float64(val2-val1)*100/float64(val1))
|
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) {
|
func compareTwoMap(m1, m2 map[string]stats.BenchResults) {
|
||||||
for k2, v2 := range m2 {
|
for k2, v2 := range m2 {
|
||||||
if v1, ok := m1[k2]; ok {
|
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("90th-Lat", v1.Data.Ninetieth, v2.Data.Ninetieth)
|
||||||
changes += timeChange("99th-Lat", v1.Data.NinetyNinth, v2.Data.NinetyNinth)
|
changes += timeChange("99th-Lat", v1.Data.NinetyNinth, v2.Data.NinetyNinth)
|
||||||
changes += timeChange("Avg-Lat", v1.Data.Average, v2.Data.Average)
|
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)
|
fmt.Printf("%s\n", changes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FeatureIndex is an enum for features that usually differ across individual
|
// 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
|
// benchmark execution, and could later be read for pretty-printing or
|
||||||
// comparison with other benchmark results.
|
// comparison with other benchmark results.
|
||||||
type BenchResults struct {
|
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,
|
// RunMode is the workload mode for this benchmark run. This could be unary,
|
||||||
// stream or unconstrained.
|
// stream or unconstrained.
|
||||||
RunMode string
|
RunMode string
|
||||||
@ -262,7 +268,13 @@ func (s *Stats) StartRun(mode string, f Features, sf []bool) {
|
|||||||
defer s.mu.Unlock()
|
defer s.mu.Unlock()
|
||||||
|
|
||||||
runtime.ReadMemStats(&s.startMS)
|
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
|
// 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.
|
// dump returns a printable version.
|
||||||
func (s *Stats) dump(result *BenchResults) {
|
func (s *Stats) dump(result *BenchResults) {
|
||||||
var b bytes.Buffer
|
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.
|
// 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()))
|
b.WriteString(fmt.Sprintf("%s-%s:\n", result.RunMode, result.Features.String()))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user