Skip to content

Commit d090128

Browse files
committed
add benchmarks
1 parent 6d7600c commit d090128

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

retry_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,20 @@ func BenchmarkDo(b *testing.B) {
553553
}
554554
}
555555

556+
func BenchmarkDoWithData(b *testing.B) {
557+
testError := errors.New("test error")
558+
559+
for i := 0; i < b.N; i++ {
560+
_, _ = DoWithData(
561+
func() (int, error) {
562+
return 0, testError
563+
},
564+
Attempts(10),
565+
Delay(0),
566+
)
567+
}
568+
}
569+
556570
func BenchmarkDoNoErrors(b *testing.B) {
557571
for i := 0; i < b.N; i++ {
558572
_ = Do(
@@ -565,6 +579,18 @@ func BenchmarkDoNoErrors(b *testing.B) {
565579
}
566580
}
567581

582+
func BenchmarkDoWithDataNoErrors(b *testing.B) {
583+
for i := 0; i < b.N; i++ {
584+
_, _ = DoWithData(
585+
func() (int, error) {
586+
return 0, nil
587+
},
588+
Attempts(10),
589+
Delay(0),
590+
)
591+
}
592+
}
593+
568594
func TestIsRecoverable(t *testing.T) {
569595
err := errors.New("err")
570596
assert.True(t, IsRecoverable(err))

0 commit comments

Comments
 (0)