-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbenchmark_test.go
More file actions
43 lines (37 loc) · 900 Bytes
/
Copy pathbenchmark_test.go
File metadata and controls
43 lines (37 loc) · 900 Bytes
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
// Copyright (c) 2026 Onur Cinar.
// The source code is provided under MIT License.
// https://github.com/cinar/resile
package resile_test
import (
"context"
"testing"
"github.com/cinar/resile"
)
func BenchmarkDoErr(b *testing.B) {
ctx := context.Background()
action := func(ctx context.Context) error { return nil }
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = resile.DoErr(ctx, action)
}
}
func BenchmarkDo(b *testing.B) {
ctx := context.Background()
action := func(ctx context.Context) (int, error) { return 42, nil }
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_, _ = resile.Do(ctx, action)
}
}
func BenchmarkPolicy(b *testing.B) {
p := resile.NewPolicy()
ctx := context.Background()
action := func(ctx context.Context) error { return nil }
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = p.DoErr(ctx, action)
}
}