Skip to content

Commit

Permalink
add benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
craigpangea committed Aug 3, 2023
1 parent 6d7600c commit d090128
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,20 @@ func BenchmarkDo(b *testing.B) {
}
}

func BenchmarkDoWithData(b *testing.B) {
testError := errors.New("test error")

for i := 0; i < b.N; i++ {
_, _ = DoWithData(
func() (int, error) {
return 0, testError
},
Attempts(10),
Delay(0),
)
}
}

func BenchmarkDoNoErrors(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = Do(
Expand All @@ -565,6 +579,18 @@ func BenchmarkDoNoErrors(b *testing.B) {
}
}

func BenchmarkDoWithDataNoErrors(b *testing.B) {
for i := 0; i < b.N; i++ {
_, _ = DoWithData(
func() (int, error) {
return 0, nil
},
Attempts(10),
Delay(0),
)
}
}

func TestIsRecoverable(t *testing.T) {
err := errors.New("err")
assert.True(t, IsRecoverable(err))
Expand Down

0 comments on commit d090128

Please sign in to comment.