diff options
Diffstat (limited to 'cmd/bolt/stats_test.go')
-rw-r--r-- | cmd/bolt/stats_test.go | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/cmd/bolt/stats_test.go b/cmd/bolt/stats_test.go index 9662f09..2ad5d51 100644 --- a/cmd/bolt/stats_test.go +++ b/cmd/bolt/stats_test.go @@ -1,6 +1,8 @@ package main_test import ( + "os" + "strconv" "testing" "github.com/boltdb/bolt" @@ -9,12 +11,31 @@ import ( ) func TestStats(t *testing.T) { + if os.Getpagesize() != 4096 { + t.Skip() + } SetTestMode(true) open(func(db *bolt.DB, path string) { db.Update(func(tx *bolt.Tx) error { - tx.CreateBucket([]byte("foo")) - tx.CreateBucket([]byte("bar")) - tx.CreateBucket([]byte("baz")) + b, err := tx.CreateBucket([]byte("foo")) + if err != nil { + return err + } + for i := 0; i < 10; i++ { + b.Put([]byte(strconv.Itoa(i)), []byte(strconv.Itoa(i))) + } + b, err = tx.CreateBucket([]byte("bar")) + if err != nil { + return err + } + for i := 0; i < 100; i++ { + b.Put([]byte(strconv.Itoa(i)), []byte(strconv.Itoa(i))) + } + b, err = tx.CreateBucket([]byte("baz")) + if err != nil { + return err + } + b.Put([]byte("key"), []byte("value")) return nil }) db.Close() @@ -23,15 +44,19 @@ func TestStats(t *testing.T) { "Page count statistics\n"+ "\tNumber of logical branch pages: 0\n"+ "\tNumber of physical branch overflow pages: 0\n"+ - "\tNumber of logical leaf pages: 2\n"+ + "\tNumber of logical leaf pages: 1\n"+ "\tNumber of physical leaf overflow pages: 0\n"+ "Tree statistics\n"+ - "\tNumber of keys/value pairs: 0\n"+ - "\tNumber of levels in B+tree: 0\n"+ + "\tNumber of keys/value pairs: 101\n"+ + "\tNumber of levels in B+tree: 1\n"+ "Page size utilization\n"+ "\tBytes allocated for physical branch pages: 0\n"+ - "\tBytes actually used for branch data: 0\n"+ - "\tBytes allocated for physical leaf pages: 8192\n"+ - "\tBytes actually used for leaf data: 0", output) + "\tBytes actually used for branch data: 0 (0%)\n"+ + "\tBytes allocated for physical leaf pages: 4096\n"+ + "\tBytes actually used for leaf data: 1996 (48%)\n"+ + "Bucket statistics\n"+ + "\tTotal number of buckets: 2\n"+ + "\tTotal number on inlined buckets: 1 (50%)\n"+ + "\tBytes used for inlined buckets: 40 (2%)", output) }) } |