MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / BenchmarkDAUManager_AddIP_Cache

Function BenchmarkDAUManager_AddIP_Cache

internal/stats/dau_manager_test.go:112–135  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

110}
111
112func BenchmarkDAUManager_AddIP_Cache(b *testing.B) {
113 runtime.GOMAXPROCS(1)
114
115 var cachedIPs []stats.IPInfo
116 var maxIPs = 128
117 b.Log("maxIPs:", maxIPs)
118 for i := 0; i < maxIPs; i++ {
119 cachedIPs = append(cachedIPs, stats.IPInfo{
120 IP: testutils.RandIP(),
121 ServerId: 1,
122 })
123 }
124
125 b.ResetTimer()
126
127 for i := 0; i < b.N; i++ {
128 var ip = "1.2.3.4"
129 for _, cacheIP := range cachedIPs {
130 if cacheIP.IP == ip && cacheIP.ServerId == 1 {
131 break
132 }
133 }
134 }
135}

Callers

nothing calls this directly

Calls 2

RandIPFunction · 0.92
LogMethod · 0.80

Tested by

no test coverage detected