MCPcopy Create free account
hub / github.com/ByteStorage/FlyDB / TestPutAndGet

Function TestPutAndGet

engine/put_get_test.go:13–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestPutAndGet(t *testing.T) {
14 opts := config.DefaultOptions
15 dir, _ := os.MkdirTemp("", "flydb-benchmark")
16 opts.DirPath = dir
17 opts.DataFileSize = 64 * 1024 * 1024
18 db, err := NewDB(opts)
19 defer db.Clean()
20 assert.Nil(t, err)
21 assert.NotNil(t, db)
22
23 start := time.Now()
24 for n := 0; n < 500000; n++ {
25 err = db.Put(randkv.GetTestKey(n), randkv.RandomValue(24))
26 assert.Nil(t, err)
27 }
28 end := time.Now()
29 fmt.Println("put time: ", end.Sub(start).String())
30
31 start = time.Now()
32 for n := 0; n < 500000; n++ {
33 _, err = db.Get(randkv.GetTestKey(n))
34 assert.Nil(t, err)
35 }
36 end = time.Now()
37 fmt.Println("get time: ", end.Sub(start).String())
38}

Callers

nothing calls this directly

Calls 7

CleanMethod · 0.95
PutMethod · 0.95
GetMethod · 0.95
GetTestKeyFunction · 0.92
RandomValueFunction · 0.92
NewDBFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected