Use a timer to clock the different phases of the translation.

* src/tgbatest/ltl2tgba.cc: Add option -T.
This commit is contained in:
Alexandre Duret-Lutz 2009-11-06 15:57:24 +01:00
parent 77df39b4dd
commit e539226e13
2 changed files with 100 additions and 58 deletions

View file

@ -1,3 +1,9 @@
2009-11-06 Alexandre Duret-Lutz <adl@lrde.epita.fr>
Use a timer to clock the different phases of the translation.
* src/tgbatest/ltl2tgba.cc: Add option -T.
2009-11-08 Alexandre Duret-Lutz <adl@lrde.epita.fr> 2009-11-08 Alexandre Duret-Lutz <adl@lrde.epita.fr>
Deprecate ltl::destroy(f) in favor of f->destroy() Deprecate ltl::destroy(f) in favor of f->destroy()

View file

@ -48,6 +48,7 @@
#include "tgbaalgos/reductgba_sim.hh" #include "tgbaalgos/reductgba_sim.hh"
#include "tgbaalgos/replayrun.hh" #include "tgbaalgos/replayrun.hh"
#include "tgbaalgos/rundotdec.hh" #include "tgbaalgos/rundotdec.hh"
#include "misc/timer.hh"
#include "tgbaalgos/stats.hh" #include "tgbaalgos/stats.hh"
#include "tgbaalgos/scc.hh" #include "tgbaalgos/scc.hh"
@ -140,6 +141,8 @@ syntax(char* prog)
<< " -S convert to explicit automata, and number states " << " -S convert to explicit automata, and number states "
<< "in BFS order" << std::endl << "in BFS order" << std::endl
<< " -t display reachable states in LBTT's format" << std::endl << " -t display reachable states in LBTT's format" << std::endl
<< " -T time the different phases of the translation"
<< std::endl
<< " -U[PROPS] consider atomic properties of the formula as " << " -U[PROPS] consider atomic properties of the formula as "
<< "exclusive events, and" << std::endl << "exclusive events, and" << std::endl
<< " PROPS as unobservables events (implies -f)" << " PROPS as unobservables events (implies -f)"
@ -203,6 +206,8 @@ main(int argc, char** argv)
spot::tgba* product = 0; spot::tgba* product = 0;
spot::tgba* product_to_free = 0; spot::tgba* product_to_free = 0;
spot::bdd_dict* dict = new spot::bdd_dict(); spot::bdd_dict* dict = new spot::bdd_dict();
spot::timer_map tm;
bool use_timer = false;
for (;;) for (;;)
{ {
@ -472,6 +477,10 @@ main(int argc, char** argv)
{ {
output = 6; output = 6;
} }
else if (!strcmp(argv[formula_index], "-T"))
{
use_timer = true;
}
else if (!strncmp(argv[formula_index], "-U", 2)) else if (!strncmp(argv[formula_index], "-U", 2))
{ {
unobservables = new spot::ltl::atomic_prop_set; unobservables = new spot::ltl::atomic_prop_set;
@ -520,6 +529,7 @@ main(int argc, char** argv)
if (file_opt) if (file_opt)
{ {
tm.start("reading formula");
if (strcmp(argv[formula_index], "-")) if (strcmp(argv[formula_index], "-"))
{ {
std::ifstream fin(argv[formula_index]); std::ifstream fin(argv[formula_index]);
@ -539,6 +549,7 @@ main(int argc, char** argv)
{ {
std::getline(std::cin, input, '\0'); std::getline(std::cin, input, '\0');
} }
tm.stop("reading formula");
} }
else else
{ {
@ -549,7 +560,9 @@ main(int argc, char** argv)
if (!from_file) if (!from_file)
{ {
spot::ltl::parse_error_list pel; spot::ltl::parse_error_list pel;
tm.start("parsing formula");
f = spot::ltl::parse(input, pel, env, debug_opt); f = spot::ltl::parse(input, pel, env, debug_opt);
tm.stop("parsing formula");
exit_code = spot::ltl::format_parse_errors(std::cerr, input, pel); exit_code = spot::ltl::format_parse_errors(std::cerr, input, pel);
} }
if (f || from_file) if (f || from_file)
@ -562,8 +575,10 @@ main(int argc, char** argv)
{ {
spot::tgba_parse_error_list pel; spot::tgba_parse_error_list pel;
spot::tgba_explicit* e; spot::tgba_explicit* e;
tm.start("parsing automaton");
to_free = a = e = spot::tgba_parse(input, pel, dict, to_free = a = e = spot::tgba_parse(input, pel, dict,
env, env, debug_opt); env, env, debug_opt);
tm.stop("parsing automaton");
if (spot::format_tgba_parse_errors(std::cerr, input, pel)) if (spot::format_tgba_parse_errors(std::cerr, input, pel))
{ {
delete to_free; delete to_free;
@ -576,13 +591,16 @@ main(int argc, char** argv)
{ {
if (redopt != spot::ltl::Reduce_None) if (redopt != spot::ltl::Reduce_None)
{ {
tm.start("reducing formula");
spot::ltl::formula* t = spot::ltl::reduce(f, redopt); spot::ltl::formula* t = spot::ltl::reduce(f, redopt);
f->destroy(); f->destroy();
tm.stop("reducing formula");
f = t; f = t;
if (display_reduce_form) if (display_reduce_form)
std::cout << spot::ltl::to_string(f) << std::endl; std::cout << spot::ltl::to_string(f) << std::endl;
} }
tm.start("translating formula");
if (fm_opt) if (fm_opt)
to_free = a = spot::ltl_to_tgba_fm(f, dict, fm_exprop_opt, to_free = a = spot::ltl_to_tgba_fm(f, dict, fm_exprop_opt,
fm_symb_merge_opt, fm_symb_merge_opt,
@ -594,6 +612,7 @@ main(int argc, char** argv)
to_free = a = spot::ltl_to_taa(f, dict, containment); to_free = a = spot::ltl_to_taa(f, dict, containment);
else else
to_free = a = concrete = spot::ltl_to_tgba_lacim(f, dict); to_free = a = concrete = spot::ltl_to_tgba_lacim(f, dict);
tm.stop("translating formula");
} }
spot::tgba_tba_proxy* degeneralized = 0; spot::tgba_tba_proxy* degeneralized = 0;
@ -617,6 +636,7 @@ main(int argc, char** argv)
spot::tgba_reduc* aut_red = 0; spot::tgba_reduc* aut_red = 0;
if (reduc_aut != spot::Reduce_None) if (reduc_aut != spot::Reduce_None)
{ {
tm.start("reducing formula automaton");
a = aut_red = new spot::tgba_reduc(a); a = aut_red = new spot::tgba_reduc(a);
if (reduc_aut & spot::Reduce_Scc) if (reduc_aut & spot::Reduce_Scc)
@ -671,6 +691,7 @@ main(int argc, char** argv)
if (rel_del) if (rel_del)
spot::free_relation_simulation(rel_del); spot::free_relation_simulation(rel_del);
} }
tm.stop("reducing formula automaton");
} }
spot::tgba_explicit* expl = 0; spot::tgba_explicit* expl = 0;
@ -729,11 +750,11 @@ main(int argc, char** argv)
a = new spot::future_conditions_collector(a, true); a = new spot::future_conditions_collector(a, true);
} }
if (output != -1)
{
tm.start("producing output");
switch (output) switch (output)
{ {
case -1:
/* No output. */
break;
case 0: case 0:
spot::dotty_reachable(std::cout, a); spot::dotty_reachable(std::cout, a);
break; break;
@ -789,6 +810,8 @@ main(int argc, char** argv)
default: default:
assert(!"unknown output option"); assert(!"unknown output option");
} }
tm.stop("producing output");
}
if (echeck_inst) if (echeck_inst)
{ {
@ -797,7 +820,10 @@ main(int argc, char** argv)
assert(ec); assert(ec);
do do
{ {
tm.start("running emptiness check");
spot::emptiness_check_result* res = ec->check(); spot::emptiness_check_result* res = ec->check();
tm.stop("running emptiness check");
if (paper_opt) if (paper_opt)
{ {
std::ios::fmtflags old = std::cout.flags(); std::ios::fmtflags old = std::cout.flags();
@ -856,7 +882,10 @@ main(int argc, char** argv)
else else
{ {
tm.start("computing accepting run");
spot::tgba_run* run = res->accepting_run(); spot::tgba_run* run = res->accepting_run();
tm.stop("computing accepting run");
if (!run) if (!run)
{ {
std::cout << "an accepting run exists" << std::endl; std::cout << "an accepting run exists" << std::endl;
@ -865,11 +894,14 @@ main(int argc, char** argv)
{ {
if (opt_reduce) if (opt_reduce)
{ {
tm.start("reducing accepting run");
spot::tgba_run* redrun = spot::tgba_run* redrun =
spot::reduce_run(res->automaton(), run); spot::reduce_run(res->automaton(), run);
tm.stop("reducing accepting run");
delete run; delete run;
run = redrun; run = redrun;
} }
tm.start("printing accepting run");
if (graph_run_opt) if (graph_run_opt)
{ {
spot::tgba_run_dotty_decorator deco(run); spot::tgba_run_dotty_decorator deco(run);
@ -889,6 +921,7 @@ main(int argc, char** argv)
exit_code = 1; exit_code = 1;
} }
delete run; delete run;
tm.stop("printing accepting run");
} }
} }
} }
@ -917,6 +950,9 @@ main(int argc, char** argv)
exit_code = 1; exit_code = 1;
} }
if (use_timer)
tm.print(std::cout);
if (unobservables) if (unobservables)
{ {
for (spot::ltl::atomic_prop_set::iterator i = for (spot::ltl::atomic_prop_set::iterator i =