9#ifndef LLVM_SUPPORT_TIMER_H
10#define LLVM_SUPPORT_TIMER_H
26 double WallTime = 0.0;
27 double UserTime = 0.0;
28 double SystemTime = 0.0;
49 return WallTime <
T.WallTime;
53 WallTime +=
RHS.WallTime;
54 UserTime +=
RHS.UserTime;
55 SystemTime +=
RHS.SystemTime;
56 MemUsed +=
RHS.MemUsed;
57 InstructionsExecuted +=
RHS.InstructionsExecuted;
60 WallTime -=
RHS.WallTime;
61 UserTime -=
RHS.UserTime;
62 SystemTime -=
RHS.SystemTime;
63 MemUsed -=
RHS.MemUsed;
64 InstructionsExecuted -=
RHS.InstructionsExecuted;
83 std::string Description;
85 bool Triggered =
false;
88 Timer **Prev =
nullptr;
89 Timer *Next =
nullptr;
92 init(TimerName, TimerDescription);
95 init(TimerName, TimerDescription, tg);
98 assert(!
RHS.TG &&
"Can only copy uninitialized timers");
101 assert(!TG && !
T.TG &&
"Can only assign uninit timers");
111 const std::string &
getName()
const {
return Name; }
152 if (
T)
T->startTimer();
155 if (
T)
T->stopTimer();
177 std::string Description;
179 PrintRecord(
const PrintRecord &
Other) =
default;
180 PrintRecord &operator=(
const PrintRecord &
Other) =
default;
181 PrintRecord(
const TimeRecord &Time,
const std::string &Name,
182 const std::string &Description)
183 : Time(Time), Name(Name), Description(Description) {}
185 bool operator <(
const PrintRecord &
Other)
const {
186 return Time <
Other.Time;
190 std::string Description;
191 Timer *FirstTimer =
nullptr;
192 std::vector<PrintRecord> TimersToPrint;
197 void operator=(
const TimerGroup &TG) =
delete;
208 Name.assign(NewName.
begin(), NewName.
end());
209 Description.assign(NewDescription.
begin(), NewDescription.
end());
245 void removeTimer(
Timer &
T);
246 void prepareToPrintList(
bool reset_time =
false);
249 const char *suffix,
double Value);
This file defines the StringMap class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
StringRef - Represent a constant reference to a string, i.e.
double getUserTime() const
double getProcessTime() const
static TimeRecord getCurrentTime(bool Start=true)
Get the current time and memory usage.
double getWallTime() const
ssize_t getMemUsed() const
void operator-=(const TimeRecord &RHS)
void operator+=(const TimeRecord &RHS)
double getSystemTime() const
bool operator<(const TimeRecord &T) 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.
uint64_t getInstructionsExecuted() const
The TimeRegion class is used as a helper class to call the startTimer() and stopTimer() methods of th...
The TimerGroup class is used to group together related timers into a single report that is printed wh...
static void printAll(raw_ostream &OS)
This static method prints all timers.
void setName(StringRef NewName, StringRef NewDescription)
void print(raw_ostream &OS, bool ResetAfterPrint=false)
Print any started timers in this group, optionally resetting timers after printing them.
static void clearAll()
Clear out all timers.
void clear()
Clear all timers in this group.
friend void PrintStatisticsJSON(raw_ostream &OS)
Print statistics in JSON format.
static std::unique_ptr< TimerGroup > aquireDefaultGroup()
This makes the default group unmanaged, and lets the user manage the group's lifetime.
static const char * printAllJSONValues(raw_ostream &OS, const char *delim)
Prints all timers as JSON key/value pairs.
const char * printJSONValues(raw_ostream &OS, const char *delim)
static void constructForStatistics()
Ensure global objects required for statistics printing are initialized.
This class is used to track the amount of time spent between invocations of its startTimer()/stopTime...
bool hasTriggered() const
Check if startTimer() has ever been called on this timer.
bool isRunning() const
Check if the timer is currently running.
void stopTimer()
Stop the timer.
const Timer & operator=(const Timer &T)
const std::string & getDescription() const
void init(StringRef TimerName, StringRef TimerDescription)
void clear()
Clear the timer state.
const std::string & getName() const
Timer()=default
Create an uninitialized timer, client must use 'init'.
bool isInitialized() const
Timer(StringRef TimerName, StringRef TimerDescription)
Timer(StringRef TimerName, StringRef TimerDescription, TimerGroup &tg)
void startTimer()
Start the timer running.
TimeRecord getTotalTime() const
Return the duration for which this timer has been running.
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
This class is basically a combination of TimeRegion and Timer.