Skip to content

Commit

Permalink
add benchmark for parallel processing
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo82148 committed Dec 29, 2023
1 parent 5b0d4a5 commit 728f568
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"testing"
"time"
)

//go:noinline
Expand Down Expand Up @@ -56,3 +57,19 @@ func BenchmarkDoSuccess(b *testing.B) {
})
}
}

func BenchmarkDo_Parallel(b *testing.B) {
err := errors.New("error")
policy := &Policy{
MaxCount: 100,
Jitter: 1 * time.Nanosecond,
}
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
policy.Do(context.Background(), func() error {
dummyFunc()
return err
})
}
})
}

0 comments on commit 728f568

Please sign in to comment.