-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitnet-benchmarks.mdc
More file actions
43 lines (35 loc) · 1.09 KB
/
bitnet-benchmarks.mdc
File metadata and controls
43 lines (35 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
---
description: "Enforce benchmark file organization and naming conventions for the BitNet project."
globs: pkg/bitnet/**/*.go
alwaysApply: false
---
# Benchmark Naming & File Layout
**Purpose:** Keep benchmarks discoverable and consistent across packages.
## File placement
- Benchmarks live alongside unit tests in `*_test.go` files under the same package.
```
pkg/bitnet/
+- mycomponent.go
+- mycomponent_test.go # must contain both unit and benchmark tests
```
## Benchmark function names
- Must start with `Benchmark` followed by `<Type>_<Operation>`
- Use `_` to separate semantic units; avoid camel-case after the prefix.
```go
func BenchmarkTensor_Create(b *testing.B) { ... }
func BenchmarkTensor_Get(b *testing.B) { ... }
func BenchmarkTensor_Set(b *testing.B) { ... }
```
## Sub-benchmarks
When you need multiple scenarios in one function, use `b.Run`:
```go
func BenchmarkTensor_Create(b *testing.B) {
for _, size := range []int{100, 1_000, 10_000} {
b.Run(fmt.Sprintf("%d", size), func(b *testing.B) {
for i := 0; i < b.N; i++ {
NewTensor(size)
}
})
}
}
```