-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
testing: go1.14rc1 b.Cleanup behaves differently from t.Cleanup #37073
Comments
CC @rogpeppe |
I'm not even sure how to use the |
My assumption was that it will be run once at the end of the entire benchmark function. I was merely testing it out to possibly include it in a article on "what's new in go1.14", so my stance is just that "the documentation says X, but it's doing Y" :) |
Unfortunately I have no idea how to implement that suggestion. The problem is that the benchmark function will be invoked multiple times, and it might call the |
I understand. In that case I should probably study the behavior further and propose a doc patch, as I found it vague (at least when I glanced through it very briefly prior to testing it out) as to exactly how |
Upon reading the source code that came with go1.14rc1, I think it's safe to say that If a doc change should suffice, and there are plans to make this work somehow on
to something like
Otherwise moving its implementation from |
I have to say it was a surprise to me (as someone who was involved in discussing the implementation/docs) to read that you could even call Hence, the method only be defined on |
@lestrrat indeed. Ashamedly, I didn't even read the release notes following the change. Again, something at least I missed, apologies. |
Thanks for bringing this up. It's definitely an omission (and my fault!). By my understanding, a benchmark cleanup function should be run every time the benchmark function is called, after all sub-benchmarks have returned. The idea is that you should potentially be able to use the same resource-lifetime-control mechanism for benchmarks as you would for tests. I don't see any particular reason that someone might want a resource to stay around after a benchmark function returns - there would be no way to access it. |
Change https://golang.org/cl/218117 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
What did you see instead?
I'm not sure if the Cleanup isn't being fired at all, or the
b.Logf
is just not outputting anything. FWIW, I tried replacingb.Logf
with apanic
, and I didn't see anything different so I'm inclined to say that b.Cleanup just isn't firing?(Edit: expected and actual output were flipped)
The text was updated successfully, but these errors were encountered: