@@ -53,9 +53,10 @@ import qualified Data.ByteString.Internal as BS
53
53
import Data.Dynamic
54
54
import Data.Maybe
55
55
import Data.Map.Strict (Map )
56
- import Data.List.Extra
56
+ import Data.List.Extra ( foldl' , partition , takeEnd )
57
57
import qualified Data.Set as Set
58
58
import qualified Data.Text as T
59
+ import Data.Traversable (for )
59
60
import Data.Tuple.Extra
60
61
import Data.Unique
61
62
import Development.IDE.Core.Debouncer
@@ -227,14 +228,15 @@ data IdeState = IdeState
227
228
228
229
229
230
-- 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 )
231
232
shakeRunDatabaseProfile mbProfileDir shakeDb acts = do
232
233
(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)
238
240
where
239
241
240
242
{-# NOINLINE profileStartTime #-}
@@ -392,9 +394,15 @@ shakeRun IdeState{shakeExtras=ShakeExtras{..}, ..} acts =
392
394
let res' = case res of
393
395
Left e -> " exception: " <> displayException e
394
396
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
+ _ -> " "
395
403
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)
398
406
-- important: we send an async exception to the thread, then wait for it to die, before continuing
399
407
pure (killThread thread >> void (waitBarrier bar), either throwIO return =<< waitBarrier bar))
400
408
0 commit comments