Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1 | //===-- Timer.cpp - Interval Timing Support -------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 081ce94 | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // Interval Timing implementation. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "llvm/Support/Timer.h" |
| 15 | #include "llvm/Support/CommandLine.h" |
Chris Lattner | 7597f69 | 2010-03-29 21:28:41 +0000 | [diff] [blame] | 16 | #include "llvm/Support/Debug.h" |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 17 | #include "llvm/Support/ManagedStatic.h" |
Chris Lattner | 5febcae | 2009-08-23 08:43:55 +0000 | [diff] [blame] | 18 | #include "llvm/Support/raw_ostream.h" |
| 19 | #include "llvm/Support/Format.h" |
Chris Lattner | 7597f69 | 2010-03-29 21:28:41 +0000 | [diff] [blame] | 20 | #include "llvm/System/Mutex.h" |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 21 | #include "llvm/System/Process.h" |
Chris Lattner | 0203994 | 2010-03-30 04:03:22 +0000 | [diff] [blame] | 22 | #include "llvm/ADT/StringMap.h" |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 23 | using namespace llvm; |
| 24 | |
| 25 | // GetLibSupportInfoOutputFile - Return a file stream to print our output on. |
Chris Lattner | 5febcae | 2009-08-23 08:43:55 +0000 | [diff] [blame] | 26 | namespace llvm { extern raw_ostream *GetLibSupportInfoOutputFile(); } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 27 | |
| 28 | // getLibSupportInfoOutputFilename - This ugly hack is brought to you courtesy |
| 29 | // of constructor/destructor ordering being unspecified by C++. Basically the |
| 30 | // problem is that a Statistic object gets destroyed, which ends up calling |
| 31 | // 'GetLibSupportInfoOutputFile()' (below), which calls this function. |
| 32 | // LibSupportInfoOutputFilename used to be a global variable, but sometimes it |
| 33 | // would get destroyed before the Statistic, causing havoc to ensue. We "fix" |
| 34 | // this by creating the string the first time it is needed and never destroying |
| 35 | // it. |
| 36 | static ManagedStatic<std::string> LibSupportInfoOutputFilename; |
| 37 | static std::string &getLibSupportInfoOutputFilename() { |
| 38 | return *LibSupportInfoOutputFilename; |
| 39 | } |
| 40 | |
Owen Anderson | 1846310 | 2009-06-23 20:52:29 +0000 | [diff] [blame] | 41 | static ManagedStatic<sys::SmartMutex<true> > TimerLock; |
| 42 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 43 | namespace { |
Dan Gohman | bbe6922 | 2008-04-23 23:15:23 +0000 | [diff] [blame] | 44 | static cl::opt<bool> |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 45 | TrackSpace("track-memory", cl::desc("Enable -time-passes memory " |
| 46 | "tracking (this may be slow)"), |
| 47 | cl::Hidden); |
| 48 | |
Dan Gohman | bbe6922 | 2008-04-23 23:15:23 +0000 | [diff] [blame] | 49 | static cl::opt<std::string, true> |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 50 | InfoOutputFilename("info-output-file", cl::value_desc("filename"), |
| 51 | cl::desc("File to append -stats and -timer output to"), |
| 52 | cl::Hidden, cl::location(getLibSupportInfoOutputFilename())); |
| 53 | } |
| 54 | |
Chris Lattner | 7641c7b | 2010-03-29 21:34:06 +0000 | [diff] [blame] | 55 | // GetLibSupportInfoOutputFile - Return a file stream to print our output on. |
| 56 | raw_ostream *llvm::GetLibSupportInfoOutputFile() { |
| 57 | std::string &LibSupportInfoOutputFilename = getLibSupportInfoOutputFilename(); |
| 58 | if (LibSupportInfoOutputFilename.empty()) |
| 59 | return &errs(); |
| 60 | if (LibSupportInfoOutputFilename == "-") |
| 61 | return &outs(); |
| 62 | |
| 63 | std::string Error; |
| 64 | raw_ostream *Result = new raw_fd_ostream(LibSupportInfoOutputFilename.c_str(), |
| 65 | Error, raw_fd_ostream::F_Append); |
| 66 | if (Error.empty()) |
| 67 | return Result; |
| 68 | |
| 69 | errs() << "Error opening info-output-file '" |
| 70 | << LibSupportInfoOutputFilename << " for appending!\n"; |
| 71 | delete Result; |
| 72 | return &errs(); |
| 73 | } |
| 74 | |
| 75 | |
Owen Anderson | 56ddb83 | 2009-06-23 16:36:10 +0000 | [diff] [blame] | 76 | static TimerGroup *DefaultTimerGroup = 0; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 77 | static TimerGroup *getDefaultTimerGroup() { |
Chris Lattner | c354685 | 2010-03-29 20:35:01 +0000 | [diff] [blame] | 78 | TimerGroup *tmp = DefaultTimerGroup; |
Owen Anderson | 1b2ea53 | 2009-06-23 17:33:37 +0000 | [diff] [blame] | 79 | sys::MemoryFence(); |
Chris Lattner | c354685 | 2010-03-29 20:35:01 +0000 | [diff] [blame] | 80 | if (tmp) return tmp; |
| 81 | |
| 82 | llvm_acquire_global_lock(); |
| 83 | tmp = DefaultTimerGroup; |
Owen Anderson | 1b2ea53 | 2009-06-23 17:33:37 +0000 | [diff] [blame] | 84 | if (!tmp) { |
Chris Lattner | c354685 | 2010-03-29 20:35:01 +0000 | [diff] [blame] | 85 | tmp = new TimerGroup("Miscellaneous Ungrouped Timers"); |
| 86 | sys::MemoryFence(); |
| 87 | DefaultTimerGroup = tmp; |
Owen Anderson | 1b2ea53 | 2009-06-23 17:33:37 +0000 | [diff] [blame] | 88 | } |
Chris Lattner | c354685 | 2010-03-29 20:35:01 +0000 | [diff] [blame] | 89 | llvm_release_global_lock(); |
Mikhail Glushenkov | 05858c5 | 2009-11-07 06:33:12 +0000 | [diff] [blame] | 90 | |
Owen Anderson | 1b2ea53 | 2009-06-23 17:33:37 +0000 | [diff] [blame] | 91 | return tmp; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 92 | } |
| 93 | |
Chris Lattner | c354685 | 2010-03-29 20:35:01 +0000 | [diff] [blame] | 94 | //===----------------------------------------------------------------------===// |
| 95 | // Timer Implementation |
| 96 | //===----------------------------------------------------------------------===// |
| 97 | |
Chris Lattner | 0203994 | 2010-03-30 04:03:22 +0000 | [diff] [blame] | 98 | void Timer::init(const std::string &N) { |
| 99 | assert(TG == 0 && "Timer already initialized"); |
| 100 | Name = N; |
| 101 | Started = false; |
| 102 | TG = getDefaultTimerGroup(); |
Chris Lattner | 9d55611 | 2010-03-30 04:40:01 +0000 | [diff] [blame^] | 103 | TG->addTimer(*this); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 104 | } |
| 105 | |
Chris Lattner | 0203994 | 2010-03-30 04:03:22 +0000 | [diff] [blame] | 106 | void Timer::init(const std::string &N, TimerGroup &tg) { |
| 107 | assert(TG == 0 && "Timer already initialized"); |
| 108 | Name = N; |
| 109 | Started = false; |
| 110 | TG = &tg; |
Chris Lattner | 9d55611 | 2010-03-30 04:40:01 +0000 | [diff] [blame^] | 111 | TG->addTimer(*this); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 112 | } |
| 113 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 114 | Timer::~Timer() { |
Chris Lattner | 0203994 | 2010-03-30 04:03:22 +0000 | [diff] [blame] | 115 | if (!TG) return; // Never initialized. |
Chris Lattner | 9d55611 | 2010-03-30 04:40:01 +0000 | [diff] [blame^] | 116 | TG->removeTimer(*this); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | static inline size_t getMemUsage() { |
| 120 | if (TrackSpace) |
| 121 | return sys::Process::GetMallocUsage(); |
| 122 | return 0; |
| 123 | } |
| 124 | |
Chris Lattner | 0203994 | 2010-03-30 04:03:22 +0000 | [diff] [blame] | 125 | TimeRecord TimeRecord::getCurrentTime(bool Start) { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 126 | TimeRecord Result; |
| 127 | |
| 128 | sys::TimeValue now(0,0); |
| 129 | sys::TimeValue user(0,0); |
| 130 | sys::TimeValue sys(0,0); |
| 131 | |
Owen Anderson | ac637c6 | 2009-06-23 20:17:22 +0000 | [diff] [blame] | 132 | ssize_t MemUsed = 0; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 133 | if (Start) { |
| 134 | MemUsed = getMemUsage(); |
Chris Lattner | c354685 | 2010-03-29 20:35:01 +0000 | [diff] [blame] | 135 | sys::Process::GetTimeUsage(now, user, sys); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 136 | } else { |
Chris Lattner | c354685 | 2010-03-29 20:35:01 +0000 | [diff] [blame] | 137 | sys::Process::GetTimeUsage(now, user, sys); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 138 | MemUsed = getMemUsage(); |
| 139 | } |
| 140 | |
Chris Lattner | 0203994 | 2010-03-30 04:03:22 +0000 | [diff] [blame] | 141 | Result.WallTime = now.seconds() + now.microseconds() / 1000000.0; |
Chris Lattner | c354685 | 2010-03-29 20:35:01 +0000 | [diff] [blame] | 142 | Result.UserTime = user.seconds() + user.microseconds() / 1000000.0; |
Chris Lattner | 0203994 | 2010-03-30 04:03:22 +0000 | [diff] [blame] | 143 | Result.SystemTime = sys.seconds() + sys.microseconds() / 1000000.0; |
Chris Lattner | c354685 | 2010-03-29 20:35:01 +0000 | [diff] [blame] | 144 | Result.MemUsed = MemUsed; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 145 | return Result; |
| 146 | } |
| 147 | |
| 148 | static ManagedStatic<std::vector<Timer*> > ActiveTimers; |
| 149 | |
| 150 | void Timer::startTimer() { |
| 151 | Started = true; |
Dan Gohman | f6930f9 | 2008-06-24 22:07:07 +0000 | [diff] [blame] | 152 | ActiveTimers->push_back(this); |
Chris Lattner | 0203994 | 2010-03-30 04:03:22 +0000 | [diff] [blame] | 153 | Time -= TimeRecord::getCurrentTime(true); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | void Timer::stopTimer() { |
Chris Lattner | 0203994 | 2010-03-30 04:03:22 +0000 | [diff] [blame] | 157 | Time += TimeRecord::getCurrentTime(false); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 158 | |
| 159 | if (ActiveTimers->back() == this) { |
| 160 | ActiveTimers->pop_back(); |
| 161 | } else { |
| 162 | std::vector<Timer*>::iterator I = |
| 163 | std::find(ActiveTimers->begin(), ActiveTimers->end(), this); |
| 164 | assert(I != ActiveTimers->end() && "stop but no startTimer?"); |
| 165 | ActiveTimers->erase(I); |
| 166 | } |
| 167 | } |
| 168 | |
Chris Lattner | c354685 | 2010-03-29 20:35:01 +0000 | [diff] [blame] | 169 | static void printVal(double Val, double Total, raw_ostream &OS) { |
Chris Lattner | 626ca12 | 2010-03-29 20:40:19 +0000 | [diff] [blame] | 170 | if (Total < 1e-7) // Avoid dividing by zero. |
Chris Lattner | c354685 | 2010-03-29 20:35:01 +0000 | [diff] [blame] | 171 | OS << " ----- "; |
| 172 | else { |
| 173 | OS << " " << format("%7.4f", Val) << " ("; |
| 174 | OS << format("%5.1f", Val*100/Total) << "%)"; |
| 175 | } |
| 176 | } |
| 177 | |
Chris Lattner | 0203994 | 2010-03-30 04:03:22 +0000 | [diff] [blame] | 178 | void TimeRecord::print(const TimeRecord &Total, raw_ostream &OS) const { |
| 179 | if (Total.getUserTime()) |
| 180 | printVal(getUserTime(), Total.getUserTime(), OS); |
| 181 | if (Total.getSystemTime()) |
| 182 | printVal(getSystemTime(), Total.getSystemTime(), OS); |
Chris Lattner | c354685 | 2010-03-29 20:35:01 +0000 | [diff] [blame] | 183 | if (Total.getProcessTime()) |
| 184 | printVal(getProcessTime(), Total.getProcessTime(), OS); |
Chris Lattner | 0203994 | 2010-03-30 04:03:22 +0000 | [diff] [blame] | 185 | printVal(getWallTime(), Total.getWallTime(), OS); |
Chris Lattner | c354685 | 2010-03-29 20:35:01 +0000 | [diff] [blame] | 186 | |
| 187 | OS << " "; |
| 188 | |
Chris Lattner | 0203994 | 2010-03-30 04:03:22 +0000 | [diff] [blame] | 189 | if (Total.getMemUsed()) |
| 190 | OS << format("%9lld", (long long)getMemUsed()) << " "; |
Chris Lattner | c354685 | 2010-03-29 20:35:01 +0000 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 194 | //===----------------------------------------------------------------------===// |
| 195 | // NamedRegionTimer Implementation |
| 196 | //===----------------------------------------------------------------------===// |
| 197 | |
Chris Lattner | 0203994 | 2010-03-30 04:03:22 +0000 | [diff] [blame] | 198 | typedef StringMap<Timer> Name2TimerMap; |
| 199 | typedef StringMap<std::pair<TimerGroup, Name2TimerMap> > Name2PairMap; |
Dan Gohman | 368a08b | 2008-07-14 18:19:29 +0000 | [diff] [blame] | 200 | |
Chris Lattner | 0203994 | 2010-03-30 04:03:22 +0000 | [diff] [blame] | 201 | static ManagedStatic<Name2TimerMap> NamedTimers; |
| 202 | static ManagedStatic<Name2PairMap> NamedGroupedTimers; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 203 | |
| 204 | static Timer &getNamedRegionTimer(const std::string &Name) { |
Owen Anderson | be44bed | 2009-07-07 18:33:04 +0000 | [diff] [blame] | 205 | sys::SmartScopedLock<true> L(*TimerLock); |
Chris Lattner | 0203994 | 2010-03-30 04:03:22 +0000 | [diff] [blame] | 206 | |
| 207 | Timer &T = (*NamedTimers)[Name]; |
| 208 | if (!T.isInitialized()) |
| 209 | T.init(Name); |
| 210 | return T; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 211 | } |
| 212 | |
Dan Gohman | 368a08b | 2008-07-14 18:19:29 +0000 | [diff] [blame] | 213 | static Timer &getNamedRegionTimer(const std::string &Name, |
| 214 | const std::string &GroupName) { |
Owen Anderson | be44bed | 2009-07-07 18:33:04 +0000 | [diff] [blame] | 215 | sys::SmartScopedLock<true> L(*TimerLock); |
Dan Gohman | 368a08b | 2008-07-14 18:19:29 +0000 | [diff] [blame] | 216 | |
Chris Lattner | 0203994 | 2010-03-30 04:03:22 +0000 | [diff] [blame] | 217 | std::pair<TimerGroup, Name2TimerMap> &GroupEntry = |
| 218 | (*NamedGroupedTimers)[GroupName]; |
Dan Gohman | 368a08b | 2008-07-14 18:19:29 +0000 | [diff] [blame] | 219 | |
Chris Lattner | 0203994 | 2010-03-30 04:03:22 +0000 | [diff] [blame] | 220 | if (GroupEntry.second.empty()) |
| 221 | GroupEntry.first.setName(GroupName); |
Dan Gohman | 368a08b | 2008-07-14 18:19:29 +0000 | [diff] [blame] | 222 | |
Chris Lattner | 0203994 | 2010-03-30 04:03:22 +0000 | [diff] [blame] | 223 | Timer &T = GroupEntry.second[Name]; |
| 224 | if (!T.isInitialized()) |
| 225 | T.init(Name); |
| 226 | return T; |
Dan Gohman | 368a08b | 2008-07-14 18:19:29 +0000 | [diff] [blame] | 227 | } |
| 228 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 229 | NamedRegionTimer::NamedRegionTimer(const std::string &Name) |
| 230 | : TimeRegion(getNamedRegionTimer(Name)) {} |
| 231 | |
Dan Gohman | 368a08b | 2008-07-14 18:19:29 +0000 | [diff] [blame] | 232 | NamedRegionTimer::NamedRegionTimer(const std::string &Name, |
| 233 | const std::string &GroupName) |
| 234 | : TimeRegion(getNamedRegionTimer(Name, GroupName)) {} |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 235 | |
| 236 | //===----------------------------------------------------------------------===// |
| 237 | // TimerGroup Implementation |
| 238 | //===----------------------------------------------------------------------===// |
| 239 | |
Chris Lattner | 9d55611 | 2010-03-30 04:40:01 +0000 | [diff] [blame^] | 240 | void TimerGroup::removeTimer(Timer &T) { |
Owen Anderson | be44bed | 2009-07-07 18:33:04 +0000 | [diff] [blame] | 241 | sys::SmartScopedLock<true> L(*TimerLock); |
Chris Lattner | c354685 | 2010-03-29 20:35:01 +0000 | [diff] [blame] | 242 | |
Chris Lattner | 9d55611 | 2010-03-30 04:40:01 +0000 | [diff] [blame^] | 243 | // If the timer was started, move its data to TimersToPrint. |
| 244 | if (T.Started) { |
| 245 | T.Started = false; |
| 246 | TimersToPrint.push_back(std::make_pair(T.Time, T.Name)); |
| 247 | } |
| 248 | |
| 249 | // Unlink the timer from our list. |
| 250 | *T.Prev = T.Next; |
| 251 | if (T.Next) |
| 252 | T.Next->Prev = T.Prev; |
| 253 | |
| 254 | // Print the report when all timers in this group are destroyed if some of |
| 255 | // them were started. |
| 256 | if (FirstTimer != 0 || TimersToPrint.empty()) |
| 257 | return; |
| 258 | |
Chris Lattner | c354685 | 2010-03-29 20:35:01 +0000 | [diff] [blame] | 259 | raw_ostream *OutStream = GetLibSupportInfoOutputFile(); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 260 | |
Chris Lattner | 9d55611 | 2010-03-30 04:40:01 +0000 | [diff] [blame^] | 261 | PrintQueuedTimers(*OutStream); |
Chris Lattner | c354685 | 2010-03-29 20:35:01 +0000 | [diff] [blame] | 262 | |
Chris Lattner | 5f52edc | 2010-03-29 21:24:52 +0000 | [diff] [blame] | 263 | if (OutStream != &errs() && OutStream != &outs()) |
Chris Lattner | 626ca12 | 2010-03-29 20:40:19 +0000 | [diff] [blame] | 264 | delete OutStream; // Close the file. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 265 | } |
| 266 | |
Chris Lattner | 9d55611 | 2010-03-30 04:40:01 +0000 | [diff] [blame^] | 267 | void TimerGroup::addTimer(Timer &T) { |
Owen Anderson | be44bed | 2009-07-07 18:33:04 +0000 | [diff] [blame] | 268 | sys::SmartScopedLock<true> L(*TimerLock); |
Chris Lattner | 9d55611 | 2010-03-30 04:40:01 +0000 | [diff] [blame^] | 269 | |
| 270 | // Add the timer to our list. |
| 271 | if (FirstTimer) |
| 272 | FirstTimer->Prev = &T.Next; |
| 273 | T.Next = FirstTimer; |
| 274 | T.Prev = &FirstTimer; |
| 275 | FirstTimer = &T; |
Owen Anderson | 1846310 | 2009-06-23 20:52:29 +0000 | [diff] [blame] | 276 | } |
| 277 | |
Chris Lattner | 9d55611 | 2010-03-30 04:40:01 +0000 | [diff] [blame^] | 278 | void TimerGroup::PrintQueuedTimers(raw_ostream &OS) { |
| 279 | // Sort the timers in descending order by amount of time taken. |
| 280 | std::sort(TimersToPrint.begin(), TimersToPrint.end()); |
| 281 | |
| 282 | TimeRecord Total; |
| 283 | for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) |
| 284 | Total += TimersToPrint[i].first; |
| 285 | |
| 286 | // Print out timing header. |
| 287 | OS << "===" << std::string(73, '-') << "===\n"; |
| 288 | // Figure out how many spaces to indent TimerGroup name. |
| 289 | unsigned Padding = (80-Name.length())/2; |
| 290 | if (Padding > 80) Padding = 0; // Don't allow "negative" numbers |
| 291 | OS.indent(Padding) << Name << '\n'; |
| 292 | OS << "===" << std::string(73, '-') << "===\n"; |
| 293 | |
| 294 | // If this is not an collection of ungrouped times, print the total time. |
| 295 | // Ungrouped timers don't really make sense to add up. We still print the |
| 296 | // TOTAL line to make the percentages make sense. |
| 297 | if (this != DefaultTimerGroup) { |
| 298 | OS << " Total Execution Time: "; |
| 299 | OS << format("%5.4f", Total.getProcessTime()) << " seconds ("; |
| 300 | OS << format("%5.4f", Total.getWallTime()) << " wall clock)\n"; |
| 301 | } |
| 302 | OS << '\n'; |
| 303 | |
| 304 | if (Total.getUserTime()) |
| 305 | OS << " ---User Time---"; |
| 306 | if (Total.getSystemTime()) |
| 307 | OS << " --System Time--"; |
| 308 | if (Total.getProcessTime()) |
| 309 | OS << " --User+System--"; |
| 310 | OS << " ---Wall Time---"; |
| 311 | if (Total.getMemUsed()) |
| 312 | OS << " ---Mem---"; |
| 313 | OS << " --- Name ---\n"; |
| 314 | |
| 315 | // Loop through all of the timing data, printing it out. |
| 316 | for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) { |
| 317 | const std::pair<TimeRecord, std::string> &Entry = TimersToPrint[e-i-1]; |
| 318 | Entry.first.print(Total, OS); |
| 319 | OS << Entry.second << '\n'; |
| 320 | } |
| 321 | |
| 322 | Total.print(Total, OS); |
| 323 | OS << "Total\n\n"; |
| 324 | OS.flush(); |
| 325 | |
| 326 | TimersToPrint.clear(); |
Owen Anderson | 1846310 | 2009-06-23 20:52:29 +0000 | [diff] [blame] | 327 | } |
| 328 | |