diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-06-24 11:37:16 -0600 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-06-24 11:37:16 -0600 |
commit | 78d08e0438f55eaee5f26e4599890926ac48205f (patch) | |
tree | f40eccfc4c414982f7c02168043ea4c602087887 | |
parent | Merge pull request #210 from benbjohnson/default-options (diff) | |
parent | review tweaks (diff) | |
download | dedo-78d08e0438f55eaee5f26e4599890926ac48205f.tar.gz dedo-78d08e0438f55eaee5f26e4599890926ac48205f.tar.xz |
Merge pull request #212 from Shopify/stats_sub
Improve Stats.Sub()
-rw-r--r-- | db.go | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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 } |