Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/b0c0205e3c0dfefc3ffbd49d22160ad5d624ee1f

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

commit b0c0205e3c0dfefc3ffbd49d22160ad5d624ee1f
Author: Simon Peyton Jones <[email protected]>
Date:   Thu Dec 29 10:31:57 2011 +0000

    Print more informative sizes in -dshow-passes,
    and add intWithCommas to Outputable for printing
    large Int/Integers

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

 compiler/coreSyn/CoreUtils.lhs   |    8 ++++----
 compiler/simplCore/CoreMonad.lhs |    2 +-
 compiler/utils/Outputable.lhs    |   11 ++++++++++-
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/compiler/coreSyn/CoreUtils.lhs b/compiler/coreSyn/CoreUtils.lhs
index d3a2ca5..47e31fa 100644
--- a/compiler/coreSyn/CoreUtils.lhs
+++ b/compiler/coreSyn/CoreUtils.lhs
@@ -1284,10 +1284,10 @@ data CoreStats = CS { cs_tm, cs_ty, cs_co :: Int }
 
 
 instance Outputable CoreStats where 
- ppr (CS { cs_tm = i1, cs_ty = i2, cs_co = i3 }) = 
-    text "size of" <+> vcat [ text "terms     =" <+> int i1
-                            , text "types     =" <+> int i2
-                            , text "coercions =" <+> int i3 ]
+ ppr (CS { cs_tm = i1, cs_ty = i2, cs_co = i3 })
+   = braces (sep [ptext (sLit "terms:")     <+> intWithCommas i1 <> comma,
+                  ptext (sLit "types:")     <+> intWithCommas i2 <> comma,
+                  ptext (sLit "coercions:") <+> intWithCommas i3])
 
 plusCS :: CoreStats -> CoreStats -> CoreStats
 plusCS (CS { cs_tm = p1, cs_ty = q1, cs_co = r1 })
diff --git a/compiler/simplCore/CoreMonad.lhs b/compiler/simplCore/CoreMonad.lhs
index ab69916..c82a557 100644
--- a/compiler/simplCore/CoreMonad.lhs
+++ b/compiler/simplCore/CoreMonad.lhs
@@ -162,7 +162,7 @@ dumpPassResult dflags mb_flag hdr extra_info binds rules
 
   | otherwise
   = Err.debugTraceMsg dflags 2 $
-    (text "Result size of" <+> hdr <+> equals <+> int (coreBindsSize binds))
+    (sep [text "Result size of" <+> hdr, nest 2 (equals <+> ppr 
(coreBindsStats binds))])
           -- Report result size 
          -- This has the side effect of forcing the intermediate to be 
evaluated
 
diff --git a/compiler/utils/Outputable.lhs b/compiler/utils/Outputable.lhs
index e0be21b..248f549 100644
--- a/compiler/utils/Outputable.lhs
+++ b/compiler/utils/Outputable.lhs
@@ -22,7 +22,7 @@ module Outputable (
         empty, nest,
         char,
         text, ftext, ptext,
-        int, integer, float, double, rational,
+        int, intWithCommas, integer, float, double, rational,
         parens, cparen, brackets, braces, quotes, quote, doubleQuotes, 
angleBrackets,
         semi, comma, colon, dcolon, space, equals, dot, arrow, darrow,
         lparen, rparen, lbrack, rbrack, lbrace, rbrace, underscore,
@@ -830,6 +830,15 @@ quotedListWithOr xs = quotedList xs
 %************************************************************************
 
 \begin{code}
+intWithCommas :: Integral a => a -> SDoc
+-- Prints a big integer with commas, eg 345,821
+intWithCommas n
+  | n < 0     = char '-' <> intWithCommas (-n)
+  | q == 0    = int (fromIntegral r)
+  | otherwise = intWithCommas q <> comma <> int (fromIntegral r)
+  where
+    (q,r) = n `quotRem` 1000
+
 -- | Converts an integer to a verbal index:
 --
 -- > speakNth 1 = text "first"



_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to