45 cl::desc(
"Enable statistics output from program (available with Asserts)"));
53 std::vector<const Statistic*>
Stats;
88 StatisticInfo::~StatisticInfo() {
104 unsigned MaxNameLen = 0, MaxValLen = 0;
105 for (
size_t i = 0, e = Stats.Stats.size(); i != e; ++i) {
106 MaxValLen = std::max(MaxValLen,
107 (
unsigned)
utostr(Stats.Stats[i]->getValue()).
size());
108 MaxNameLen = std::max(MaxNameLen,
109 (
unsigned)std::strlen(Stats.Stats[i]->getName()));
113 std::stable_sort(Stats.Stats.begin(), Stats.Stats.end(),
115 if (
int Cmp = std::strcmp(LHS->
getName(), RHS->getName()))
119 return std::strcmp(LHS->
getDesc(), RHS->getDesc()) < 0;
123 OS <<
"===" << std::string(73,
'-') <<
"===\n"
124 <<
" ... Statistics Collected ...\n"
125 <<
"===" << std::string(73,
'-') <<
"===\n\n";
128 for (
size_t i = 0, e = Stats.Stats.size(); i != e; ++i)
129 OS <<
format(
"%*u %-*s - %s\n",
130 MaxValLen, Stats.Stats[i]->getValue(),
131 MaxNameLen, Stats.Stats[i]->getName(),
132 Stats.Stats[i]->getDesc());
140 #if !defined(NDEBUG) || defined(LLVM_ENABLE_STATS)
144 if (Stats.Stats.empty())
return;
157 OutStream <<
"Statistics are disabled. "
158 <<
"Build with asserts or with -DLLVM_ENABLE_STATS\n";
void RegisterStatistic()
RegisterStatistic - The first time a statistic is bumped, this method is called.
#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)"))
-stats - Command line option to cause transformations to emit stats about what they did...
void EnableStatistics()
Enable the collection and printing of statistics.
static ManagedStatic< StatisticInfo > StatInfo
static std::string utostr(uint64_t X, bool isNeg=false)
format_object< Ts...> format(const char *Fmt, const Ts &...Vals)
These are helper functions used to produce formatted output.
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().
This class implements an extremely fast bulk output stream that can only output to a stream...
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
static ManagedStatic< sys::SmartMutex< true > > StatLock
bool AreStatisticsEnabled()
Check if statistics are enabled.