Go

Performance, Profiling & Testing Interview Questions

38 Go interview questions on performance, profiling & testing, with detailed answers and code.

0/577 known
38 questions
Performance, Profiling & TestingQ376Hard

func square(x int) int { return x * x } func BenchmarkSquare(b *testing.B) { for i := 0; i < b.N; i++ { square(42) } } It typically reports something like 0.25 ns/op —…

Performance, Profiling & TestingQ379Hard

func TestOrder(t *testing.T) { defer fmt.Println("defer") t.Cleanup(func() { fmt.Println("cleanup") }) for i := range 2 { t.Run(fmt.Sprint(i), func(t *testing.T) {…

Performance, Profiling & TestingQ380Medium

Parallel tests in a package run concurrently up to -parallel (default GOMAXPROCS ). Packages themselves run in parallel as separate processes ( -p ). Top-level parallel…

Performance, Profiling & TestingQ393Hard

package main import ( "fmt" "strings" ) func main() { var a strings.Builder a.WriteString("hello") b := a b.WriteString(" world") fmt.Println(b.String()) } It panics :…

Performance, Profiling & TestingQ401Medium

Functions named ExampleXxx in _test.go files serve as both documentation (rendered on pkg.go.dev next to the identifier) and tests. If the function ends with an //…

Next topicModules, Packages & Tooling