npx claudepluginhub jamesprial/prial-plugins --plugin golang-workflowThis skill uses the workspace's default tool permissions.
Measure function performance with benchmark tests.
Guides Go performance measurement: writing benchmarks with b.Loop(), running pprof profiles, analyzing with benchstat, CI regression detection, Prometheus metrics.
Optimizes Go code performance using patterns like strconv over fmt, avoiding repeated string-to-byte conversions, specifying slice/map capacities, and passing values. Includes benchmarking script with benchstat support.
Provides Go testing patterns with TDD: table-driven tests, subtests, benchmarks, fuzzing, and coverage for reliable, idiomatic tests.
Share bugs, ideas, or general feedback.
Measure function performance with benchmark tests.
func Benchmark_Fibonacci(b *testing.B) {
for i := 0; i < b.N; i++ {
Fibonacci(10)
}
}
func Benchmark_Fibonacci_Cases(b *testing.B) {
cases := []struct {
name string
n int
}{
{name: "small", n: 10},
{name: "medium", n: 20},
{name: "large", n: 30},
}
for _, bc := range cases {
b.Run(bc.name, func(b *testing.B) {
for i := 0; i < b.N; i++ {
Fibonacci(bc.n)
}
})
}
}
func Benchmark_StringConcat(b *testing.B) {
b.ResetTimer() // Exclude setup time
for i := 0; i < b.N; i++ {
_ = "hello" + "world"
}
}
Run benchmarks:
go test -bench=. -benchmem
Why:
func Benchmark_Fibonacci(b *testing.B) {
Fibonacci(10) // Missing loop
}
func Benchmark_NoReset(b *testing.B) {
// Expensive setup
data := generateLargeData()
// Missing b.ResetTimer()
for i := 0; i < b.N; i++ {
Process(data)
}
}
Problems: