summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErlend Hamberg <erlend@hamberg.no>2014-03-06 23:27:29 +0100
committerAustin Seipp <austin@well-typed.com>2014-04-21 22:30:20 -0500
commit9ca17f8850aeaf1fd2109532338da2ffc0e8be1b (patch)
treefc761d439571835df9d50ee8ca21a1d440c2fbea
parent8586f600613a6a99fee8fe707b00adab1a340641 (diff)
downloadhaskell-9ca17f8850aeaf1fd2109532338da2ffc0e8be1b.tar.gz
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: Austin Seipp <austin@well-typed.com>
-rw-r--r--ghc/GhciMonad.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/ghc/GhciMonad.hs b/ghc/GhciMonad.hs
index 54e7e0c984..a4abe322d2 100644
--- a/ghc/GhciMonad.hs
+++ b/ghc/GhciMonad.hs
@@ -316,7 +316,12 @@ printTimes dflags allocs psecs
secs_str = showFFloat (Just 2) secs
putStrLn (showSDoc dflags (
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