Created
August 6, 2019 21:14
-
-
Save parsonsmatt/26f89b6503f2c07e5e2f990f4f27c3b7 to your computer and use it in GitHub Desktop.
How long is your Template Haskell taking to run?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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