Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
stats: Remove the now unused Stats.Clone method
Browse files Browse the repository at this point in the history
This has been superseded by the Snapshot method.
  • Loading branch information
mjs committed Apr 10, 2018
1 parent 1617812 commit f5e652b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 32 deletions.
16 changes: 1 addition & 15 deletions stats/stats.go
Expand Up @@ -67,6 +67,7 @@ type CounterPair struct {
Value int
}

// Snapshot holds the names and values of some counters.
type Snapshot []CounterPair

// Snapshot returns the current values of all the counters.
Expand All @@ -80,18 +81,3 @@ func (s *Stats) Snapshot() Snapshot {
}
return out
}

// Clone returns a new Stats instance, copying the source Stats
// counts.
func (s *Stats) Clone() *Stats {
s.mu.Lock()
defer s.mu.Unlock()

out := &Stats{
counts: make(map[string]int),
}
for name, count := range s.counts {
out.counts[name] = count
}
return out
}
17 changes: 0 additions & 17 deletions stats/stats_small_test.go
Expand Up @@ -62,23 +62,6 @@ func TestSnapshot(t *testing.T) {
}, s.Snapshot())
}

func TestClone(t *testing.T) {
s := stats.New("foo", "bar", "qaz")
s.Inc("foo")
s.Inc("bar")
s.Inc("bar")

s2 := s.Clone()
assert.Equal(t, 1, s2.Get("foo"))
assert.Equal(t, 2, s2.Get("bar"))
assert.Equal(t, 0, s2.Get("qaz"))

// Make sure they're independent
s2.Inc("foo")
assert.Equal(t, 2, s2.Get("foo"))
assert.Equal(t, 1, s.Get("foo"))
}

func BenchmarkStats(b *testing.B) {
s := stats.New("foo", "bar")

Expand Down

0 comments on commit f5e652b

Please sign in to comment.