Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

portlist: add BenchmarkGetListIncremental #6028

Merged
merged 1 commit into from
Oct 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion portlist/portlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,23 @@ func TestSameInodes(t *testing.T) {
}

func BenchmarkGetList(b *testing.B) {
benchmarkGetList(b, false)
}

func BenchmarkGetListIncremental(b *testing.B) {
benchmarkGetList(b, true)
}

func benchmarkGetList(b *testing.B, incremental bool) {
b.ReportAllocs()
var p Poller
for i := 0; i < b.N; i++ {
_, err := p.getList()
pl, err := p.getList()
if err != nil {
b.Fatal(err)
}
if incremental {
p.prev = pl
}
}
}