-
Notifications
You must be signed in to change notification settings - Fork 25
replace old-time with time in measure from Test.Framework.Utils
#137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. getPOSIXTime uses 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)/ | ||
|
|
||
There was a problem hiding this comment.
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 😅
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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!