split up BrushBSP and CountLeafs stat prints

This commit is contained in:
Jonathan 2022-08-21 21:54:16 -04:00
parent 4eebbd0bdd
commit e7ae158a10
2 changed files with 16 additions and 2 deletions

View File

@ -201,6 +201,7 @@ struct stat_tracker_t
};
std::list<stat> stats;
bool stats_printed = false;
inline stat &register_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

View File

@ -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");
}