MCPcopy
hub / github.com/etcd-io/bbolt / TestTx_allocatePageStats

Function TestTx_allocatePageStats

allocate_test.go:10–39  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestTx_allocatePageStats(t *testing.T) {
11 for n, f := range map[string]freelist.Interface{"hashmap": freelist.NewHashMapFreelist(), "array": freelist.NewArrayFreelist()} {
12 t.Run(n, func(t *testing.T) {
13 ids := []common.Pgid{2, 3}
14 f.Init(ids)
15
16 tx := &Tx{
17 db: &DB{
18 freelist: f,
19 pageSize: common.DefaultPageSize,
20 },
21 meta: &common.Meta{},
22 pages: make(map[common.Pgid]*common.Page),
23 }
24
25 txStats := tx.Stats()
26 prePageCnt := txStats.GetPageCount()
27 allocateCnt := f.FreeCount()
28
29 if _, err := tx.allocate(allocateCnt); err != nil {
30 t.Fatal(err)
31 }
32
33 txStats = tx.Stats()
34 if txStats.GetPageCount() != prePageCnt+int64(allocateCnt) {
35 t.Errorf("Allocated %d but got %d page in stats", allocateCnt, txStats.GetPageCount())
36 }
37 })
38 }
39}

Callers

nothing calls this directly

Calls 10

StatsMethod · 0.95
allocateMethod · 0.95
NewHashMapFreelistFunction · 0.92
NewArrayFreelistFunction · 0.92
RunMethod · 0.80
GetPageCountMethod · 0.80
InitMethod · 0.65
FreeCountMethod · 0.65
FatalMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected