A benchmark test in Go should be written in a file with the suffix _____.
- .benchmark
- .go
- .test
- .bench
In Go, benchmark tests should be written in files with the .bench suffix. When Go's testing package identifies a test file with this suffix, it treats the functions within it as benchmarks. These functions must have a specific signature and use the testing.B type to perform benchmarking. Using the .bench suffix is a naming convention that helps the Go toolchain identify and execute benchmark tests correctly.
Loading...
Related Quiz
- Describe a scenario where you would need to use a complex transaction in Go. How would you ensure its atomicity?
- To upgrade to the latest version of a dependency, you would use the command go get -u _____.
- To skip a test in Go, you can call the _____ method on the *testing.T or *testing.B object.
- Describe how you would implement a concurrent file processing system in Go.
- How does go fmt help in maintaining a consistent code style?