Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#14] Add parallelism level and dependency sum time to profile summary #18

Merged
merged 2 commits into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ""
bradrn marked this conversation as resolved.
Show resolved Hide resolved
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 = getSum $ foldMap (Sum . phaseTotal . snd) entries
bradrn marked this conversation as resolved.
Show resolved Hide resolved

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

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

Expand Down