I propose that cmd/vet flag any benchmark that doesn’t have any reference to b in its body.
- Frequency: Low among experienced gophers, but not an uncommon mistake among new gophers.
- Correctness: Benchmarks written without using b do not function as benchmarks. Often this gets caught by a user who is puzzled by the output, but not always, particularly if the benchmark is slow.
- Precision: 100%, or very near it. You cannot write a correct benchmark without using b.N, b.Run, b.RunParallel, or somehow passing b or one of its fields to another function to do that for you.
The implementation should be fairly straightforward. Pick out benchmarks. Pick out the identifier (usually b). Look for any uses of that identifier. If none, complain.
cc @robpike @mvdan
I propose that cmd/vet flag any benchmark that doesn’t have any reference to b in its body.
The implementation should be fairly straightforward. Pick out benchmarks. Pick out the identifier (usually
b). Look for any uses of that identifier. If none, complain.cc @robpike @mvdan