diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2017-06-30 16:12:28 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2017-06-30 16:49:29 +0000 |
| commit | 0ff876a8505d61fc20f3176f90bc589d76a4c966 (patch) | |
| tree | 7efc04b4fcb21f727e61dfa1ce617d64f95f8266 /src/testing | |
| parent | ee4550440afd4f896dbcfe40c04e7fe11abd5a7b (diff) | |
| download | go-0ff876a8505d61fc20f3176f90bc589d76a4c966.tar.xz | |
testing: revert CL 36791's conditional ReadMemStats
Now that ReadMemStats is fast (CL 34937), CL 36791 is not so
necessary, and causes confusion. See #20863
This was already partially reverted in CL 46612 but missed two of the
spots.
Fixes #20863
Change-Id: I1307a0f7b1f9e86e8b6ceaa6a677f24f13431110
Reviewed-on: https://go-review.googlesource.com/47350
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/testing')
| -rw-r--r-- | src/testing/benchmark.go | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/testing/benchmark.go b/src/testing/benchmark.go index 484a6d7e12..84005aa322 100644 --- a/src/testing/benchmark.go +++ b/src/testing/benchmark.go @@ -87,11 +87,9 @@ func (b *B) StartTimer() { func (b *B) StopTimer() { if b.timerOn { b.duration += time.Now().Sub(b.start) - if *benchmarkMemory || b.showAllocResult { - runtime.ReadMemStats(&memStats) - b.netAllocs += memStats.Mallocs - b.startAllocs - b.netBytes += memStats.TotalAlloc - b.startBytes - } + runtime.ReadMemStats(&memStats) + b.netAllocs += memStats.Mallocs - b.startAllocs + b.netBytes += memStats.TotalAlloc - b.startBytes b.timerOn = false } } @@ -100,11 +98,9 @@ func (b *B) StopTimer() { // It does not affect whether the timer is running. func (b *B) ResetTimer() { if b.timerOn { - if *benchmarkMemory || b.showAllocResult { - runtime.ReadMemStats(&memStats) - b.startAllocs = memStats.Mallocs - b.startBytes = memStats.TotalAlloc - } + runtime.ReadMemStats(&memStats) + b.startAllocs = memStats.Mallocs + b.startBytes = memStats.TotalAlloc b.start = time.Now() } b.duration = 0 @@ -298,8 +294,6 @@ func (b *B) launch() { } // The results of a benchmark run. -// MemAllocs and MemBytes may be zero if memory benchmarking is not requested -// using B.ReportAllocs or the -benchmem command line flag. type BenchmarkResult struct { N int // The number of iterations. T time.Duration // The total time taken. |
