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.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *