-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstats.go
36 lines (29 loc) · 819 Bytes
/
stats.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package lm2
import "sync/atomic"
// Stats holds collection statistics.
type Stats struct {
RecordsWritten uint64
RecordsRead uint64
CacheHits uint64
CacheMisses uint64
}
func (s *Stats) incRecordsWritten(count uint64) {
atomic.AddUint64(&s.RecordsWritten, count)
}
func (s *Stats) incRecordsRead(count uint64) {
atomic.AddUint64(&s.RecordsRead, count)
}
func (s *Stats) incCacheHits(count uint64) {
atomic.AddUint64(&s.CacheHits, count)
}
func (s *Stats) incCacheMisses(count uint64) {
atomic.AddUint64(&s.CacheMisses, count)
}
func (s *Stats) clone() Stats {
return Stats{
RecordsWritten: atomic.LoadUint64(&s.RecordsWritten),
RecordsRead: atomic.LoadUint64(&s.RecordsRead),
CacheHits: atomic.LoadUint64(&s.CacheHits),
CacheMisses: atomic.LoadUint64(&s.CacheMisses),
}
}