• Meir Fischer's avatar
    testing: always ReadMemStats before first benchmark run · 3858349e
    Meir Fischer authored
    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/46612Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    3858349e
benchmark.go 18.6 KB