-
Notifications
You must be signed in to change notification settings - Fork 44
/
extractstats.go
39 lines (32 loc) · 1.07 KB
/
extractstats.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
37
38
39
package desync
import (
"sync/atomic"
)
// ExtractStats contains detailed statistics about a file extract operation, such
// as if data chunks were copied from seeds or cloned.
type ExtractStats struct {
ChunksFromSeeds uint64 `json:"chunks-from-seeds"`
ChunksFromStore uint64 `json:"chunks-from-store"`
ChunksInPlace uint64 `json:"chunks-in-place"`
BytesCopied uint64 `json:"bytes-copied-from-seeds"`
BytesCloned uint64 `json:"bytes-cloned-from-seeds"`
Blocksize uint64 `json:"blocksize"`
BytesTotal int64 `json:"bytes-total"`
ChunksTotal int `json:"chunks-total"`
Seeds int `json:"seeds"`
}
func (s *ExtractStats) incChunksFromStore() {
atomic.AddUint64(&s.ChunksFromStore, 1)
}
func (s *ExtractStats) incChunksInPlace() {
atomic.AddUint64(&s.ChunksInPlace, 1)
}
func (s *ExtractStats) addChunksFromSeed(n uint64) {
atomic.AddUint64(&s.ChunksFromSeeds, n)
}
func (s *ExtractStats) addBytesCopied(n uint64) {
atomic.AddUint64(&s.BytesCopied, n)
}
func (s *ExtractStats) addBytesCloned(n uint64) {
atomic.AddUint64(&s.BytesCloned, n)
}