Commit 2b3b3957 authored by Ben Gamari's avatar Ben Gamari 🐢

Clean up

parent 839a0389
......@@ -22,32 +22,21 @@ import LabelMatch
args :: Parser [FilePath]
args = some $ argument str (metavar "FILE" <> help "results.json file")
-- | Hackily align decimal numbers.
padDecimal :: RealFloat a
=> Int -- ^ how many columns before the point
-> Int -- ^ how many digits after the point
-> a -> String
padDecimal before after x =
let s = showGFloat (Just after) x ""
pad = before - length (takeWhile (/= '.') s)
in replicate pad ' ' ++ s
main :: IO ()
main = do
files <- execParser $ info (helper <*> args) mempty
mtrees <- mapM (fmap (MTree.toMap head . fromJust) . MTree.readFile) files
let aligned = alignMany $ M.fromList $ zip (map takeFileName files) mtrees
let tabulate :: (Show a, Ord a) => String -> (Label -> Maybe a) -> IO ()
let tabulate :: (Show a, Ord a) => String -> (LabelMatcher a) -> IO ()
tabulate heading pred = do
putStrLn $ render show show (maybe "-" (\x -> showGFloat (Just 3) x ""))
$ toTable
$ M.fromList
$ mapMaybe (\(k,v) -> (\k' -> (k',v)) <$> pred k)
$ mapMaybe (\(k,v) -> (\k' -> (k',v)) <$> match pred k)
$ M.toList aligned
tabulate "compiler allocations" (match compilerAllocs)
tabulate "compiler mutator time" (match compilerMutTime)
tabulate "compiler GC time" (match compilerGcTime)
tabulate "compiler allocations" $ objectCompilerStats <* "bytes allocated"
tabulate "compiler mutator time" $ objectCompilerStats <* "mutator_cpu_seconds"
tabulate "compiler GC time" $ objectCompilerStats <* "GC_cpu_seconds"
alignMany :: (Align f, Ord k) => M.Map k (f a) -> f (M.Map k a)
alignMany mtrees =
......@@ -60,11 +49,6 @@ alignMany mtrees =
objectCompilerStats :: LabelMatcher (String, String)
objectCompilerStats = (,) <$> wildcard <* "objects" <*> wildcard <* "rts stats"
compilerAllocs, compilerMutTime :: LabelMatcher (String, String)
compilerAllocs = objectCompilerStats <* "bytes allocated"
compilerMutTime = objectCompilerStats <* "mutator_cpu_seconds"
compilerGcTime = objectCompilerStats <* "GC_cpu_seconds"
toTable :: (Ord r, Ord c)
=> M.Map r (M.Map c a)
-> Table r c (Maybe a)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment