Commit e16b42a5 authored by Ben Gamari's avatar Ben Gamari 🐢

Make relative mode configurable

parent 88b92b82
......@@ -20,22 +20,27 @@ import qualified MeasurementTree as MTree
import MeasurementTree (Measurements, Label)
import LabelMatch
args :: Parser [FilePath]
args = some $ argument str (metavar "FILE" <> help "results.json file")
data Mode = RelativeMode | AbsoluteMode
args :: Parser (Mode, [FilePath])
args =
(,)
<$> flag RelativeMode AbsoluteMode (long "absolute" <> short 'a' <> help "show absolute metrics")
<*> some (argument str (metavar "FILE" <> help "results.json file"))
-- | Pick out the interesting part of a set of filenames for use as a friendly
-- name. Essentially we just break up all paths into their components and drop
-- all components common to all.
friendlyNameFiles :: [FilePath] -> M.Map String FilePath
friendlyNameFiles files =
M.fromList
friendlyNameFiles files =
M.fromList
[ (joinPath $ toList name, path)
| (path, name) <- M.toList friendlyNames
]
where
friendlyNames :: M.Map FilePath (Seq.Seq String)
friendlyNames =
fmap (fmap snd . Seq.filter (not . fst) . Seq.zip isCommon) splitPaths
fmap (fmap snd . Seq.filter (not . fst) . Seq.zip isCommon) splitPaths
where
isCommon :: Seq.Seq Bool
isCommon = Seq.fromList $ fmap isCommonComp [0..maximum $ fmap length splitPaths]
......@@ -51,7 +56,7 @@ friendlyNameFiles files =
main :: IO ()
main = do
files <- execParser $ info (helper <*> args) mempty
(mode, files) <- execParser $ info (helper <*> args) mempty
let filesWithFriendlyNames = friendlyNameFiles files
-- Yuck. Figure out friendly name of reference set
[ref] = [ name
......@@ -68,9 +73,15 @@ main = do
[ heading
, replicate 20 '='
, ""
, let showRel = (maybe "-" (showRelative $ showGFloat (Just 3)))
table = toTable $ toRelativeChange ref xs
in render show show showRel table
, case mode of
RelativeMode ->
let showRel = (maybe "-" (showRelative $ showGFloat (Just 3)))
table = toTable $ toRelativeChange ref xs
in render show show showRel table
AbsoluteMode ->
let showVal = (maybe "-" (\x -> showGFloat (Just 3) x ""))
table = toTable xs
in render show show showVal table
, ""
]
where
......
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