(t *testing.T)
| 125 | } |
| 126 | |
| 127 | func TestCache_Read(t *testing.T) { |
| 128 | if !testutils.IsSingleTesting() { |
| 129 | return |
| 130 | } |
| 131 | |
| 132 | runtime.GOMAXPROCS(1) |
| 133 | |
| 134 | var cache = NewCache[int](PiecesOption{Count: 32}) |
| 135 | |
| 136 | for i := 0; i < 10_000_000; i++ { |
| 137 | cache.Write("HELLO_WORLD_"+strconv.Itoa(i), i, time.Now().Unix()+int64(i%10240)+1) |
| 138 | } |
| 139 | time.Sleep(10 * time.Second) |
| 140 | |
| 141 | total := 0 |
| 142 | for _, piece := range cache.pieces { |
| 143 | //t.Log(len(piece.m), "keys") |
| 144 | total += len(piece.m) |
| 145 | } |
| 146 | t.Log(total, "total keys") |
| 147 | |
| 148 | before := time.Now() |
| 149 | for i := 0; i < 10_240; i++ { |
| 150 | _ = cache.Read("HELLO_WORLD_" + strconv.Itoa(i)) |
| 151 | } |
| 152 | t.Log(time.Since(before).Seconds()*1000, "ms") |
| 153 | } |
| 154 | |
| 155 | func TestCache_GC(t *testing.T) { |
| 156 | if !testutils.IsSingleTesting() { |
nothing calls this directly
no test coverage detected