MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / TestCache_Read

Function TestCache_Read

internal/ttlcache/cache_test.go:127–153  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

125}
126
127func 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
155func TestCache_GC(t *testing.T) {
156 if !testutils.IsSingleTesting() {

Callers

nothing calls this directly

Calls 5

IsSingleTestingFunction · 0.92
UnixMethod · 0.80
LogMethod · 0.80
WriteMethod · 0.65
ReadMethod · 0.65

Tested by

no test coverage detected