data-extra 2.1.0 → 2.1.1
raw patch · 2 files changed
+10/−9 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- data-extra.cabal +1/−1
- src/Data/Time/Extra.hs +9/−8
data-extra.cabal view
@@ -1,5 +1,5 @@ name: data-extra-version: 2.1.0+version: 2.1.1 synopsis: Extra utilities for working on Data.* types. description: Extra utilities for working on Data.* types. license: BSD3
src/Data/Time/Extra.hs view
@@ -67,12 +67,13 @@ -- | Trivial benchmark for some monadic action. bench :: MonadIO m => Integer -> m a -> m (a,NominalDiffTime)-bench i computation = go i Nothing where- go n Nothing = do+bench i computation = go i (Nothing,0) where+ go n (Nothing,_) = do (a,time) <- stopwatch computation- go (n-1) (Just (a,time))- go 0 (Just x) = do- return x- go n (Just (_,avgTime)) = do- (a,timeNew) <- stopwatch computation- go (n-1) (Just (a,(timeNew + avgTime) / 2))+ go (n-1) (Just a,time)+ go 0 (Just x,avg) = do+ return (x, avg)+ go n (Just _,avg) = do+ (a,new) <- stopwatch computation+ go (n-1) (Just a,(new + avg*cnt) / (cnt+1))+ where cnt = fromIntegral (i-n)