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,331
- フォーク
- 409
インストール方法
デフォルトでは、最初にソースを確認する 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で見る