A benchmark function in Go receives a pointer to a _____ as its parameter.
- testing.B
- benchmark.B
- testing.T
- benchmark.T
A benchmark function in Go receives a pointer to a testing.B as its parameter. The testing.B type provides methods and fields for controlling and reporting the benchmark's progress and results. By receiving this parameter, the benchmark function can use it to record timings, perform iterations, and report the benchmark's outcomes, including memory allocations and custom metrics if needed.
Loading...
Related Quiz
- Describe a scenario where it would be appropriate to use a switch statement over multiple if-else statements in Go.
- What is the role of the select statement in Go concurrency?
- In a high-traffic web application, how would you optimize the routing process to ensure efficient handling of HTTP requests?
- To skip a test in Go, you can call the _____ method on the *testing.T or *testing.B object.
- How do you create a new goroutine?