46 TrackSpace(
"track-memory",
cl::desc(
"Enable -time-passes memory "
47 "tracking (this may be slow)"),
52 cl::desc(
"File to append -stats and -timer output to"),
59 if (OutputFilename.empty())
61 if (OutputFilename ==
"-")
74 errs() <<
"Error opening info-output-file '"
75 << OutputFilename <<
" for appending!\n";
90 tmp =
new TimerGroup(
"Miscellaneous Ungrouped Timers");
104 assert(TG == 0 &&
"Timer already initialized");
112 assert(TG == 0 &&
"Timer already initialized");
121 TG->removeTimer(*
this);
125 if (!TrackSpace)
return 0;
141 Result.WallTime = now.seconds() + now.microseconds() / 1000000.0;
142 Result.UserTime = user.seconds() + user.microseconds() / 1000000.0;
161 std::vector<Timer*>::iterator
I =
163 assert(I !=
ActiveTimers->end() &&
"stop but no startTimer?");
172 OS <<
format(
" %7.4f (%5.1f%%)", Val, Val*100/Total);
203 for (
StringMap<std::pair<TimerGroup*, Name2TimerMap> >::iterator
204 I = Map.begin(), E = Map.end();
I != E; ++
I)
205 delete I->second.first;
211 std::pair<TimerGroup*, Name2TimerMap> &GroupEntry = Map[GroupName];
213 if (!GroupEntry.first)
268 while (FirstTimer != 0)
269 removeTimer(*FirstTimer);
279 void TimerGroup::removeTimer(
Timer &
T) {
284 TimersToPrint.push_back(std::make_pair(T.Time, T.Name));
291 T.Next->Prev = T.Prev;
295 if (FirstTimer != 0 || TimersToPrint.empty())
299 PrintQueuedTimers(*OutStream);
303 void TimerGroup::addTimer(
Timer &T) {
308 FirstTimer->Prev = &T.Next;
310 T.Prev = &FirstTimer;
314 void TimerGroup::PrintQueuedTimers(
raw_ostream &OS) {
316 std::sort(TimersToPrint.begin(), TimersToPrint.end());
319 for (
unsigned i = 0, e = TimersToPrint.size(); i != e; ++i)
320 Total += TimersToPrint[i].first;
323 OS <<
"===" << std::string(73,
'-') <<
"===\n";
325 unsigned Padding = (80-Name.length())/2;
326 if (Padding > 80) Padding = 0;
327 OS.
indent(Padding) << Name <<
'\n';
328 OS <<
"===" << std::string(73,
'-') <<
"===\n";
334 OS <<
format(
" Total Execution Time: %5.4f seconds (%5.4f wall clock)\n",
335 Total.getProcessTime(), Total.getWallTime());
338 if (Total.getUserTime())
339 OS <<
" ---User Time---";
340 if (Total.getSystemTime())
341 OS <<
" --System Time--";
342 if (Total.getProcessTime())
343 OS <<
" --User+System--";
344 OS <<
" ---Wall Time---";
345 if (Total.getMemUsed())
347 OS <<
" --- Name ---\n";
350 for (
unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) {
351 const std::pair<TimeRecord, std::string> &Entry = TimersToPrint[e-i-1];
352 Entry.first.print(Total, OS);
353 OS << Entry.second <<
'\n';
356 Total.print(Total, OS);
360 TimersToPrint.clear();
369 for (
Timer *T = FirstTimer;
T; T = T->Next) {
370 if (!T->Started)
continue;
371 TimersToPrint.push_back(std::make_pair(T->Time, T->Name));
379 if (!TimersToPrint.empty())
380 PrintQueuedTimers(OS);
bool isInitialized() const
const_iterator end(StringRef path)
Get end iterator over path.
void print(const TimeRecord &Total, raw_ostream &OS) const
void llvm_acquire_global_lock()
static TimeRecord getCurrentTime(bool Start=true)
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
const_iterator begin(StringRef path)
Get begin iterator over path.
void llvm_release_global_lock()
NamedRegionTimer(StringRef Name, bool Enabled=true)
SecondsType seconds() const
Retrieve the seconds component.
double getProcessTime() const
static cl::opt< bool > Enabled("stats", cl::desc("Enable statistics output from program (available with Asserts)"))
double getWallTime() const
format_object1< T > format(const char *Fmt, const T &Val)
static ManagedStatic< Name2TimerMap > NamedTimers
double getUserTime() const
static void printVal(double Val, double Total, raw_ostream &OS)
static TimerGroup * DefaultTimerGroup
static TimerGroup * TimerGroupList
static void GetTimeUsage(TimeValue &elapsed, TimeValue &user_time, TimeValue &sys_time)
ssize_t getMemUsed() const
static ManagedStatic< std::string > LibSupportInfoOutputFilename
static ManagedStatic< Name2PairMap > NamedGroupedTimers
static ManagedStatic< std::vector< Timer * > > ActiveTimers
static size_t GetMallocUsage()
Return process memory usage. This static function will return the total amount of memory allocated by...
void print(raw_ostream &OS)
print - Print any started timers in this group and zero them.
static TimerGroup * getDefaultTimerGroup()
double getSystemTime() const
static std::string & getLibSupportInfoOutputFilename()
raw_ostream * CreateInfoOutputFile()
Provides an abstraction for a fixed point in time.
static void printAll(raw_ostream &OS)
printAll - This static method prints all timers and clears them all out.
static size_t getMemUsage()
uint32_t microseconds() const
Retrieve the fractional part as microseconds;.
static Timer & getNamedRegionTimer(StringRef Name)
LocationClass< Ty > location(Ty &L)
static ManagedStatic< sys::SmartMutex< true > > TimerLock