diff --git a/include/common/log.hh b/include/common/log.hh index aef0c5ed..5b412d18 100644 --- a/include/common/log.hh +++ b/include/common/log.hh @@ -201,6 +201,7 @@ struct stat_tracker_t }; std::list stats; + bool stats_printed = false; inline stat ®ister_stat(const std::string &name, bool show_even_if_zero = false, bool is_warning = false) { @@ -230,8 +231,14 @@ struct stat_tracker_t return number_padding + ((number_padding - 1) / 3); } - ~stat_tracker_t() + void print_stats() { + if (stats_printed) { + return; + } + + stats_printed = true; + auto old = std::locale::global(std::locale("en_US.UTF-8")); // add 8 char padding just to keep it away from the left side size_t number_padding = number_of_digit_padding() + 4; @@ -243,5 +250,10 @@ struct stat_tracker_t } std::locale::global(old); } + + virtual ~stat_tracker_t() + { + print_stats(); + } }; }; // namespace logging \ No newline at end of file diff --git a/qbsp/brushbsp.cc b/qbsp/brushbsp.cc index 4f552734..b0e9b9fe 100644 --- a/qbsp/brushbsp.cc +++ b/qbsp/brushbsp.cc @@ -53,7 +53,7 @@ struct bspstats_t : logging::stat_tracker_t // total number of nodes, includes c_nonvis stat &c_nodes = register_stat("nodes"); // number of nodes created by splitting on a side_t which had !visible - stat &c_nonvis =register_stat("non-visible nodes"); + stat &c_nonvis = register_stat("non-visible nodes"); // total number of nodes created by qbsp3 method stat &c_qbsp3 = register_stat("expensive split nodes"); // total number of nodes created by midsplit @@ -1289,6 +1289,8 @@ void BrushBSP(tree_t &tree, mapentity_t &entity, const bspbrush_t::container &br BuildTree_r(tree, 0, tree.headnode, brushlist, split_type, stats, clock); } + stats.print_stats(); + logging::header("CountLeafs"); qbsp_options.target_game->print_content_stats(*stats.leafstats, "leafs"); }