clock 0.5.1 → 0.5.2
raw patch · 2 files changed
+21/−36 lines, 2 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- System.Clock: instance Constructor C1_0Clock
- System.Clock: instance Constructor C1_0TimeSpec
- System.Clock: instance Constructor C1_1Clock
- System.Clock: instance Constructor C1_2Clock
- System.Clock: instance Constructor C1_3Clock
- System.Clock: instance Datatype D1Clock
- System.Clock: instance Datatype D1TimeSpec
- System.Clock: instance Enum Clock
- System.Clock: instance Eq Clock
- System.Clock: instance Eq TimeSpec
- System.Clock: instance Generic Clock
- System.Clock: instance Generic TimeSpec
- System.Clock: instance Num TimeSpec
- System.Clock: instance Ord TimeSpec
- System.Clock: instance Read Clock
- System.Clock: instance Read TimeSpec
- System.Clock: instance Selector S1_0_0TimeSpec
- System.Clock: instance Selector S1_0_1TimeSpec
- System.Clock: instance Show Clock
- System.Clock: instance Show TimeSpec
- System.Clock: instance Storable TimeSpec
- System.Clock: instance Typeable Clock
- System.Clock: instance Typeable TimeSpec
- System.Clock: nsec :: TimeSpec -> {-# UNPACK #-} !Int64
- System.Clock: sec :: TimeSpec -> {-# UNPACK #-} !Int64
+ System.Clock: [nsec] :: TimeSpec -> {-# UNPACK #-} !Int64
+ System.Clock: [sec] :: TimeSpec -> {-# UNPACK #-} !Int64
+ System.Clock: instance Foreign.Storable.Storable System.Clock.TimeSpec
+ System.Clock: instance GHC.Classes.Eq System.Clock.Clock
+ System.Clock: instance GHC.Classes.Eq System.Clock.TimeSpec
+ System.Clock: instance GHC.Classes.Ord System.Clock.TimeSpec
+ System.Clock: instance GHC.Enum.Enum System.Clock.Clock
+ System.Clock: instance GHC.Generics.Constructor System.Clock.C1_0Clock
+ System.Clock: instance GHC.Generics.Constructor System.Clock.C1_0TimeSpec
+ System.Clock: instance GHC.Generics.Constructor System.Clock.C1_1Clock
+ System.Clock: instance GHC.Generics.Constructor System.Clock.C1_2Clock
+ System.Clock: instance GHC.Generics.Constructor System.Clock.C1_3Clock
+ System.Clock: instance GHC.Generics.Datatype System.Clock.D1Clock
+ System.Clock: instance GHC.Generics.Datatype System.Clock.D1TimeSpec
+ System.Clock: instance GHC.Generics.Generic System.Clock.Clock
+ System.Clock: instance GHC.Generics.Generic System.Clock.TimeSpec
+ System.Clock: instance GHC.Generics.Selector System.Clock.S1_0_0TimeSpec
+ System.Clock: instance GHC.Generics.Selector System.Clock.S1_0_1TimeSpec
+ System.Clock: instance GHC.Num.Num System.Clock.TimeSpec
+ System.Clock: instance GHC.Read.Read System.Clock.Clock
+ System.Clock: instance GHC.Read.Read System.Clock.TimeSpec
+ System.Clock: instance GHC.Show.Show System.Clock.Clock
+ System.Clock: instance GHC.Show.Show System.Clock.TimeSpec
Files
- System/Clock.hsc +16/−33
- clock.cabal +5/−3
System/Clock.hsc view
@@ -170,43 +170,26 @@ #endif normalize :: TimeSpec -> TimeSpec-normalize (TimeSpec xs xn)- | xn < 0 || xn >= 10^9 =- let (q, r) = xn `divMod` (10^9)- in TimeSpec (xs + q) r- | otherwise = TimeSpec xs xn+normalize (TimeSpec xs xn) | xn < 0 || xn >= 10^9 = TimeSpec (xs + q) r+ | otherwise = TimeSpec xs xn+ where (q, r) = xn `divMod` (10^9) instance Num TimeSpec where- (TimeSpec xs xn) + (TimeSpec ys yn) =- normalize $ TimeSpec (xs + ys) (xn + yn)- (TimeSpec xs xn) - (TimeSpec ys yn) =- normalize $ TimeSpec (xs - ys) (xn - yn)- (normalize -> TimeSpec xs xn) * (normalize -> TimeSpec ys yn) =- let- -- convert to arbitraty Integer type to avoid int overflow- xsi = toInteger xs- xni = toInteger xn- ysi = toInteger ys- yni = toInteger yn- in- normalize $ TimeSpec- -- seconds- (fromInteger $ xsi * ysi)- -- nanoseconds- (fromInteger $ (xni * yni + (xni * ysi + xsi * yni) * (10^9))- `div` (10^9))+ (TimeSpec xs xn) + (TimeSpec ys yn) = normalize $ TimeSpec (xs + ys) (xn + yn)+ (TimeSpec xs xn) - (TimeSpec ys yn) = normalize $ TimeSpec (xs - ys) (xn - yn)+ (TimeSpec xs xn) * (TimeSpec ys yn) =+ let xsi = toInteger xs -- convert to arbitraty Integer type to avoid int overflow+ xni = toInteger xn+ ysi = toInteger ys+ yni = toInteger yn -- seconds -- nanoseconds+ in normalize $! TimeSpec (fromInteger $! xsi * ysi) (fromInteger $! (xni * yni + (xni * ysi + xsi * yni) * (10^9)) `div` (10^9)) negate (TimeSpec xs xn) = normalize $ TimeSpec (negate xs) (negate xn)- abs (normalize -> TimeSpec xs xn)- | xs == 0 = normalize $ TimeSpec 0 xn- | otherwise = normalize $ TimeSpec (abs xs) (signum xs * xn)- signum (normalize -> TimeSpec xs xn)- | xs == 0 = TimeSpec (signum xn) 0- | otherwise = TimeSpec (signum xs) 0- fromInteger x =- -- For range, compute div, mod over integers, not any bounded type.- let (q, r) = x `divMod` (10^9)- in TimeSpec (fromInteger q) (fromInteger r)+ abs (normalize -> TimeSpec xs xn) | xs == 0 = normalize $! TimeSpec 0 xn+ | otherwise = normalize $! TimeSpec (abs xs) (signum xs * xn)+ signum (normalize -> TimeSpec xs xn) | xs == 0 = TimeSpec (signum xn) 0+ | otherwise = TimeSpec (signum xs) 0+--fromInteger x = TimeSpec (fromInteger q) (fromInteger r) where (q, r) = x `divMod` (10^9) instance Eq TimeSpec where (normalize -> TimeSpec xs xn) == (normalize -> TimeSpec ys yn)
clock.cabal view
@@ -1,5 +1,5 @@ name: clock-version: 0.5.1+version: 0.5.2 stability: stable synopsis: High-resolution clock functions: monotonic, realtime, cputime. description: A package for convenient access to high-resolution clock and@@ -25,12 +25,14 @@ . Unit tests and instance fixes by Christian Burger on 2015-06-25. .+ Removed fromInteger definition for TimeSpec, Cetin Sert on 2015-12-15.+ . [Version Scheme] Major-@/R/@-ewrite . New-@/F/@-unctionality . @/I/@-mprovementAndBugFixes . @/P/@-ackagingOnly . * @PackagingOnly@ changes are made for quality assurance reasons. -copyright: Copyright © Cetin Sert 2009-2013, Eugene Kirpichov 2010, Finn Espen Gundersen 2013, Gerolf Seitz 2013, Mathieu Boespflug 2014 2015, Chris Done 2015, Dimitri Sabadie 2015, Christian Burger 2015+copyright: Copyright © Cetin Sert 2009-2016, Eugene Kirpichov 2010, Finn Espen Gundersen 2013, Gerolf Seitz 2013, Mathieu Boespflug 2014 2015, Chris Done 2015, Dimitri Sabadie 2015, Christian Burger 2015 license: BSD3 license-file: LICENSE author: Cetin Sert <cetin@corsis.eu>, Corsis Research@@ -67,7 +69,7 @@ if os(windows) c-sources: cbits/hs_clock_win32.c include-dirs: cbits- ghc-options: -O2 -Wall+ ghc-options: -O3 -Wall if flag(llvm) ghc-options: -fllvm -optlo-O3