Skip to content

Instantly share code, notes, and snippets.

@parsonsmatt
Created August 6, 2019 21:14
Show Gist options
  • Save parsonsmatt/26f89b6503f2c07e5e2f990f4f27c3b7 to your computer and use it in GitHub Desktop.
Save parsonsmatt/26f89b6503f2c07e5e2f990f4f27c3b7 to your computer and use it in GitHub Desktop.
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