Commit 0ff876a8 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

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/47350Reviewed-by: 's avatarAustin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent ee455044
......@@ -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
}
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
}
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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment