Debian Codegraph @

extractstats.go

raw
1 package desync
2
3 import (
4 "sync/atomic"
5 )
6
7 // ExtractStats contains detailed statistics about a file extract operation, such
8 // as if data chunks were copied from seeds or cloned.
9 type ExtractStats struct {
10 ChunksFromSeeds uint64 `json:"chunks-from-seeds"`
11 ChunksFromStore uint64 `json:"chunks-from-store"`
12 ChunksInPlace uint64 `json:"chunks-in-place"`
13 BytesCopied uint64 `json:"bytes-copied-from-seeds"`
14 BytesCloned uint64 `json:"bytes-cloned-from-seeds"`
15 Blocksize uint64 `json:"blocksize"`
16 BytesTotal int64 `json:"bytes-total"`
17 ChunksTotal int `json:"chunks-total"`
18 Seeds int `json:"seeds"`
19 }
20
21 func (s *ExtractStats) incChunksFromStore() {
22 atomic.AddUint64(&s.ChunksFromStore, 1)
23 }
24
25 func (s *ExtractStats) incChunksInPlace() {
26 atomic.AddUint64(&s.ChunksInPlace, 1)
27 }
28
29 func (s *ExtractStats) addChunksFromSeed(n uint64) {
30 atomic.AddUint64(&s.ChunksFromSeeds, n)
31 }
32
33 func (s *ExtractStats) addBytesCopied(n uint64) {
34 atomic.AddUint64(&s.BytesCopied, n)
35 }
36
37 func (s *ExtractStats) addBytesCloned(n uint64) {
38 atomic.AddUint64(&s.BytesCloned, n)
39 }