fix up freelist stats naming and add FreeAlloc

master
Martin Kobetic 2014-06-18 18:10:42 +00:00
parent afd38460ef
commit 8a386756df
3 changed files with 7 additions and 5 deletions

5
db.go
View File

@ -557,8 +557,9 @@ func (db *DB) allocate(count int) (*page, error) {
// Stats represents statistics about the database.
type Stats struct {
// Freelist stats
FreelistN int // total number of pages on the freelist
FreelistAlloc int // total bytes used by the freelist and the pages on it
FreePageN int // total number of free pages
FreeAlloc int // total bytes allocated in free pages
FreelistInuse int // total bytes used by the freelist
// Transaction stats
TxN int // total number of started read transactions

View File

@ -254,7 +254,7 @@ func TestDB_Stats(t *testing.T) {
})
stats := db.Stats()
assert.Equal(t, 2, stats.TxStats.PageCount, "PageCount")
assert.Equal(t, 2, stats.FreelistN, "FreelistN %d", db.freelist.count())
assert.Equal(t, 2, stats.FreePageN, "FreelistN")
})
}

5
tx.go
View File

@ -241,8 +241,9 @@ func (tx *Tx) close() {
// Merge statistics.
tx.db.statlock.Lock()
tx.db.stats.FreelistN = freelistN
tx.db.stats.FreelistAlloc = freelistAlloc
tx.db.stats.FreePageN = freelistN
tx.db.stats.FreeAlloc = freelistN * tx.db.pageSize
tx.db.stats.FreelistInuse = freelistAlloc
tx.db.stats.TxStats.add(&tx.stats)
tx.db.statlock.Unlock()
} else {