]> Cypherpunks repositories - gostls13.git/commit
testing: always ReadMemStats before first benchmark run
authorMeir Fischer <meirfischer@gmail.com>
Mon, 26 Jun 2017 01:17:52 +0000 (21:17 -0400)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 28 Jun 2017 20:47:26 +0000 (20:47 +0000)
commit3858349ec956b4abb052ba3191da16dc487c4ad4
treeb8301c51cfc7ecc7581d20ee01d535cf207a33ed
parent32002079083e533e11209824bd9e3a797169d1c4
testing: always ReadMemStats before first benchmark run

If the only way the user indicates they want alloc stats shown
is via ReportAllocs, we don't know that until benchFunc is run.
Therefore, StopTimer's ReadMemStats will return incorrect data
for single cycle runs since there's no counterpart ReadMemStats from
StartTimer that initializes alloc stats.

It appears that this bug was introduced by CL 46612,
"testing: only call ReadMemStats if necessary when benchmarking"

Fixes #20590

Change-Id: I3b5ef91677823f4b98011880a3be15423baf7e33
Reviewed-on: https://go-review.googlesource.com/46612
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/testing/benchmark.go
src/testing/sub_test.go