Skip to content

Instantly share code, notes, and snippets.

@epicallan
Forked from parsonsmatt/timestamp.hs
Created August 7, 2019 07:03
Show Gist options
  • Save epicallan/08fb76dea21e36d2eb818ccaecbb1f0c to your computer and use it in GitHub Desktop.
Save epicallan/08fb76dea21e36d2eb818ccaecbb1f0c 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