aboutsummaryrefslogtreecommitdiff
path: root/cmd/bolt/stats.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/bolt/stats.go')
-rw-r--r--cmd/bolt/stats.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/cmd/bolt/stats.go b/cmd/bolt/stats.go
index 6968273..54a0f44 100644
--- a/cmd/bolt/stats.go
+++ b/cmd/bolt/stats.go
@@ -46,17 +46,26 @@ func Stats(path, prefix string) {
println("Page size utilization")
printf("\tBytes allocated for physical branch pages: %d\n", s.BranchAlloc)
- percentage := int(float32(s.BranchInuse) * 100.0 / float32(s.BranchAlloc))
+ var percentage int
+ if s.BranchAlloc != 0 {
+ percentage = int(float32(s.BranchInuse) * 100.0 / float32(s.BranchAlloc))
+ }
printf("\tBytes actually used for branch data: %d (%d%%)\n", s.BranchInuse, percentage)
printf("\tBytes allocated for physical leaf pages: %d\n", s.LeafAlloc)
- percentage = int(float32(s.LeafInuse) * 100.0 / float32(s.LeafAlloc))
+ percentage = 0
+ if s.LeafAlloc != 0 {
+ percentage = int(float32(s.LeafInuse) * 100.0 / float32(s.LeafAlloc))
+ }
printf("\tBytes actually used for leaf data: %d (%d%%)\n", s.LeafInuse, percentage)
- println("Bucket statistics ")
+ println("Bucket statistics")
printf("\tTotal number of buckets: %d\n", s.BucketN)
percentage = int(float32(s.InlineBucketN) * 100.0 / float32(s.BucketN))
printf("\tTotal number on inlined buckets: %d (%d%%)\n", s.InlineBucketN, percentage)
- percentage = int(float32(s.InlineBucketInuse) * 100.0 / float32(s.LeafInuse))
+ percentage = 0
+ if s.LeafInuse != 0 {
+ percentage = int(float32(s.InlineBucketInuse) * 100.0 / float32(s.LeafInuse))
+ }
printf("\tBytes used for inlined buckets: %d (%d%%)\n", s.InlineBucketInuse, percentage)
return nil