Internals: Add some FileLine stats

This commit is contained in:
Wilson Snyder 2025-07-26 15:03:36 -04:00
parent 504884b7d5
commit 42e1c83875
3 changed files with 15 additions and 0 deletions

View File

@ -26,6 +26,7 @@
# include "V3Global.h"
# include "V3Control.h"
# include "V3File.h"
# include "V3Stats.h"
#endif
#include "V3Waiver.h"
// clang-format on
@ -551,6 +552,18 @@ void FileLine::operator delete(void* objp, size_t size) {
}
#endif
void FileLine::stats() {
#ifndef V3ERROR_NO_GLOBAL_
V3Stats::addStatSum("FileLines, Number of filenames",
singleton().m_names.size()); // Max m_filenameno
V3Stats::addStatSum("FileLines, Message enable sets",
singleton().m_internedMsgEns.size()); // Max m_msgEnIdx
// Don't currently have a good path to recording max line/column,
// Infrequently useful, alternatively we could keep globals we update as make each FileLine
// or could use fileLineLeakChecks.
#endif
}
void FileLine::deleteAllRemaining() {
#ifdef VL_LEAK_CHECKS
// FileLines are allocated, but never nicely freed, as it's much faster

View File

@ -213,6 +213,7 @@ public:
FileLine* copyOrSameFileLine();
FileLine* copyOrSameFileLineApplied();
static void deleteAllRemaining();
static void stats();
~FileLine();
#ifdef VL_LEAK_CHECKS
static void* operator new(size_t size);

View File

@ -119,6 +119,7 @@ V3Global v3Global;
static void reportStatsIfEnabled() {
if (v3Global.opt.stats()) {
FileLine::stats();
V3Stats::statsFinalAll(v3Global.rootp());
V3Stats::statsReport();
}