Commit 9ca17f88 authored by Erlend Hamberg's avatar Erlend Hamberg Committed by Austin Seipp

Separate thousands when printing allocated bytes

When printing allocated bytes (`:set +s` in ghci), separate thousands
to make it easier to read large allocations sizes, e.g. “1,200,000
bytes”.
Signed-off-by: default avatarAustin Seipp <austin@well-typed.com>
parent 8586f600
...@@ -316,7 +316,12 @@ printTimes dflags allocs psecs ...@@ -316,7 +316,12 @@ printTimes dflags allocs psecs
secs_str = showFFloat (Just 2) secs secs_str = showFFloat (Just 2) secs
putStrLn (showSDoc dflags ( putStrLn (showSDoc dflags (
parens (text (secs_str "") <+> text "secs" <> comma <+> parens (text (secs_str "") <+> text "secs" <> comma <+>
text (show allocs) <+> text "bytes"))) text (separateThousands allocs) <+> text "bytes")))
where
separateThousands n = reverse . sep . reverse . show $ n
where sep n'
| length n' <= 3 = n'
| otherwise = take 3 n' ++ "," ++ sep (drop 3 n')
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- reverting CAFs -- reverting CAFs
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment