diff --git a/cmd/bench/gotest.go b/cmd/bench/gotest.go index 02d1574..ac8b46a 100644 --- a/cmd/bench/gotest.go +++ b/cmd/bench/gotest.go @@ -14,7 +14,7 @@ func goTest(tcs []*toolchain) error { for _, tc := range tcs { log.Printf("Running Go test benchmarks for %s", tc.Name) fmt.Printf("toolchain: %s\n", tc.Name) - err := tc.Do("", "test", "-v", "-run=none", "-bench=.", "-count=5", "golang.org/x/benchmarks/...") + err := tc.Do("", "test", "-v", "-run=none", "-short", "-bench=.", "-count=5", "golang.org/x/benchmarks/...") if err != nil { return fmt.Errorf("error running gotest with toolchain %s: %w", tc.Name, err) } diff --git a/gc_latency/latency.go b/gc_latency/latency.go index de1afca..3b4e925 100644 --- a/gc_latency/latency.go +++ b/gc_latency/latency.go @@ -202,13 +202,19 @@ func (lb0 *LB) bench(b *testing.B) { average, median := time.Duration(lb.total.Nanoseconds()/int64(count)), delays[len(delays)/2] p29, p39, p49, p59, p69 := lb.delays[int(0.99*delayLen)], delays[int(0.999*delayLen)], delays[int(0.9999*delayLen)], delays[int(0.99999*delayLen)], delays[int(0.999999*delayLen)] if b != nil { - b.ReportMetric(float64(average.Nanoseconds()), "ns/op") - b.ReportMetric(float64(median), "p50-ns") - b.ReportMetric(float64(p29), "p99-ns") - b.ReportMetric(float64(p39), "p99.9-ns") - b.ReportMetric(float64(p49), "p99.99-ns") - b.ReportMetric(float64(p59), "p99.999-ns") - b.ReportMetric(float64(p69), "p99.9999-ns") + if testing.Short() { + b.ReportMetric(0, "ns/op") + b.ReportMetric(float64(p59), "p99.999-ns") + b.ReportMetric(float64(p69), "p99.9999-ns") + } else { + b.ReportMetric(float64(average.Nanoseconds()), "ns/op") + b.ReportMetric(float64(median), "p50-ns") + b.ReportMetric(float64(p29), "p99-ns") + b.ReportMetric(float64(p39), "p99.9-ns") + b.ReportMetric(float64(p49), "p99.99-ns") + b.ReportMetric(float64(p59), "p99.999-ns") + b.ReportMetric(float64(p69), "p99.9999-ns") + } if reportWorstFlag { b.ReportMetric(float64(lb.worst), "worst") } diff --git a/gc_latency/latency_test.go b/gc_latency/latency_test.go index a86d84f..c507ec4 100644 --- a/gc_latency/latency_test.go +++ b/gc_latency/latency_test.go @@ -38,6 +38,14 @@ func BenchmarkGCLatency(b *testing.B) { {"global", true}, } + if testing.Short() { + tcs = []testCase{ + {"stack", false}, + {"heap", false}, + {"global", false}, + } + } + for _, tc := range tcs { lb := &LB{doFluff: tc.withFluff, howAllocated: tc.howAlloc} b.Run(fmt.Sprintf("how=%s/fluff=%v", tc.howAlloc, tc.withFluff),