10 #ifndef LLVM_SUPPORT_TIMER_H
11 #define LLVM_SUPPORT_TIMER_H
14 #include "llvm/Support/DataTypes.h"
32 TimeRecord() : WallTime(0), UserTime(0), SystemTime(0), MemUsed(0) {}
48 return WallTime < T.WallTime;
52 WallTime += RHS.WallTime;
53 UserTime += RHS.UserTime;
54 SystemTime += RHS.SystemTime;
55 MemUsed += RHS.MemUsed;
58 WallTime -= RHS.WallTime;
59 UserTime -= RHS.UserTime;
60 SystemTime -= RHS.SystemTime;
61 MemUsed -= RHS.MemUsed;
80 std::string Description;
89 init(Name, Description);
92 init(Name, Description, tg);
95 assert(!RHS.TG &&
"Can only copy uninitialized timers");
98 assert(!TG && !T.TG &&
"Can only assign uninit timers");
108 const std::string &
getName()
const {
return Name; }
149 if (
T)
T->startTimer();
152 if (
T)
T->stopTimer();
174 std::string Description;
176 PrintRecord(
const PrintRecord &
Other) =
default;
177 PrintRecord(
const TimeRecord &Time,
const std::string &Name,
178 const std::string &Description)
179 : Time(Time), Name(Name), Description(Description) {}
181 bool operator <(
const PrintRecord &Other)
const {
182 return Time < Other.Time;
186 std::string Description;
187 Timer *FirstTimer =
nullptr;
188 std::vector<PrintRecord> TimersToPrint;
193 void operator=(
const TimerGroup &TG) =
delete;
200 Name.assign(NewName.
begin(), NewName.
end());
201 Description.assign(NewDescription.
begin(), NewDescription.
end());
218 void removeTimer(
Timer &
T);
219 void prepareToPrintList();
221 void printJSONValue(
raw_ostream &OS,
const PrintRecord &R,
222 const char *suffix,
double Value);
223 const char *printJSONValues(
raw_ostream &OS,
const char *delim);
224 static const char *printAllJSONValues(
raw_ostream &OS,
const char *delim);
bool isInitialized() const
void print(const TimeRecord &Total, raw_ostream &OS) const
Print the current time record to OS, with a breakdown showing contributions to the Total time record...
const std::string & getName() const
static TimeRecord getCurrentTime(bool Start=true)
Get the current time and memory usage.
void init(StringRef Name, StringRef Description)
void stopTimer()
Stop the timer.
bool isRunning() const
Check if the timer is currently running.
The TimeRegion class is used as a helper class to call the startTimer() and stopTimer() methods of th...
This class is basically a combination of TimeRegion and Timer.
double getProcessTime() const
double getWallTime() const
This class is used to track the amount of time spent between invocations of its startTimer()/stopTime...
double getUserTime() const
friend void PrintStatisticsJSON(raw_ostream &OS)
Print statistics in JSON format.
Timer()
Create an uninitialized timer, client must use 'init'.
ssize_t getMemUsed() const
void clear()
Clear the timer state.
Timer(StringRef Name, StringRef Description)
const std::string & getDescription() const
Timer(StringRef Name, StringRef Description, TimerGroup &tg)
void print(raw_ostream &OS)
Print any started timers in this group and zero them.
TimeRecord getTotalTime() const
Return the duration for which this timer has been running.
double getSystemTime() const
void startTimer()
Start the timer running.
void setName(StringRef NewName, StringRef NewDescription)
bool hasTriggered() const
Check if startTimer() has ever been called on this timer.
void operator+=(const TimeRecord &RHS)
The TimerGroup class is used to group together related timers into a single report that is printed wh...
const Timer & operator=(const Timer &T)
NamedRegionTimer(StringRef Name, StringRef Description, StringRef GroupName, StringRef GroupDescription, bool Enabled=true)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool operator<(int64_t V1, const APSInt &V2)
static void ConstructTimerLists()
Ensure global timer group lists are initialized.
LLVM Value Representation.
bool operator<(const TimeRecord &T) const
static void printAll(raw_ostream &OS)
This static method prints all timers and clears them all out.
void operator-=(const TimeRecord &RHS)
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.