Skip to content

Commit

Permalink
improve GetAndClearAddrs benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
sukunrt committed Dec 17, 2024
1 parent ba1703f commit 478fd59
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions p2p/host/peerstore/test/benchmarks_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,20 @@ func BenchmarkPeerstore(b *testing.B, factory PeerstoreFactory, variant string)
ps, cleanup := factory()
defer cleanup()
b.ResetTimer()
itersPerBM := 10
for i := 0; i < b.N; i++ {
pp := peers[i%N]
ps.AddAddrs(pp.ID, pp.Addr, pstore.RecentlyConnectedAddrTTL)
ps.Addrs(pp.ID)
ps.ClearAddrs(pp.ID)
for j := 0; j < itersPerBM; j++ {
pp := peers[(i+j)%N]
ps.AddAddrs(pp.ID, pp.Addr, pstore.RecentlyConnectedAddrTTL)
}
for j := 0; j < itersPerBM; j++ {
pp := peers[(i+j)%N]
ps.Addrs(pp.ID)
}
for j := 0; j < itersPerBM; j++ {
pp := peers[(i+j)%N]
ps.ClearAddrs(pp.ID)
}
}
})

Expand Down

0 comments on commit 478fd59

Please sign in to comment.