data-size 0.1.1.1 → 0.1.1.4
raw patch · 3 files changed
+30/−11 lines, 3 files
Files
- Data/Size/Base.hs +17/−9
- Data/Size/Instances.hs +12/−1
- data-size.cabal +1/−1
Data/Size/Base.hs view
@@ -281,9 +281,9 @@ showStats (SST name (Size oc bc) (ST parts)) = unlines $ header- ++ "total value:"+ ++ "accumulated data:" : toLine' ( (charToString name, "")- , (showNum oc, showNum . bytesToWords $ bc)+ , (showNum oc, (showNum {- . bytesToWords -} $ bc, "")) ) : "" : "components:"@@ -291,7 +291,7 @@ where statsTable = L.map toString . M.toList $ parts - toString :: ((String, String), Size) -> ((String, String), (String, String))+ toString :: ((String, String), Size) -> ((String, String), (String, (String, String))) toString ((tn, cn), Size os bs) = ( ( if null cn then charToString tn@@ -299,19 +299,22 @@ , cn ) , ( showNum os- , showNum . bytesToWords $ bs+ , ( showNum {- . bytesToWords -} $ bs+ , showNum $ (bs + os - 1) `div` os+ ) ) ) toTable = L.map toLine' $ statsTable - toLine' :: ((String, String), (String, String)) -> String- toLine' ((tn, cn), (os, bs))+ toLine' :: ((String, String), (String, (String, String))) -> String+ toLine' ((tn, cn), (os, (bs, sz))) = unwords [ if null cn then expR widthCol1 tn else blankName ++ expR widthCol1 cn , expL widthCol2 os , expL widthCol3 bs+ , expL widthCol4 sz ] blankName = replicate 8 ' '@@ -325,20 +328,25 @@ = 16 `max` length col2 `max` (L.maximum . L.map (length . fst . snd) $ statsTable) widthCol3- = 16 `max`length col3 `max` (L.maximum . L.map (length . snd . snd) $ statsTable)+ = 16 `max` length col3 `max` (L.maximum . L.map (length . fst . snd . snd) $ statsTable) + widthCol4+ = 16 `max` length col4 `max` (L.maximum . L.map (length . snd . snd . snd) $ statsTable)+ charToString = subst "[Char]" "String" col1 = "type/constructor"- col2 = "# object"- col3 = "# word" ++ show bitsPerWord+ col2 = "# objects"+ col3 = "# bytes" -- "# word" ++ show bitsPerWord+ col4 = "bytes/obj" header = [l1, l2, l3] where l1 = unwords [ expR widthCol1 col1 , expL widthCol2 col2 , expL widthCol3 col3+ , expL widthCol4 col4 ] l2 = map (const '=') l1 l3 = ""
Data/Size/Instances.hs view
@@ -9,10 +9,11 @@ import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as BL+import Data.Int import qualified Data.IntMap as IM import qualified Data.IntSet as IS import qualified Data.Map as M-+import Data.Word import qualified Foreign.Storable as FS -- ----------------------------------------@@ -22,6 +23,16 @@ instance Sizeable Char where dataOf = dataOfStorable instance Sizeable Float where dataOf = dataOfStorable instance Sizeable Double where dataOf = dataOfStorable++instance Sizeable Word8 where dataOf = dataOfStorable+instance Sizeable Word16 where dataOf = dataOfStorable+instance Sizeable Word32 where dataOf = dataOfStorable+instance Sizeable Word64 where dataOf = dataOfStorable++instance Sizeable Int8 where dataOf = dataOfStorable+instance Sizeable Int16 where dataOf = dataOfStorable+instance Sizeable Int32 where dataOf = dataOfStorable+instance Sizeable Int64 where dataOf = dataOfStorable dataOfStorable :: FS.Storable a => a -> Bytes dataOfStorable x
data-size.cabal view
@@ -1,5 +1,5 @@ name: data-size-version: 0.1.1.1+version: 0.1.1.4 synopsis: Profiling of data structures description: Profiling of data structures for counting the # of object allocated for a value