Skip to content

Commit bcaf7cc

Browse files
Updating timing module
1 parent a7f7f2e commit bcaf7cc

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

cabal.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ allow-newer:
66

77
packages: .
88

9-
with-compiler: ghc-8.10.2
9+
with-compiler: ghc-8.10.7

src/File/Input.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ runFileParsers input = timeOp $ do
107107

108108

109109
runUnification
110-
:: MonadIO m
110+
:: ( MonadIO m
111+
, NFData b
112+
)
111113
=> AlphabetType
112114
-> (FastaParseResult, BTree b a, TCM)
113115
-> m (CPUTime, Validation (NonEmpty String) (Alphabet Char, Matrix Word, BTree b PreliminaryNode))

src/System/Timing.hs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import System.CPUTime
2121

2222

2323
-- | CPU time with picosecond resolution
24-
newtype CPUTime = CPUTime Integer
24+
newtype CPUTime = CPUTime Natural
2525

2626

2727
instance NFData CPUTime where
@@ -50,40 +50,40 @@ instance Show CPUTime where
5050
day = 24 * hour
5151

5252

53-
zeroPad :: Int -> Integer -> String
53+
zeroPad :: Int -> Natural -> String
5454
zeroPad k i = replicate (k - length shown) '0' <> shown
5555
where
5656
shown = show i
5757

5858

59-
timeOp :: MonadIO m => m a -> m (CPUTime, a)
59+
timeOp :: (MonadIO m, NFData a) => m a -> m (CPUTime, a)
6060
timeOp ioa = do
6161
t1 <- liftIO getCPUTime
62-
a <- ioa
62+
a <- force <$> ioa
6363
t2 <- liftIO getCPUTime
64-
let t = CPUTime (t2 - t1)
64+
let t = CPUTime . fromIntegral $ t2 - t1
6565
pure (t, a)
6666

6767

6868
fromPicoseconds :: Natural -> CPUTime
69-
fromPicoseconds = CPUTime . toInteger
69+
fromPicoseconds = CPUTime
7070

7171

7272
fromMicroseconds :: Natural -> CPUTime
73-
fromMicroseconds = CPUTime . (*1000000000) . toInteger
73+
fromMicroseconds = CPUTime . (*1000000)
7474

7575

7676
fromMilliseconds :: Natural -> CPUTime
77-
fromMilliseconds = CPUTime . (*1000000) . toInteger
77+
fromMilliseconds = CPUTime . (*1000000000)
7878

7979

8080
toPicoseconds :: CPUTime -> Natural
81-
toPicoseconds (CPUTime x) = fromInteger x
81+
toPicoseconds (CPUTime x) = x
8282

8383

8484
toMicroseconds :: CPUTime -> Natural
85-
toMicroseconds (CPUTime x) = fromInteger $ x `div` 1000000
85+
toMicroseconds (CPUTime x) = x `div` 1000000
8686

8787

8888
toMilliseconds :: CPUTime -> Natural
89-
toMilliseconds (CPUTime x) = fromInteger $ x `div` 1000000000
89+
toMilliseconds (CPUTime x) = x `div` 1000000000

0 commit comments

Comments
 (0)