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

Function TestFileListDB_Memory

internal/caches/list_file_db_sqlite_test.go:108–170  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

106}
107
108func TestFileListDB_Memory(t *testing.T) {
109 if !testutils.IsSingleTesting() {
110 return
111 }
112
113 var db = caches.NewSQLiteFileListDB()
114
115 defer func() {
116 _ = db.Close()
117 }()
118
119 err := db.Open(Tea.Root + "/data/cache-index/p1/db-0.db")
120 if err != nil {
121 t.Fatal(err)
122 }
123
124 err = db.Init()
125 if err != nil {
126 t.Fatal(err)
127 }
128
129 t.Log(db.Total())
130
131 // load hashes
132 var maxId int64
133 var hashList []string
134 var before = time.Now()
135 for i := 0; i < 1_000; i++ {
136 hashList, maxId, err = db.ListHashes(maxId)
137 if err != nil {
138 t.Fatal(err)
139 }
140 if len(hashList) == 0 {
141 t.Log("hashes loaded", time.Since(before).Seconds()*1000, "ms")
142 break
143 }
144 if i%100 == 0 {
145 t.Log(i)
146 }
147 }
148
149 runtime.GC()
150 debug.FreeOSMemory()
151
152 //time.Sleep(600 * time.Second)
153
154 for i := 0; i < 1_000; i++ {
155 _, err = db.ListLFUItems(5000)
156 if err != nil {
157 t.Fatal(err)
158 }
159 if i%100 == 0 {
160 t.Log(i)
161 }
162 }
163
164 t.Log("loaded")
165

Callers

nothing calls this directly

Calls 10

IsSingleTestingFunction · 0.92
NewSQLiteFileListDBFunction · 0.92
LogMethod · 0.80
TotalMethod · 0.80
ListHashesMethod · 0.80
ListLFUItemsMethod · 0.80
CloseMethod · 0.65
InitMethod · 0.65
GCMethod · 0.65
OpenMethod · 0.45

Tested by

no test coverage detected