MCPcopy Index your code
hub / github.com/syncthing/syncthing / TestBenchmarkDropAllRemote

Function TestBenchmarkDropAllRemote

internal/db/sqlite/db_bench_test.go:227–270  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

225}
226
227func TestBenchmarkDropAllRemote(t *testing.T) {
228 if testing.Short() || os.Getenv("LONG_TEST") == "" {
229 t.Skip("slow test")
230 }
231
232 db, err := Open(t.TempDir())
233 if err != nil {
234 t.Fatal(err)
235 }
236 t.Cleanup(func() {
237 if err := db.Close(); err != nil {
238 t.Fatal(err)
239 }
240 })
241
242 fs := make([]protocol.FileInfo, 1000)
243 seq := 0
244 for {
245 local, err := db.CountLocal(folderID, protocol.LocalDeviceID)
246 if err != nil {
247 t.Fatal(err)
248 }
249 if local.Files >= 15_000 {
250 break
251 }
252 for i := range fs {
253 seq++
254 fs[i] = genFile(rand.String(24), 64, seq)
255 }
256 if err := db.Update(folderID, protocol.DeviceID{42}, fs); err != nil {
257 t.Fatal(err)
258 }
259 if err := db.Update(folderID, protocol.LocalDeviceID, fs); err != nil {
260 t.Fatal(err)
261 }
262 }
263
264 t0 := time.Now()
265 if err := db.DropAllFiles(folderID, protocol.DeviceID{42}); err != nil {
266 t.Fatal(err)
267 }
268 d := time.Since(t0)
269 t.Log("drop all took", d)
270}
271
272func TestBenchmarkSizeManyFilesRemotes(t *testing.T) {
273 // Reports the database size for a setup with many files and many remote

Callers

nothing calls this directly

Calls 12

StringFunction · 0.92
OpenFunction · 0.85
genFileFunction · 0.85
ShortMethod · 0.80
FatalMethod · 0.80
CloseMethod · 0.65
CountLocalMethod · 0.65
UpdateMethod · 0.65
NowMethod · 0.65
DropAllFilesMethod · 0.65
SinceMethod · 0.65
LogMethod · 0.65

Tested by

no test coverage detected