2008-05-27 01:19:21 +04:00
|
|
|
#!/usr/bin/env runhaskell
|
2008-12-05 03:37:47 +03:00
|
|
|
-- simplifyprof.hs somefile.prof
|
|
|
|
-- filter uninteresting fields from GHC profile output
|
|
|
|
-- tested with GHC 6.8
|
|
|
|
-- Simon Michael 2007,2008
|
|
|
|
|
2008-05-27 01:19:21 +04:00
|
|
|
import Data.List
|
2008-12-05 03:37:47 +03:00
|
|
|
import System.Environment
|
|
|
|
import Text.Printf
|
|
|
|
|
|
|
|
main = do
|
2014-09-11 00:07:53 +04:00
|
|
|
args <- getArgs
|
2008-12-05 03:37:47 +03:00
|
|
|
let f = head args
|
|
|
|
s <- readFile f
|
|
|
|
let ls = lines s
|
|
|
|
let (firstpart, secondpart) = break ("individual inherited" `isInfixOf`) ls
|
|
|
|
putStr $ unlines firstpart
|
2009-09-22 15:55:11 +04:00
|
|
|
let fields = map getfields $ filter (not . null) $ drop 2 secondpart
|
2008-12-05 03:37:47 +03:00
|
|
|
let maxnamelen = maximum $ map (length . head) fields
|
2009-09-22 20:51:27 +04:00
|
|
|
let fmt = "%-" ++ show maxnamelen ++ "s %10s %5s %6s %9s %10s"
|
2008-12-05 03:37:47 +03:00
|
|
|
putStrLn $ showheading fmt
|
|
|
|
putStr $ unlines $ map (format fmt) fields
|
|
|
|
|
|
|
|
getfields s = name:rest
|
2008-05-27 01:19:21 +04:00
|
|
|
where
|
2008-12-05 03:37:47 +03:00
|
|
|
space = takeWhile (==' ') s
|
|
|
|
fields = words s
|
|
|
|
name = space ++ head fields
|
|
|
|
rest = drop 3 fields
|
|
|
|
|
|
|
|
showheading fmt = format fmt ["cost centre","entries","%time","%alloc","%time-inh","%alloc-inh"]
|
|
|
|
|
2021-08-16 07:25:18 +03:00
|
|
|
format fmt [s1,s2,s3,s4,s5,s6] = printf fmt s1 s2 s3 s4 s5 s6
|