Skip to content

Commit 5e6f217

Browse files
authored
addrsmanager: extract out addressing logic from basichost (#3075)
Benchmark for AllAddrs: ``` goos: linux goarch: amd64 pkg: github.com/libp2p/go-libp2p cpu: AMD Ryzen 7 7840U w/ Radeon 780M Graphics BenchmarkAllAddrs-16 16737 122245 ns/op 21240 B/op 218 allocs/op ``` after: ``` goos: linux goarch: amd64 pkg: github.com/libp2p/go-libp2p cpu: AMD Ryzen 7 7840U w/ Radeon 780M Graphics BenchmarkAllAddrs-16 11103236 105.7 ns/op 192 B/op 1 allocs/op ```
1 parent 578af0c commit 5e6f217

File tree

6 files changed

+1093
-385
lines changed

6 files changed

+1093
-385
lines changed

libp2p_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,3 +811,17 @@ func TestCustomTCPDialer(t *testing.T) {
811811
})
812812
require.ErrorContains(t, err, expectedErr.Error())
813813
}
814+
815+
func BenchmarkAllAddrs(b *testing.B) {
816+
h, err := New()
817+
818+
addrsHost := h.(interface{ AllAddrs() []ma.Multiaddr })
819+
require.NoError(b, err)
820+
defer h.Close()
821+
822+
b.ReportAllocs()
823+
b.ResetTimer()
824+
for i := 0; i < b.N; i++ {
825+
addrsHost.AllAddrs()
826+
}
827+
}

0 commit comments

Comments
 (0)