[commit: ghc] master: Separate thousands when printing allocated bytes (9ca17f8)

git at git.haskell.org git at git.haskell.org
Tue Apr 22 04:40:35 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/9ca17f8850aeaf1fd2109532338da2ffc0e8be1b/ghc

>---------------------------------------------------------------

commit 9ca17f8850aeaf1fd2109532338da2ffc0e8be1b
Author: Erlend Hamberg <erlend at hamberg.no>
Date:   Thu Mar 6 23:27:29 2014 +0100

    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 at well-typed.com>


>---------------------------------------------------------------

9ca17f8850aeaf1fd2109532338da2ffc0e8be1b
 ghc/GhciMonad.hs |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/ghc/GhciMonad.hs b/ghc/GhciMonad.hs
index 54e7e0c..a4abe32 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



More information about the ghc-commits mailing list