smithery/JamesPrial

go-testing-benchmarks

Benchmark patterns for performance testing

Installation

$ npx skills add smithery/JamesPrial --skill go-testing-benchmarks

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery/JamesPrial · top by installs.

npx skills add smithery/JamesPrial

Browse all from smithery/JamesPrial

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 1,462 B
  • docs SUMMARY.md 71 B

History

  1. First recorded snapshot · 0 installs

SKILL.md

Benchmarks

Measure function performance with benchmark tests.

CORRECT

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:

  • b.N adjusted automatically for stable timing
  • Sub-benchmarks compare variations
  • b.ResetTimer() excludes setup
  • -benchmem shows allocation stats

WRONG

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:

  • No b.N loop = invalid benchmark
  • Setup time included in measurement
  • Inaccurate performance results