Skip to content

Commit

Permalink
[#14] Add parallelism level and dependency sum time to profile summary (
Browse files Browse the repository at this point in the history
#18)

* Add parallelism level and dependency sum time to profile summary
* Simplify definition of `totalAllPhases`
This also helps with strictness.

Co-authored-by: Dmitrii Kovanikov <kovanikov@gmail.com>

Fixes #14.
  • Loading branch information
bradrn authored Aug 5, 2022
1 parent 1f4b0a1 commit bb59471
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/DrCabal/Profile/Format.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
module DrCabal.Profile.Format
( fmt
, fmtNanos
, fmtDecimalPlaces
)where

import Colourista.Pure (formatWith)
import Data.Text (pack)
import Numeric (showFFloat)

fmt :: [Text] -> Text -> Text
fmt = formatWith
Expand Down Expand Up @@ -34,3 +37,6 @@ fmtNanos time
emptyIfZero :: Word64 -> Text -> Text
emptyIfZero 0 _ = ""
emptyIfZero t unit = show t <> unit

fmtDecimalPlaces :: Int -> Float -> Text
fmtDecimalPlaces dp f = pack $ showFFloat (Just dp) f ""
15 changes: 12 additions & 3 deletions src/DrCabal/Profile/Stacked.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Colourista.Pure (blue, cyan, red, yellow, magenta)
import Colourista.Short (b, i)

import DrCabal.Model (Status (..), Entry (..))
import DrCabal.Profile.Format (fmt, fmtNanos)
import DrCabal.Profile.Format (fmt, fmtNanos, fmtDecimalPlaces)

import qualified Data.List as List
import qualified Data.Map.Strict as Map
Expand Down Expand Up @@ -116,8 +116,11 @@ formatChart start end width libs = unlines $ concat
summary :: [Text]
summary =
[ b "Summary"
, i " Total dependency build time" <> " : " <> fmtNanos (end - start)
, i " Single block resolution " <> " : " <> fmtNanos blockMeasure
, i " Wall time " <> " : " <> fmtNanos (end - start)
, i " Dependency sum time " <> " : " <> fmtNanos totalAllPhases
, i " Total dependencies " <> " : " <> show (Map.size libs)
, i " Parallelism level " <> " : " <> fmtDecimalPlaces 2 parallelism
, i " Single block resolution" <> " : " <> fmtNanos blockMeasure
, ""
]

Expand Down Expand Up @@ -150,6 +153,12 @@ formatChart start end width libs = unlines $ concat
longestPhase :: Word64
longestPhase = List.maximum $ map (phaseTotal . snd) entries

totalAllPhases :: Word64
totalAllPhases = sum $ map (phaseTotal . snd) entries

parallelism :: Float
parallelism = fromIntegral totalAllPhases / fromIntegral (end - start)

fmtPhase :: Phase -> Text
fmtPhase = fmtNanos . phaseTotal

Expand Down

0 comments on commit bb59471

Please sign in to comment.