Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How long is your Template Haskell taking to run?
timestamp :: String -> Q a -> Q a
timestamp name action = do
start <- runIO getCurrentTime
runIO $ putStrLn $ "Starting " <> name <> ": " <> show start
a <- action
end <- runIO getCurrentTime
runIO $ do
putStrLn $ "Ending " <> name <> ": " <> show end
putStrLn $ "Elapased " <> name <> ": " <> show (diffUTCTime end start)
pure a
-- used like:
timestamp "persistent models" $ share [mkPersist persistSettings]
$(timestamp "persistent parsing" $ persistFileWith lowercaseSettings "file")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.