Repository navigation
testing: Benchmark shows zero allocations #20863
Description
Activity
- changed the title
[-]testing: testing.Benchmark shows zero allocations[/-][+]testing: Benchmark shows zero allocations[/+]on Jun 30, 2017 It turns out that it prints memory statistics when b.ReportAllocs is called.
As this is a behaviour change, perhaps this should be documented in
the Go 1.9 release notes.This is already documented
MemAllocs and MemBytes may be zero if memory benchmarking is not requested using B.ReportAllocs or the -benchmem command line flag.
http://tip.golang.org/pkg/testing/#BenchmarkResult
but if it was changed in go1.9 then I agree it's worth mentioning in release notes, too.
- addedDocumentationIssues describing a change to documentation.Issues describing a change to documentation.
on Jun 30, 2017 - addedNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Feedback is required from experts, contributors, and/or the community before a change can be made.
on Jun 30, 2017 The change was introduced in https://go-review.googlesource.com/c/36791/
CL https://golang.org/cl/47331 mentions this issue.
@ALTree I would rather revert CL 36791 now that ReadMemStats is fast (see https://tip.golang.org/doc/go1.9#gc).
I'll send a CL.
/cc @josharian @aclements
I thought this was fixed a few days ago by https://golang.org/cl/46612?
Yeah, I was just about to point that out. Looks like that only reverted 1 of the 3 spots.
CL https://golang.org/cl/47350 mentions this issue.
- added a commit that references this issue
on Jun 30, 2017 Ah, thanks for noticing. I didn't notice that that change was partly reverted.
- locked and limited conversation to collaborators
on Jun 30, 2018
testing.Benchmark does not seem to produce valid memory stats any more:
The following program:
always prints:
I'd expect it to print
like previous Go versions.
go version devel +eab99a8 Mon Jun 26 21:12:22 2017 +0000 linux/amd64