blob: 12b90324cd2e5ac0d039466bfd5af83c967332cc [file] [log] [blame]
Chris Lattner6c38a792002-10-01 19:36:54 +00001//===-- Timer.cpp - Interval Timing Support -------------------------------===//
Misha Brukmanf976c852005-04-21 22:55:34 +00002//
John Criswellb576c942003-10-20 19:43:21 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Misha Brukmanf976c852005-04-21 22:55:34 +00007//
John Criswellb576c942003-10-20 19:43:21 +00008//===----------------------------------------------------------------------===//
Chris Lattner6c38a792002-10-01 19:36:54 +00009//
10// Interval Timing implementation.
11//
12//===----------------------------------------------------------------------===//
13
Reid Spencer551ccae2004-09-01 22:55:40 +000014#include "llvm/Support/Timer.h"
15#include "llvm/Support/CommandLine.h"
Chris Lattnerfc86c3c2010-03-29 21:28:41 +000016#include "llvm/Support/Debug.h"
Chris Lattner90aa8392006-10-04 21:52:35 +000017#include "llvm/Support/ManagedStatic.h"
Chris Lattnerd9ea85a2009-08-23 08:43:55 +000018#include "llvm/Support/raw_ostream.h"
19#include "llvm/Support/Format.h"
Chris Lattnerfc86c3c2010-03-29 21:28:41 +000020#include "llvm/System/Mutex.h"
Reid Spencerdf52c9a2004-12-20 00:59:04 +000021#include "llvm/System/Process.h"
Chris Lattnerb4db5f32004-06-07 19:34:51 +000022#include <map>
Chris Lattnerb6d465f2003-12-14 21:27:33 +000023using namespace llvm;
Chris Lattnerf205fec2003-05-09 20:05:44 +000024
Chris Lattnerb4db5f32004-06-07 19:34:51 +000025// GetLibSupportInfoOutputFile - Return a file stream to print our output on.
Chris Lattnerd9ea85a2009-08-23 08:43:55 +000026namespace llvm { extern raw_ostream *GetLibSupportInfoOutputFile(); }
Brian Gaeked0fde302003-11-11 22:41:34 +000027
Chris Lattner71336a92003-07-31 19:38:34 +000028// getLibSupportInfoOutputFilename - This ugly hack is brought to you courtesy
29// of constructor/destructor ordering being unspecified by C++. Basically the
Chris Lattnerac0b6ae2006-12-06 17:46:33 +000030// problem is that a Statistic object gets destroyed, which ends up calling
Chris Lattner71336a92003-07-31 19:38:34 +000031// 'GetLibSupportInfoOutputFile()' (below), which calls this function.
32// LibSupportInfoOutputFilename used to be a global variable, but sometimes it
Reid Spencerf6e5a252004-12-14 03:55:21 +000033// 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.
Chris Lattner90aa8392006-10-04 21:52:35 +000036static ManagedStatic<std::string> LibSupportInfoOutputFilename;
Chris Lattner71336a92003-07-31 19:38:34 +000037static std::string &getLibSupportInfoOutputFilename() {
Reid Spencerf6e5a252004-12-14 03:55:21 +000038 return *LibSupportInfoOutputFilename;
Chris Lattner71336a92003-07-31 19:38:34 +000039}
Chris Lattner6c38a792002-10-01 19:36:54 +000040
Owen Anderson46d9a642009-06-23 20:52:29 +000041static ManagedStatic<sys::SmartMutex<true> > TimerLock;
42
Chris Lattner3f398492003-01-30 23:08:50 +000043namespace {
Dan Gohman3c02aca2008-04-23 23:15:23 +000044 static cl::opt<bool>
Chris Lattner3f398492003-01-30 23:08:50 +000045 TrackSpace("track-memory", cl::desc("Enable -time-passes memory "
46 "tracking (this may be slow)"),
47 cl::Hidden);
Chris Lattnerf205fec2003-05-09 20:05:44 +000048
Dan Gohman3c02aca2008-04-23 23:15:23 +000049 static cl::opt<std::string, true>
Chris Lattner96a54db2003-08-01 22:15:15 +000050 InfoOutputFilename("info-output-file", cl::value_desc("filename"),
Chris Lattnerf205fec2003-05-09 20:05:44 +000051 cl::desc("File to append -stats and -timer output to"),
Chris Lattner71336a92003-07-31 19:38:34 +000052 cl::Hidden, cl::location(getLibSupportInfoOutputFilename()));
Chris Lattner3f398492003-01-30 23:08:50 +000053}
54
Owen Anderson200aa6d2009-06-23 16:36:10 +000055static TimerGroup *DefaultTimerGroup = 0;
Chris Lattner6c38a792002-10-01 19:36:54 +000056static TimerGroup *getDefaultTimerGroup() {
Chris Lattner9bb110f2010-03-29 20:35:01 +000057 TimerGroup *tmp = DefaultTimerGroup;
Owen Anderson3b8d1352009-06-23 17:33:37 +000058 sys::MemoryFence();
Chris Lattner9bb110f2010-03-29 20:35:01 +000059 if (tmp) return tmp;
60
61 llvm_acquire_global_lock();
62 tmp = DefaultTimerGroup;
Owen Anderson3b8d1352009-06-23 17:33:37 +000063 if (!tmp) {
Chris Lattner9bb110f2010-03-29 20:35:01 +000064 tmp = new TimerGroup("Miscellaneous Ungrouped Timers");
65 sys::MemoryFence();
66 DefaultTimerGroup = tmp;
Owen Anderson3b8d1352009-06-23 17:33:37 +000067 }
Chris Lattner9bb110f2010-03-29 20:35:01 +000068 llvm_release_global_lock();
Mikhail Glushenkovc11e84d2009-11-07 06:33:12 +000069
Owen Anderson3b8d1352009-06-23 17:33:37 +000070 return tmp;
Chris Lattner6c38a792002-10-01 19:36:54 +000071}
72
Chris Lattner9bb110f2010-03-29 20:35:01 +000073//===----------------------------------------------------------------------===//
74// Timer Implementation
75//===----------------------------------------------------------------------===//
76
Chris Lattner6c38a792002-10-01 19:36:54 +000077Timer::Timer(const std::string &N)
Chris Lattnerfc86c3c2010-03-29 21:28:41 +000078 : Elapsed(0), UserTime(0), SystemTime(0), MemUsed(0), Name(N),
Chris Lattner6c38a792002-10-01 19:36:54 +000079 Started(false), TG(getDefaultTimerGroup()) {
80 TG->addTimer();
81}
82
83Timer::Timer(const std::string &N, TimerGroup &tg)
Chris Lattnerfc86c3c2010-03-29 21:28:41 +000084 : Elapsed(0), UserTime(0), SystemTime(0), MemUsed(0), Name(N),
Chris Lattner6c38a792002-10-01 19:36:54 +000085 Started(false), TG(&tg) {
86 TG->addTimer();
87}
88
89Timer::Timer(const Timer &T) {
90 TG = T.TG;
91 if (TG) TG->addTimer();
92 operator=(T);
93}
94
Chris Lattner6c38a792002-10-01 19:36:54 +000095// Copy ctor, initialize with no TG member.
96Timer::Timer(bool, const Timer &T) {
97 TG = T.TG; // Avoid assertion in operator=
98 operator=(T); // Copy contents
99 TG = 0;
100}
101
Chris Lattner6c38a792002-10-01 19:36:54 +0000102Timer::~Timer() {
Chris Lattner9bb110f2010-03-29 20:35:01 +0000103 if (!TG) return;
104
105 if (Started) {
106 Started = false;
107 TG->addTimerToPrint(*this);
Chris Lattner6c38a792002-10-01 19:36:54 +0000108 }
Chris Lattner9bb110f2010-03-29 20:35:01 +0000109 TG->removeTimer();
Chris Lattner6c38a792002-10-01 19:36:54 +0000110}
111
Jeff Cohene269a1a2005-01-08 20:15:57 +0000112static inline size_t getMemUsage() {
Reid Spenceraeb47b82004-12-27 08:03:04 +0000113 if (TrackSpace)
Jeff Cohene269a1a2005-01-08 20:15:57 +0000114 return sys::Process::GetMallocUsage();
Reid Spenceraeb47b82004-12-27 08:03:04 +0000115 return 0;
116}
117
Chris Lattner6c38a792002-10-01 19:36:54 +0000118struct TimeRecord {
Owen Anderson6f2c64d2009-06-23 20:17:22 +0000119 double Elapsed, UserTime, SystemTime;
120 ssize_t MemUsed;
Chris Lattner6c38a792002-10-01 19:36:54 +0000121};
122
Chris Lattner8f0d8242002-11-18 21:47:09 +0000123static TimeRecord getTimeRecord(bool Start) {
Chris Lattnerb4db5f32004-06-07 19:34:51 +0000124 TimeRecord Result;
Chris Lattner8f0d8242002-11-18 21:47:09 +0000125
Reid Spencerdf52c9a2004-12-20 00:59:04 +0000126 sys::TimeValue now(0,0);
127 sys::TimeValue user(0,0);
128 sys::TimeValue sys(0,0);
Chris Lattner6c38a792002-10-01 19:36:54 +0000129
Owen Anderson6f2c64d2009-06-23 20:17:22 +0000130 ssize_t MemUsed = 0;
Reid Spencer7d055632004-12-20 21:44:27 +0000131 if (Start) {
Reid Spenceraeb47b82004-12-27 08:03:04 +0000132 MemUsed = getMemUsage();
Chris Lattner9bb110f2010-03-29 20:35:01 +0000133 sys::Process::GetTimeUsage(now, user, sys);
Reid Spencer7d055632004-12-20 21:44:27 +0000134 } else {
Chris Lattner9bb110f2010-03-29 20:35:01 +0000135 sys::Process::GetTimeUsage(now, user, sys);
Chris Lattnerfed1b272005-03-22 03:20:38 +0000136 MemUsed = getMemUsage();
Reid Spencer7d055632004-12-20 21:44:27 +0000137 }
Reid Spencerdf52c9a2004-12-20 00:59:04 +0000138
Chris Lattner9bb110f2010-03-29 20:35:01 +0000139 Result.Elapsed = now.seconds() + now.microseconds() / 1000000.0;
140 Result.UserTime = user.seconds() + user.microseconds() / 1000000.0;
141 Result.SystemTime = sys.seconds() + sys.microseconds() / 1000000.0;
142 Result.MemUsed = MemUsed;
Chris Lattner6c38a792002-10-01 19:36:54 +0000143 return Result;
144}
145
Chris Lattner90aa8392006-10-04 21:52:35 +0000146static ManagedStatic<std::vector<Timer*> > ActiveTimers;
Chris Lattner8f0d8242002-11-18 21:47:09 +0000147
Chris Lattner6c38a792002-10-01 19:36:54 +0000148void Timer::startTimer() {
149 Started = true;
Dan Gohman153d28a2008-06-24 22:07:07 +0000150 ActiveTimers->push_back(this);
Chris Lattner8f0d8242002-11-18 21:47:09 +0000151 TimeRecord TR = getTimeRecord(true);
Chris Lattner6c38a792002-10-01 19:36:54 +0000152 Elapsed -= TR.Elapsed;
153 UserTime -= TR.UserTime;
154 SystemTime -= TR.SystemTime;
Chris Lattner18eba912002-11-04 19:19:36 +0000155 MemUsed -= TR.MemUsed;
Chris Lattner6c38a792002-10-01 19:36:54 +0000156}
157
158void Timer::stopTimer() {
Chris Lattner8f0d8242002-11-18 21:47:09 +0000159 TimeRecord TR = getTimeRecord(false);
Chris Lattner6c38a792002-10-01 19:36:54 +0000160 Elapsed += TR.Elapsed;
161 UserTime += TR.UserTime;
162 SystemTime += TR.SystemTime;
Chris Lattner18eba912002-11-04 19:19:36 +0000163 MemUsed += TR.MemUsed;
Chris Lattner8f0d8242002-11-18 21:47:09 +0000164
Chris Lattner90aa8392006-10-04 21:52:35 +0000165 if (ActiveTimers->back() == this) {
166 ActiveTimers->pop_back();
Chris Lattner8f0d8242002-11-18 21:47:09 +0000167 } else {
168 std::vector<Timer*>::iterator I =
Chris Lattner90aa8392006-10-04 21:52:35 +0000169 std::find(ActiveTimers->begin(), ActiveTimers->end(), this);
170 assert(I != ActiveTimers->end() && "stop but no startTimer?");
171 ActiveTimers->erase(I);
Chris Lattner8f0d8242002-11-18 21:47:09 +0000172 }
Chris Lattner6c38a792002-10-01 19:36:54 +0000173}
174
175void Timer::sum(const Timer &T) {
176 Elapsed += T.Elapsed;
177 UserTime += T.UserTime;
178 SystemTime += T.SystemTime;
Chris Lattner18eba912002-11-04 19:19:36 +0000179 MemUsed += T.MemUsed;
Chris Lattner6c38a792002-10-01 19:36:54 +0000180}
181
Chris Lattner0ea86bc2010-03-29 21:24:52 +0000182const Timer &Timer::operator=(const Timer &T) {
183 Elapsed = T.Elapsed;
184 UserTime = T.UserTime;
185 SystemTime = T.SystemTime;
186 MemUsed = T.MemUsed;
Chris Lattner0ea86bc2010-03-29 21:24:52 +0000187 Name = T.Name;
188 Started = T.Started;
189 assert(TG == T.TG && "Can only assign timers in the same TimerGroup!");
190 return *this;
191}
192
193
Chris Lattner9bb110f2010-03-29 20:35:01 +0000194static void printVal(double Val, double Total, raw_ostream &OS) {
Chris Lattner0613edc2010-03-29 20:40:19 +0000195 if (Total < 1e-7) // Avoid dividing by zero.
Chris Lattner9bb110f2010-03-29 20:35:01 +0000196 OS << " ----- ";
197 else {
198 OS << " " << format("%7.4f", Val) << " (";
199 OS << format("%5.1f", Val*100/Total) << "%)";
200 }
201}
202
203void Timer::print(const Timer &Total, raw_ostream &OS) {
Chris Lattner9bb110f2010-03-29 20:35:01 +0000204 if (Total.UserTime)
205 printVal(UserTime, Total.UserTime, OS);
206 if (Total.SystemTime)
207 printVal(SystemTime, Total.SystemTime, OS);
208 if (Total.getProcessTime())
209 printVal(getProcessTime(), Total.getProcessTime(), OS);
210 printVal(Elapsed, Total.Elapsed, OS);
211
212 OS << " ";
213
Chris Lattner0ea86bc2010-03-29 21:24:52 +0000214 if (Total.MemUsed)
Chris Lattner9bb110f2010-03-29 20:35:01 +0000215 OS << format("%9lld", (long long)MemUsed) << " ";
Chris Lattner0ea86bc2010-03-29 21:24:52 +0000216
Chris Lattner9bb110f2010-03-29 20:35:01 +0000217 OS << Name << "\n";
218
219 Started = false; // Once printed, don't print again
220}
221
222
Chris Lattnerd5a310e2003-10-06 15:02:31 +0000223//===----------------------------------------------------------------------===//
224// NamedRegionTimer Implementation
225//===----------------------------------------------------------------------===//
226
Dan Gohman5e843682008-07-14 18:19:29 +0000227typedef std::map<std::string, Timer> Name2Timer;
228typedef std::map<std::string, std::pair<TimerGroup, Name2Timer> > Name2Pair;
229
Dan Gohman5e843682008-07-14 18:19:29 +0000230static ManagedStatic<Name2Timer> NamedTimers;
Dan Gohman5e843682008-07-14 18:19:29 +0000231static ManagedStatic<Name2Pair> NamedGroupedTimers;
Chris Lattnerd5a310e2003-10-06 15:02:31 +0000232
Chris Lattner90aa8392006-10-04 21:52:35 +0000233static Timer &getNamedRegionTimer(const std::string &Name) {
Owen Andersona9d1f2c2009-07-07 18:33:04 +0000234 sys::SmartScopedLock<true> L(*TimerLock);
Dan Gohman5e843682008-07-14 18:19:29 +0000235 Name2Timer::iterator I = NamedTimers->find(Name);
Dan Gohmanc418bf32008-07-11 20:58:19 +0000236 if (I != NamedTimers->end())
Chris Lattnerd5a310e2003-10-06 15:02:31 +0000237 return I->second;
238
Chris Lattner90aa8392006-10-04 21:52:35 +0000239 return NamedTimers->insert(I, std::make_pair(Name, Timer(Name)))->second;
Chris Lattnerd5a310e2003-10-06 15:02:31 +0000240}
241
Dan Gohman5e843682008-07-14 18:19:29 +0000242static Timer &getNamedRegionTimer(const std::string &Name,
243 const std::string &GroupName) {
Owen Andersona9d1f2c2009-07-07 18:33:04 +0000244 sys::SmartScopedLock<true> L(*TimerLock);
Dan Gohman5e843682008-07-14 18:19:29 +0000245
246 Name2Pair::iterator I = NamedGroupedTimers->find(GroupName);
247 if (I == NamedGroupedTimers->end()) {
248 TimerGroup TG(GroupName);
249 std::pair<TimerGroup, Name2Timer> Pair(TG, Name2Timer());
250 I = NamedGroupedTimers->insert(I, std::make_pair(GroupName, Pair));
251 }
252
253 Name2Timer::iterator J = I->second.second.find(Name);
254 if (J == I->second.second.end())
255 J = I->second.second.insert(J,
256 std::make_pair(Name,
257 Timer(Name,
258 I->second.first)));
259
260 return J->second;
261}
262
Chris Lattnerd5a310e2003-10-06 15:02:31 +0000263NamedRegionTimer::NamedRegionTimer(const std::string &Name)
264 : TimeRegion(getNamedRegionTimer(Name)) {}
265
Dan Gohman5e843682008-07-14 18:19:29 +0000266NamedRegionTimer::NamedRegionTimer(const std::string &Name,
267 const std::string &GroupName)
268 : TimeRegion(getNamedRegionTimer(Name, GroupName)) {}
Chris Lattner8f0d8242002-11-18 21:47:09 +0000269
Chris Lattner6c38a792002-10-01 19:36:54 +0000270//===----------------------------------------------------------------------===//
271// TimerGroup Implementation
272//===----------------------------------------------------------------------===//
273
Chris Lattner0613edc2010-03-29 20:40:19 +0000274// GetLibSupportInfoOutputFile - Return a file stream to print our output on.
Chris Lattner0ea86bc2010-03-29 21:24:52 +0000275raw_ostream *llvm::GetLibSupportInfoOutputFile() {
Chris Lattner71336a92003-07-31 19:38:34 +0000276 std::string &LibSupportInfoOutputFilename = getLibSupportInfoOutputFilename();
Chris Lattnerf205fec2003-05-09 20:05:44 +0000277 if (LibSupportInfoOutputFilename.empty())
Chris Lattnerd9ea85a2009-08-23 08:43:55 +0000278 return &errs();
Chris Lattnerf205fec2003-05-09 20:05:44 +0000279 if (LibSupportInfoOutputFilename == "-")
Chris Lattnerd9ea85a2009-08-23 08:43:55 +0000280 return &outs();
Chris Lattnerf205fec2003-05-09 20:05:44 +0000281
Chris Lattnerd9ea85a2009-08-23 08:43:55 +0000282 std::string Error;
283 raw_ostream *Result = new raw_fd_ostream(LibSupportInfoOutputFilename.c_str(),
284 Error, raw_fd_ostream::F_Append);
285 if (Error.empty())
286 return Result;
Mikhail Glushenkovc11e84d2009-11-07 06:33:12 +0000287
Chris Lattnerd9ea85a2009-08-23 08:43:55 +0000288 errs() << "Error opening info-output-file '"
Bill Wendlingbcd24982006-12-07 20:28:15 +0000289 << LibSupportInfoOutputFilename << " for appending!\n";
Chris Lattnerd9ea85a2009-08-23 08:43:55 +0000290 delete Result;
291 return &errs();
Chris Lattnerf205fec2003-05-09 20:05:44 +0000292}
293
Chris Lattner6c38a792002-10-01 19:36:54 +0000294
295void TimerGroup::removeTimer() {
Owen Andersona9d1f2c2009-07-07 18:33:04 +0000296 sys::SmartScopedLock<true> L(*TimerLock);
Chris Lattner9bb110f2010-03-29 20:35:01 +0000297 if (--NumTimers != 0 || TimersToPrint.empty())
298 return; // Don't print timing report.
299
300 // Sort the timers in descending order by amount of time taken.
301 std::sort(TimersToPrint.begin(), TimersToPrint.end(),
302 std::greater<Timer>());
Chris Lattner6c38a792002-10-01 19:36:54 +0000303
Chris Lattner9bb110f2010-03-29 20:35:01 +0000304 // Figure out how many spaces to indent TimerGroup name.
305 unsigned Padding = (80-Name.length())/2;
306 if (Padding > 80) Padding = 0; // Don't allow "negative" numbers
Chris Lattner6c38a792002-10-01 19:36:54 +0000307
Chris Lattner9bb110f2010-03-29 20:35:01 +0000308 raw_ostream *OutStream = GetLibSupportInfoOutputFile();
Chris Lattnerf205fec2003-05-09 20:05:44 +0000309
Chris Lattner9bb110f2010-03-29 20:35:01 +0000310 ++NumTimers;
Chris Lattner0613edc2010-03-29 20:40:19 +0000311 { // Scope to contain Total timer: don't allow total timer to drop us to
312 // zero timers.
Chris Lattner9bb110f2010-03-29 20:35:01 +0000313 Timer Total("TOTAL");
Misha Brukmanf976c852005-04-21 22:55:34 +0000314
Chris Lattner9bb110f2010-03-29 20:35:01 +0000315 for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i)
316 Total.sum(TimersToPrint[i]);
Misha Brukmanf976c852005-04-21 22:55:34 +0000317
Chris Lattner0613edc2010-03-29 20:40:19 +0000318 // Print out timing header.
Chris Lattner9bb110f2010-03-29 20:35:01 +0000319 *OutStream << "===" << std::string(73, '-') << "===\n"
320 << std::string(Padding, ' ') << Name << "\n"
321 << "===" << std::string(73, '-')
322 << "===\n";
Chris Lattner8166b7c2003-02-13 16:25:28 +0000323
Chris Lattner9bb110f2010-03-29 20:35:01 +0000324 // If this is not an collection of ungrouped times, print the total time.
325 // Ungrouped timers don't really make sense to add up. We still print the
326 // TOTAL line to make the percentages make sense.
327 if (this != DefaultTimerGroup) {
328 *OutStream << " Total Execution Time: ";
Chris Lattner3ac96052005-02-09 18:41:32 +0000329
Chris Lattner9bb110f2010-03-29 20:35:01 +0000330 *OutStream << format("%5.4f", Total.getProcessTime()) << " seconds (";
331 *OutStream << format("%5.4f", Total.getWallTime()) << " wall clock)\n";
Chris Lattner6c38a792002-10-01 19:36:54 +0000332 }
Chris Lattner9bb110f2010-03-29 20:35:01 +0000333 *OutStream << "\n";
Chris Lattner6c38a792002-10-01 19:36:54 +0000334
Chris Lattner9bb110f2010-03-29 20:35:01 +0000335 if (Total.UserTime)
336 *OutStream << " ---User Time---";
337 if (Total.SystemTime)
338 *OutStream << " --System Time--";
339 if (Total.getProcessTime())
340 *OutStream << " --User+System--";
341 *OutStream << " ---Wall Time---";
342 if (Total.getMemUsed())
343 *OutStream << " ---Mem---";
Chris Lattner9bb110f2010-03-29 20:35:01 +0000344 *OutStream << " --- Name ---\n";
Chris Lattnerf205fec2003-05-09 20:05:44 +0000345
Chris Lattner0613edc2010-03-29 20:40:19 +0000346 // Loop through all of the timing data, printing it out.
Chris Lattner9bb110f2010-03-29 20:35:01 +0000347 for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i)
348 TimersToPrint[i].print(Total, *OutStream);
349
350 Total.print(Total, *OutStream);
351 *OutStream << '\n';
352 OutStream->flush();
Chris Lattner6c38a792002-10-01 19:36:54 +0000353 }
Chris Lattner9bb110f2010-03-29 20:35:01 +0000354 --NumTimers;
355
356 TimersToPrint.clear();
357
Chris Lattner0ea86bc2010-03-29 21:24:52 +0000358 if (OutStream != &errs() && OutStream != &outs())
Chris Lattner0613edc2010-03-29 20:40:19 +0000359 delete OutStream; // Close the file.
Chris Lattner6c38a792002-10-01 19:36:54 +0000360}
Brian Gaeked0fde302003-11-11 22:41:34 +0000361
Owen Anderson46d9a642009-06-23 20:52:29 +0000362void TimerGroup::addTimer() {
Owen Andersona9d1f2c2009-07-07 18:33:04 +0000363 sys::SmartScopedLock<true> L(*TimerLock);
Owen Anderson46d9a642009-06-23 20:52:29 +0000364 ++NumTimers;
365}
366
367void TimerGroup::addTimerToPrint(const Timer &T) {
Owen Andersona9d1f2c2009-07-07 18:33:04 +0000368 sys::SmartScopedLock<true> L(*TimerLock);
Owen Anderson46d9a642009-06-23 20:52:29 +0000369 TimersToPrint.push_back(Timer(true, T));
370}
371