Commit b7bead21 authored by Bastian Kauschke's avatar Bastian Kauschke
Browse files

time minimize

parent 224c0632
......@@ -212,7 +212,9 @@ refineOptions = do
pure RefineOptions { .. }
data MinimizeOptions = MinimizeOptions
{ minimizeApplyTransformations :: Bool
{ minimizeStats :: Bool
, minimizeStatsJson :: Bool
, minimizeApplyTransformations :: Bool
, minimizeEnableSanity :: Bool
, minimizeFunctor :: Maybe (FunctorExpression SomeFunctor Sort)
, minimizeInitState :: Maybe Text
......@@ -261,6 +263,16 @@ minimizeOptions = do
<> help "Name of the initial state of the coalgebra."
)
)
minimizeStats <- switch
( long "stats"
<> help
"Print runtime statistics (such as timing information) to standard error."
)
minimizeStatsJson <- switch
( long "stats-json"
<> help
"Same as --stats, but in json format, suitable for parsing in other programs."
)
minimizeApplyTransformations <- not <$> switch
( long "no-functor-transforms"
<> help
......@@ -572,34 +584,41 @@ main = do
finalizeStats stats
(MinimizeCommand r) -> do
(f :: FunctorExpression SomeFunctor Sort, (symbolTable, encoding)) <- do
let transPolicy = if minimizeApplyTransformations r
stats <- initStats (minimizeStats r) (minimizeStatsJson r)
withTimeStat stats "overall-duration" $ do
(f, (symbolTable, encoding)) <- withTimeStat stats "parse-duration" $ do
let transPolicy = if minimizeApplyTransformations r
then P.ApplyTransformations
else P.DontApplyTransformations
let sanity = if minimizeEnableSanity r
then P.EnableSanityChecks
else P.DisableSanityChecks
let parserConfig = P.Config
{ functorTransforms = transPolicy
, sanityChecks = sanity
, functor = minimizeFunctor r
, initStateName = minimizeInitState r
}
let sanity = if minimizeEnableSanity r
then P.EnableSanityChecks
else P.DisableSanityChecks
readCoalgebra parserConfig (minimizeInputFile r)
>>= \case
Left err -> hPutStrLn stderr err >> exitFailure
Right res -> evaluate res
let parserConfig = P.Config
{ functorTransforms = transPolicy
, sanityChecks = sanity
, functor = minimizeFunctor r
, initStateName = minimizeInitState r
}
part <- stToIO $ refine (Proxy :: Proxy (Desorted SomeFunctor)) encoding (minimizeEnableOpt r)
readCoalgebra parserConfig (minimizeInputFile r)
>>= \case
Left err -> hPutStrLn stderr err >> exitFailure
Right res -> evaluate res
let (encoding', symbolTable') = minimize f encoding symbolTable part
T.putStrLn $ printParseableFunctor f
T.putStrLn ""
LT.putStrLn $ Build.toLazyText $ printEncoding encoding' symbolTable' (sortTable f)
part <- withTimeStat stats "refine-duration"
(stToIO $ refine (Proxy :: Proxy (Desorted SomeFunctor)) encoding (minimizeEnableOpt r))
(encoding', symbolTable') <- withTimeStat stats "minimize-duration"
(return $ minimize f encoding symbolTable part)
withTimeStat stats "output-duration" $ do
T.putStrLn $ printParseableFunctor f
T.putStrLn ""
LT.putStrLn $ Build.toLazyText $ printEncoding encoding' symbolTable' (sortTable f)
finalizeStats stats
(GraphCommand r) -> do
(_, (symbolTable, encoding)) <- do
let transPolicy = if graphApplyTransformations r
......
Supports Markdown
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