45 cl::desc(
"Enable statistics output from program (available with Asserts)"));
53 std::vector<const Statistic*>
Stats;
92 if (Cmp != 0)
return Cmp < 0;
102 StatisticInfo::~StatisticInfo() {
118 unsigned MaxNameLen = 0, MaxValLen = 0;
119 for (
size_t i = 0, e = Stats.Stats.size(); i != e; ++i) {
120 MaxValLen = std::max(MaxValLen,
121 (
unsigned)
utostr(Stats.Stats[i]->getValue()).size());
122 MaxNameLen = std::max(MaxNameLen,
127 std::stable_sort(Stats.Stats.begin(), Stats.Stats.end(), NameCompare());
130 OS <<
"===" << std::string(73,
'-') <<
"===\n"
131 <<
" ... Statistics Collected ...\n"
132 <<
"===" << std::string(73,
'-') <<
"===\n\n";
135 for (
size_t i = 0, e = Stats.Stats.size(); i != e; ++i)
136 OS <<
format(
"%*u %-*s - %s\n",
137 MaxValLen, Stats.Stats[i]->getValue(),
138 MaxNameLen, Stats.Stats[i]->getName(),
139 Stats.Stats[i]->getDesc());
147 #if !defined(NDEBUG) || defined(LLVM_ENABLE_STATS)
151 if (Stats.Stats.empty())
return;
164 OutStream <<
"Statistics are disabled. "
165 <<
"Build with asserts or with -DLLVM_ENABLE_STATS\n";
int strcmp(const char *s1, const char *s2);
#define TsanHappensBefore(cv)
block placement Basic Block Placement Stats
static cl::opt< bool > Enabled("stats", cl::desc("Enable statistics output from program (available with Asserts)"))
format_object1< T > format(const char *Fmt, const T &Val)
void EnableStatistics()
Enable the collection and printing of statistics.
static ManagedStatic< StatisticInfo > StatInfo
static std::string utostr(uint64_t X, bool isNeg=false)
size_t strlen(const char *s);
const char * getDesc() const
#define TsanIgnoreWritesEnd()
const char * getName() const
raw_ostream * CreateInfoOutputFile()
#define TsanIgnoreWritesBegin()
void PrintStatistics()
Print statistics to the file returned by CreateInfoOutputFile().
static ManagedStatic< sys::SmartMutex< true > > StatLock
bool AreStatisticsEnabled()
Check if statistics are enabled.