@@ -53,9 +53,10 @@ import qualified Data.ByteString.Internal as BS
5353import Data.Dynamic
5454import Data.Maybe
5555import Data.Map.Strict (Map )
56- import Data.List.Extra
56+ import Data.List.Extra ( foldl' , partition , takeEnd )
5757import qualified Data.Set as Set
5858import qualified Data.Text as T
59+ import Data.Traversable (for )
5960import Data.Tuple.Extra
6061import Data.Unique
6162import Development.IDE.Core.Debouncer
@@ -227,14 +228,15 @@ data IdeState = IdeState
227228
228229
229230-- This is debugging code that generates a series of profiles, if the Boolean is true
230- shakeRunDatabaseProfile :: Maybe FilePath -> ShakeDatabase -> [Action a ] -> IO [a ]
231+ shakeRunDatabaseProfile :: Maybe FilePath -> ShakeDatabase -> [Action a ] -> IO ( [a ], Maybe FilePath )
231232shakeRunDatabaseProfile mbProfileDir shakeDb acts = do
232233 (time, (res,_)) <- duration $ shakeRunDatabase shakeDb acts
233- whenJust mbProfileDir $ \ dir -> do
234- count <- modifyVar profileCounter $ \ x -> let ! y = x+ 1 in return (y,y)
235- let file = " ide-" ++ profileStartTime ++ " -" ++ takeEnd 5 (" 0000" ++ show count) ++ " -" ++ showDP 2 time <.> " html"
236- shakeProfileDatabase shakeDb $ dir </> file
237- return res
234+ proFile <- for mbProfileDir $ \ dir -> do
235+ count <- modifyVar profileCounter $ \ x -> let ! y = x+ 1 in return (y,y)
236+ let file = " ide-" ++ profileStartTime ++ " -" ++ takeEnd 5 (" 0000" ++ show count) ++ " -" ++ showDP 2 time <.> " html"
237+ shakeProfileDatabase shakeDb $ dir </> file
238+ return (dir </> file)
239+ return (res, proFile)
238240 where
239241
240242{-# NOINLINE profileStartTime #-}
@@ -392,9 +394,15 @@ shakeRun IdeState{shakeExtras=ShakeExtras{..}, ..} acts =
392394 let res' = case res of
393395 Left e -> " exception: " <> displayException e
394396 Right _ -> " completed"
397+ profile = case res of
398+ Right (_, Just fp) ->
399+ let link = case filePathToUri' $ toNormalizedFilePath fp of
400+ NormalizedUri x -> x
401+ in " , profile saved at " <> T. unpack link
402+ _ -> " "
395403 logDebug logger $ T. pack $
396- " Finishing shakeRun (took " ++ showDuration runTime ++ " , " ++ res' ++ " )"
397- signalBarrier bar res
404+ " Finishing shakeRun (took " ++ showDuration runTime ++ " , " ++ res' ++ profile ++ " )"
405+ signalBarrier bar ( fst <$> res)
398406 -- important: we send an async exception to the thread, then wait for it to die, before continuing
399407 pure (killThread thread >> void (waitBarrier bar), either throwIO return =<< waitBarrier bar))
400408
0 commit comments