(b *testing.B)
| 110 | } |
| 111 | |
| 112 | func 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 | } |