benchmark
Create or modify hot-path code or optimizations should be validated by a Go Benchmark
소스 정보
- 저장소
- zalando/skipper
- 최근 소스 활동
- 2026년 8월 31일 13:54
- 감지된 SKILL.md 언어
- 영어
- 스타
- 3,332
- 포크
- 408
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
SKILL.md 표시 중
SKILL.md
소스 지침 · 읽기 전용 미리보기- name
- benchmark
- description
- Create or modify hot-path code or optimizations should be validated by a Go Benchmark
- license
- MIT
- compatibility
- opencode, claude
- metadata
- {"audience":"maintainers, contributors"}
## What I do
- focus on performance and allocations
## When to use me
Use this when you are creating or modifying code in the hot path.
## Quick start
### Benchmarks
Write benchmarks alongside any performance-sensitive change. Use `benchstat`
with `-count 20` to compare. Always report `sec/op`, `B/op`, and `allocs/op`.
Target zero allocations in hot-path code.
```go
func BenchmarkMyPredicate(b *testing.B) {
p := &predicate{...}
req := httptest.NewRequest("GET", "/", nil)
req.Header.Set("Authorization", "Bearer "+testToken)
b.ReportAllocs()
b.ResetTimer()
for b.Loop() {
p.Match(req)
}
}
```
Example run:
```bash
% go test -bench=BenchmarkMyPredicate -benchmem -run='^$' -count 20 -cpu 1,2,4,8,16 ./predicates/mypredicate > old.txt
# ..edit code..
% go test -bench=BenchmarkMyPredicate -benchmem -run='^$' -count 20 -cpu 1,2,4,8,16 ./predicates/mypredicate > new.txt
% benchstat old.txt new.txt
```
Show the output of benchstat to the developer.
GitHub에서 보기