aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Peppe <rogpeppe@gmail.com>2011-03-03 11:26:53 -0800
committerRob Pike <r@golang.org>2011-03-03 11:26:53 -0800
commitda833474f57150a98d73c10df214a6364d475c5c (patch)
treede0f35d8a908af740b75ac5b630f4c1008e188cb
parent5bd284e86840eba5e4ace473a3f7341a40332db6 (diff)
downloadgo-da833474f57150a98d73c10df214a6364d475c5c.tar.gz
go-da833474f57150a98d73c10df214a6364d475c5c.zip
testing: run GC before each benchmark run.
R=r, rh, gri, rsc CC=golang-dev https://golang.org/cl/4237055
-rw-r--r--src/pkg/testing/benchmark.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/pkg/testing/benchmark.go b/src/pkg/testing/benchmark.go
index 8c226c4d41..cf73e2b48f 100644
--- a/src/pkg/testing/benchmark.go
+++ b/src/pkg/testing/benchmark.go
@@ -8,6 +8,7 @@ import (
"flag"
"fmt"
"os"
+ "runtime"
"time"
)
@@ -64,6 +65,9 @@ func (b *B) nsPerOp() int64 {
// runN runs a single benchmark for the specified number of iterations.
func (b *B) runN(n int) {
+ // Try to get a comparable environment for each run
+ // by clearing garbage from previous runs.
+ runtime.GC()
b.N = n
b.ResetTimer()
b.StartTimer()