X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/blobdiff_plain/ffea735548f5d4940dae32d8071a2676f6716ad0..97a4b4dbf628a627e3c2d5689be89265f56074df:/process.cpp?ds=inline diff --git a/process.cpp b/process.cpp index 1556f3c..214b9d0 100644 --- a/process.cpp +++ b/process.cpp @@ -1,5 +1,3 @@ -#include "process.h" - #include #include #include @@ -8,10 +6,13 @@ #include #include #include + +XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(proc); + #include "misc.h" #include "options.h" -XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(proc); +#include "process.h" double process::total_load_init = 0.0; double process::total_load_exit = 0.0; @@ -55,7 +56,7 @@ process::process(int argc, char* argv[]) oss << neigh.back().get_name(); } LOG1(logp, "Got %s.", oss.str().c_str()); - print_loads(logp); + print_loads(true, logp); } process::~process() @@ -82,7 +83,7 @@ int process::run() INFO2("(%u) current load: %g", iter, load); } - print_loads(xbt_log_priority_debug); + print_loads(true, xbt_log_priority_debug); if (opt::bookkeeping) expected_load -= load_balance(expected_load); @@ -281,23 +282,31 @@ void process::finalize() comm.flush(true); } -void process::print_loads(e_xbt_log_priority_t logp) +#define print_loads_generic(vec, verbose, logp, cat) \ + if (_XBT_LOG_ISENABLEDV((*cat), logp)) { \ + using namespace std::tr1; \ + using namespace std::tr1::placeholders; \ + XCLOG0(cat, logp, "Neighbor loads:"); \ + std::for_each(vec.begin(), vec.end(), \ + bind(&neighbor::print, _1, verbose, logp, cat)); \ + } else ((void)0) + +void process::print_loads(bool verbose, + e_xbt_log_priority_t logp, + xbt_log_category_t cat) const { - if (!LOG_ISENABLED(logp)) - return; + print_loads_generic(neigh, verbose, logp, cat); +} - std::ostringstream oss; - if (neigh.empty()) { - oss << "no neighbor!"; - } else { - std::transform(neigh.begin(), neigh.end() - 1, - std::ostream_iterator(oss, ", "), - std::tr1::mem_fn(&neighbor::get_load)); - oss << neigh.back().get_load(); - } - LOG1(logp, "Neighbor loads: %s", oss.str().c_str()); +void process::print_loads_p(bool verbose, + e_xbt_log_priority_t logp, + xbt_log_category_t cat) const +{ + print_loads_generic(pneigh, verbose, logp, cat); } +#undef print_loads_generic + // Local variables: // mode: c++ // End: