Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Software
CoPaR
Commits
b7bead21
Commit
b7bead21
authored
Oct 13, 2020
by
Bastian Kauschke
Browse files
time minimize
parent
224c0632
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/Main.hs
View file @
b7bead21
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment