Ejemplo n.º 1
0
 void print_statistics(cmd_context& ctx) {
     if (m_params.get_bool(":print-statistics", false)) {
         statistics st;
         datalog::context& dlctx = m_dl_ctx->get_dl_context();
         unsigned long long max_mem = memory::get_max_used_memory();
         unsigned long long mem = memory::get_allocation_size();
         dlctx.collect_statistics(st);
         st.update("time", ctx.get_seconds());            
         st.update("memory", static_cast<double>(mem)/static_cast<double>(1024*1024));
         st.update("max-memory", static_cast<double>(max_mem)/static_cast<double>(1024*1024));
         st.display_smt2(ctx.regular_stream());            
     }
 }
Ejemplo n.º 2
0
 virtual void execute(cmd_context & ctx) {
     if (m_target == 0)
         throw cmd_exception("invalid simplify command, argument expected");
     expr_ref r(ctx.m());
     proof_ref pr(ctx.m());
     if (m_params.get_bool("som", false))
         m_params.set_bool("flat", true);
     th_rewriter s(ctx.m(), m_params);
     unsigned cache_sz;
     unsigned num_steps = 0;
     unsigned timeout   = m_params.get_uint("timeout", UINT_MAX);
     bool failed = false;
     cancel_eh<th_rewriter> eh(s);
     { 
         scoped_ctrl_c ctrlc(eh);
         scoped_timer timer(timeout, &eh);
         cmd_context::scoped_watch sw(ctx);
         try {
             s(m_target, r, pr);
         }
         catch (z3_error & ex) {
             throw ex;
         }
         catch (z3_exception & ex) {
             ctx.regular_stream() << "(error \"simplifier failed: " << ex.msg() << "\")" << std::endl;
             failed = true;
             r = m_target;
         }
         cache_sz  = s.get_cache_size();
         num_steps = s.get_num_steps();
         s.cleanup();
     }
     if (m_params.get_bool("print", true)) {
         ctx.display(ctx.regular_stream(), r);
         ctx.regular_stream() << std::endl; 
     }
     if (!failed && m_params.get_bool("print_proofs", false)) {
         ast_smt_pp pp(ctx.m());
         pp.set_logic(ctx.get_logic().str().c_str());
         pp.display_expr_smt2(ctx.regular_stream(), pr.get());
         ctx.regular_stream() << std::endl;
     }
     if (m_params.get_bool("print_statistics", false)) {
         shared_occs s1(ctx.m());
         if (!failed)
             s1(r);
         unsigned long long max_mem = memory::get_max_used_memory();
         unsigned long long mem = memory::get_allocation_size();
         ctx.regular_stream() << "(:time " << std::fixed << std::setprecision(2) << ctx.get_seconds() << " :num-steps " << num_steps
                              << " :memory " << std::fixed << std::setprecision(2) << static_cast<double>(mem)/static_cast<double>(1024*1024)
                              << " :max-memory " << std::fixed << std::setprecision(2) << static_cast<double>(max_mem)/static_cast<double>(1024*1024)
                              << " :cache-size: " << cache_sz
                              << " :num-nodes-before " << get_num_exprs(m_target);
         if (!failed)
             ctx.regular_stream() << " :num-shared " << s1.num_shared() << " :num-nodes " << get_num_exprs(r);
         ctx.regular_stream() << ")" << std::endl;
     }
 }