Internals: Compact stage statistics table

This commit is contained in:
Geza Lore 2026-06-21 23:23:52 +01:00
parent eafe9636cf
commit fed922a538
2 changed files with 9 additions and 6 deletions

View File

@ -41,6 +41,7 @@ class StatsVisitor final : public VNVisitorConst {
// STATE
const bool m_fastOnly; // When true, consider only fast functions
bool m_empty = true; // Netlist is empty
Counters m_counters; // The actual counts we will display
Counters m_dumpster; // Alternate buffer to make discarding parts of the tree easier
Counters* m_accump; // The currently active accumulator
@ -51,6 +52,7 @@ class StatsVisitor final : public VNVisitorConst {
// METHODS
void countThenIterateChildren(AstNode* nodep) {
++m_accump->m_statTypeCount[nodep->type()];
if (nodep->type() != VNType::Netlist) m_empty = false;
iterateChildrenConst(nodep);
}
@ -93,6 +95,7 @@ public:
, m_accump{fastOnly ? &m_dumpster : &m_counters} {
UINFO(9, "Starting stats, fastOnly=" << fastOnly);
iterateConst(nodep);
if (m_empty) return;
// Shorthand
const auto addStat = [&](const std::string& name, double count, unsigned precision = 0) {
@ -127,13 +130,13 @@ public:
addStat("Node count, " + typeName(t), count);
}
}
addStat("Node memory TOTAL (MiB)", totalNodeMemoryUsage >> 20);
addStat("Node mem TOTAL (MiB)", totalNodeMemoryUsage >> 20);
// Node Memory usage
for (size_t t = 0; t < VNType::NUM_TYPES(); ++t) {
if (const uint64_t count = m_counters.m_statTypeCount[t]) {
const double share = 100.0 * count * typeSize(t) / totalNodeMemoryUsage;
addStat("Node memory share (%), " + typeName(t), share, 2);
addStat("Node mem %, " + typeName(t), share, 2);
}
}

View File

@ -119,11 +119,11 @@ class StatsReport final {
// Header
os << " Stat " << std::left << std::setw(maxWidth - 5 - 2) << "";
for (const string& i : stages) os << " " << std::left << std::setw(9) << i;
for (const string& i : stages) os << " " << std::left << std::setw(9) << i;
os << '\n';
os << " -------- " << std::left << std::setw(maxWidth - 5 - 2) << "";
for (auto it = stages.begin(); it != stages.end(); ++it) {
os << " " << std::left << std::setw(9) << "-------";
os << " " << std::left << std::setw(9) << "-------";
}
// os<<endl;
@ -149,7 +149,7 @@ class StatsReport final {
os << " " << std::left << std::setw(maxWidth) << repp->name();
}
while (col < stages.size() && stages.at(col) != repp->stage()) {
os << std::setw(11) << "";
os << std::setw(10) << "";
col++;
}
repp->dump(os);
@ -191,7 +191,7 @@ StatsReport::StatColl StatsReport::s_allStats;
// V3Statstic class
void V3Statistic::dump(std::ofstream& os) const {
os << " " << std::right << std::fixed << std::setprecision(precision()) << std::setw(9)
os << " " << std::right << std::fixed << std::setprecision(precision()) << std::setw(9)
<< value();
}