Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions HTF.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ Executable htfpp
cpphs >= 1.19,
directory >= 1.0,
mtl >= 1.1,
old-time >= 1.0,
random >= 1.0,
text >= 0.11,
time >= 1.8 && < 1.15,
HTF
Build-tool-depends: cpphs:cpphs >= 1.19
Other-Modules:
Expand All @@ -141,12 +141,12 @@ Library
lifted-base >= 0.1,
monad-control >= 0.3,
mtl >= 1.1,
old-time >= 1.0,
pretty >= 1.0,
process >= 1.0,
random >= 1.0,
regex-compat >= 0.92,
text >= 0.11,
time >= 1.8 && < 1.15,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems unnecessary, given line below 😅

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you come up with a fix? Also for the monotonic time thingy?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure #138
Thank you for fast feedback!

time,
vector,
xmlgen >= 0.6
Expand Down
19 changes: 7 additions & 12 deletions Test/Framework/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module Test.Framework.Utils where

import System.Directory
import Data.Char
import System.Time hiding (diffClockTimes)
import Data.Time.Clock.POSIX (getPOSIXTime)
import System.Random
import Data.Array.IO
import Control.Monad
Expand Down Expand Up @@ -143,20 +143,15 @@ strip = reverse . dropWhile isSpace . reverse . dropWhile isSpace
-- Measures execution time of the given IO action in milliseconds
measure :: IO a -> IO (a, Int)
measure ma =
do t0 <- getClockTime
do t0 <- getMicroTime
a <- ma
t1 <- a `seq` getClockTime
let diffMicro = t1 `diffClockTimes` t0
t1 <- a `seq` getMicroTime
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the seq doing there?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think seq forces the result to weak head normal form (WHNF) before taking the end measurement.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I guess that makes sense. I think I suffer from blurry vision, somehow I was assuming that it forces t0 😹

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getPOSIXTime uses system clock (wall time), using getMonotonicTimeNSec measure time duration.

So your proposal @sol seems nice both semantically and practically - avoids wirdness e.g. automatic time change, admins doing their thing :)

let diffMicro = t1 - t0
return (a, fromInteger (diffMicro `div` 1000))

diffClockTimes :: ClockTime -> ClockTime -> Integer
diffClockTimes (TOD s1 p1) (TOD s0 p0) =
(picoseconds p1 + seconds s1) -
(picoseconds p0 + seconds s0)
where
-- bring all into microseconds
picoseconds i = i `div` (1000 * 1000)
seconds i = i * 1000000
getMicroTime :: IO Integer
getMicroTime =
floor . (* 1000000) <$> getPOSIXTime

-- | Randomly shuffle a list
-- /O(N)/
Expand Down
Loading