Skip to content

Commit

Permalink
Markdown table and headings (#1850)
Browse files Browse the repository at this point in the history
Fixes #1837
  • Loading branch information
noonio authored Feb 12, 2025
2 parents 59c2af2 + 30d4212 commit 5e55e3e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
44 changes: 22 additions & 22 deletions hydra-cluster/bench/Bench/EndToEnd.hs
Original file line number Diff line number Diff line change
Expand Up @@ -229,22 +229,18 @@ defaultDescription = ""
-- Here is a sample content:
--
-- @@
-- 2025-02-04 17:22:50.30543862 UTC
-- Used: 7648M, Free: 46.9G
-- 2025-02-04 17:22:55.305513945 UTC
-- Used: 7713M, Free: 46.9G
-- 2025-02-04 17:23:00.30550915 UTC
-- Used: 7715M, Free: 46.9G
-- 2025-02-04 17:23:05.305513574 UTC
-- Used: 7717M, Free: 46.8G
-- 2025-02-04 17:23:10.305538265 UTC
-- Used: 7718M, Free: 46.8G
-- 2025-02-04 17:23:15.305519942 UTC
-- Used: 7719M, Free: 46.8G
-- 2025-02-04 17:23:20.30550604 UTC
-- Used: 7722M, Free: 46.8G
-- 2025-02-04 17:23:25.305413146 UTC
-- Used: 7723M, Free: 46.8G
-- | Time | Used | Free |
-- |------|------|------|
-- | 2025-02-12 09:45:53.585693506 UTC | 937M | 3731M |
-- | 2025-02-12 09:45:58.585773969 UTC | 1115M | 3553M |
-- | 2025-02-12 09:46:03.585779372 UTC | 1121M | 3546M |
-- | 2025-02-12 09:46:08.585751614 UTC | 1121M | 3545M |
-- | 2025-02-12 09:46:13.585925376 UTC | 1163M | 3435M |
-- | 2025-02-12 09:46:18.585811324 UTC | 1188M | 3334M |
-- | 2025-02-12 09:46:23.585786153 UTC | 1193M | 3328M |
-- | 2025-02-12 09:46:28.585797897 UTC | 1194M | 3327M |
-- | 2025-02-12 09:46:33.585771299 UTC | 1194M | 3326M |
-- | 2025-02-12 09:46:38.585774197 UTC | 1195M | 3325M |
-- ...
-- @@
--
Expand All @@ -256,7 +252,11 @@ withOSStats workDir tvar action =
Just _ ->
withCreateProcess process{std_out = CreatePipe} $ \_stdin out _stderr _processHandle ->
race
(collectStats tvar out)
( do
-- Write the header
atomically $ writeTVar tvar [" | Time | Used | Free | ", "|------|------|------|"]
collectStats tvar out
)
action
>>= \case
Left _ -> failure "dstat process failed unexpectedly"
Expand All @@ -277,13 +277,13 @@ withOSStats workDir tvar action =
now <- getCurrentTime
let str =
pack $
show now
<> "\n\t"
<> "Used: "
" | "
<> show now
<> " | "
<> memUsed
<> ", "
<> "Free: "
<> " | "
<> memFree
<> " | "
stats <- readTVarIO tvar'
atomically $ writeTVar tvar' $ stats <> [str]
_ -> pure ()
Expand Down
4 changes: 2 additions & 2 deletions hydra-cluster/bench/Bench/Summary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ textReport (Summary{totalTxs, numberOfTxs, averageConfirmationTime, quantiles, n
else []
)
++ ["Invalid txs: " <> show numberOfInvalidTxs]
++ if null systemStats then [] else "\n| Memory data | \n" : [unlines systemStats]
++ if null systemStats then [] else "\n### Memory data \n" : [unlines systemStats]

markdownReport :: UTCTime -> [(Summary, SystemStats)] -> [Text]
markdownReport now summaries =
Expand Down Expand Up @@ -125,7 +125,7 @@ markdownReport now summaries =
++ [ "| _Number of Invalid txs_ | " <> show numberOfInvalidTxs <> " |"
]
++ [" "]
++ if null systemStats then [] else "\n| Memory data | \n" : [unlines systemStats]
++ if null systemStats then [] else "\n### Memory data \n" : [unlines systemStats]

nominalDiffTimeToMilliseconds :: NominalDiffTime -> Nano
nominalDiffTimeToMilliseconds = fromRational . (* 1000) . toRational . nominalDiffTimeToSeconds

0 comments on commit 5e55e3e

Please sign in to comment.