Skip to content

Commit 5d6ad40

Browse files
Remove some unnecessary changes, preserve some of the old explanatory comments.
1 parent 0653030 commit 5d6ad40

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ examples/Group
1313
*.sublime-*
1414
dist-newstyle/
1515
cabal.project.local
16+
cabal.project.local~

System/Metrics.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,18 @@ newStore = do
155155
-- | Register a non-negative, monotonically increasing, integer-valued
156156
-- metric. The provided action to read the value must be thread-safe.
157157
-- Also see 'createCounter'.
158-
registerCounter :: T.Text -- ^ Counter name
159-
-> IO Int64 -- ^ Action to read the current metric value
160-
-> Store -- ^ Metric store
158+
registerCounter :: T.Text -- ^ Counter name
159+
-> IO Int64 -- ^ Action to read the current metric value
160+
-> Store -- ^ Metric store
161161
-> IO ()
162162
registerCounter name sample store =
163163
register name (CounterS sample) store
164164

165165
-- | Register an integer-valued metric. The provided action to read
166166
-- the value must be thread-safe. Also see 'createGauge'.
167-
registerGauge :: T.Text -- ^ Gauge name
168-
-> IO Int64 -- ^ Action to read the current metric value
169-
-> Store -- ^ Metric store
167+
registerGauge :: T.Text -- ^ Gauge name
168+
-> IO Int64 -- ^ Action to read the current metric value
169+
-> Store -- ^ Metric store
170170
-> IO ()
171171
registerGauge name sample store =
172172
register name (GaugeS sample) store

System/Metrics/Distribution.hsc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ int64ToDouble i =
162162
{-# INLINE int64ToDouble #-}
163163

164164
-- | Add the same value to the distribution N times.
165+
-- Mean and variance are computed according to
166+
-- http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Online_algorithm
165167
addN :: Distribution -> Double -> Int64 -> IO ()
166168
addN distribution (D## val) (I64## n) = IO $ \s ->
167169
case myStripe distribution of { (IO myStripe') ->
@@ -194,6 +196,11 @@ addN distribution (D## val) (I64## n) = IO $ \s ->
194196
case spinUnlock mba s14 of { s15 ->
195197
(## s15, () ##) }}}}}}}}}}}}}}}}}}}}}}}}}}}}
196198

199+
-- | Combine 'b' with 'a', writing the result in 'a'. Takes the lock of
200+
-- 'b' while combining, but doesn't otherwise modify 'b'. 'a' is
201+
-- assumed to not be used concurrently.
202+
-- See also:
203+
-- http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm
197204
combine :: Distrib -> Distrib -> IO ()
198205
combine (Distrib bMBA) (Distrib aMBA) = IO $ \s ->
199206
case spinLock bMBA s of { s1 ->
@@ -232,6 +239,8 @@ combine (Distrib bMBA) (Distrib aMBA) = IO $ \s ->
232239
case readDoubleArray## bMBA minPos' s13 of { (## s14, bMin ##) ->
233240
case writeDoubleArray## aMBA minPos' bMin s14 of { s15 ->
234241
case maxPos of { (I## maxPos') ->
242+
-- This is slightly hacky, but ok: see
243+
-- 813aa426be78e8abcf1c7cdd43433bcffa07828e
235244
case readDoubleArray## bMBA maxPos' s15 of { (## s16, bMax ##) ->
236245
case writeDoubleArray## aMBA maxPos' bMax s16 of { s17 ->
237246
case spinUnlock bMBA s17 of { s18 ->

0 commit comments

Comments
 (0)