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

Commit

Permalink
Merge pull request #212 from Shopify/stats_sub
Browse files Browse the repository at this point in the history
Improve Stats.Sub()
  • Loading branch information
benbjohnson committed Jun 24, 2014
2 parents c45c4a1 + 8dd18bd commit 78d08e0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,18 @@ type Stats struct {
// you need the performance counters that occurred within that time span.
func (s *Stats) Sub(other *Stats) Stats {
var diff Stats
if s == nil {
if other == nil {
return diff
} else {
return *other
}
}
diff = *s
if other == nil {
return diff
}
diff.TxN = other.TxN - diff.TxN
diff.TxStats = s.TxStats.Sub(&other.TxStats)
return diff
}
Expand Down

0 comments on commit 78d08e0

Please sign in to comment.