
On 11-10-20 01:38 PM, thomas burt wrote:
I've been trying to measure execution time for some code I'm running with the StateT monad transformer.
I have a function f :: StateT MyState IO a
Now, I measure the time it takes to run an invocation of this function from beginning to end, i.e.
f = do t0 <- getCurrentTime stuffToDo t1 <- getCurrentTime liftIO $ putStrLn (show $ diffUTCTime t1 t0)
And also measure like this:
g :: IO g = do t0 <- getCurrentTime (val,newState) <- runStateT f initialState t1 <- getCurrentTime putStrLn $ "outside: " ++ (show $ diffUTCTime t1 t0)
Where can I find stuffToDo? How do you get away with getCurrentTime (as opposed to liftIO getCurrentTime) inside f? Does not type-check. How much should I trust this code?