Skip to content

Commit def202c

Browse files
committed
Use testing.B.Loop in benchmarks
Available since Go 1.24.
1 parent 9631883 commit def202c

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

process_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func TestFindProcessInit(t *testing.T) {
197197

198198
func BenchmarkProcesses(b *testing.B) {
199199
b.ReportAllocs()
200-
for i := 0; i < b.N; i++ {
200+
for b.Loop() {
201201
_, err := ps.Processes()
202202
if err != nil {
203203
b.Fatalf("Processes: %v", err)
@@ -209,8 +209,7 @@ func BenchmarkFindProcess(b *testing.B) {
209209
pid := os.Getpid()
210210

211211
b.ReportAllocs()
212-
b.ResetTimer()
213-
for i := 0; i < b.N; i++ {
212+
for b.Loop() {
214213
_, err := ps.FindProcess(pid)
215214
if err != nil {
216215
b.Fatalf("FindProcess: %v", err)

0 commit comments

Comments
 (0)