Go to the documentation of this file.
9 #ifndef LLVM_SUPPORT_TIMER_H
10 #define LLVM_SUPPORT_TIMER_H
33 : WallTime(0), UserTime(0), SystemTime(0), MemUsed(0),
34 InstructionsExecuted(0) {}
51 return WallTime <
T.WallTime;
55 WallTime +=
RHS.WallTime;
56 UserTime +=
RHS.UserTime;
57 SystemTime +=
RHS.SystemTime;
58 MemUsed +=
RHS.MemUsed;
59 InstructionsExecuted +=
RHS.InstructionsExecuted;
62 WallTime -=
RHS.WallTime;
63 UserTime -=
RHS.UserTime;
64 SystemTime -=
RHS.SystemTime;
65 MemUsed -=
RHS.MemUsed;
66 InstructionsExecuted -=
RHS.InstructionsExecuted;
85 std::string Description;
87 bool Triggered =
false;
90 Timer **Prev =
nullptr;
91 Timer *Next =
nullptr;
94 init(TimerName, TimerDescription);
97 init(TimerName, TimerDescription, tg);
100 assert(!
RHS.TG &&
"Can only copy uninitialized timers");
103 assert(!TG && !
T.TG &&
"Can only assign uninit timers");
109 explicit Timer() =
default;
113 const std::string &
getName()
const {
return Name; }
154 if (
T)
T->startTimer();
157 if (
T)
T->stopTimer();
179 std::string Description;
181 PrintRecord(
const PrintRecord &
Other) =
default;
182 PrintRecord &operator=(
const PrintRecord &
Other) =
default;
183 PrintRecord(
const TimeRecord &Time,
const std::string &Name,
184 const std::string &Description)
185 : Time(Time), Name(Name), Description(Description) {}
188 return Time <
Other.Time;
192 std::string Description;
193 Timer *FirstTimer =
nullptr;
194 std::vector<PrintRecord> TimersToPrint;
199 void operator=(
const TimerGroup &TG) =
delete;
210 Name.assign(NewName.
begin(), NewName.
end());
211 Description.assign(NewDescription.
begin(), NewDescription.
end());
247 void removeTimer(
Timer &
T);
248 void prepareToPrintList(
bool reset_time =
false);
250 void printJSONValue(
raw_ostream &OS,
const PrintRecord &
R,
251 const char *suffix,
double Value);
void clear()
Clear the timer state.
This is an optimization pass for GlobalISel generic memory operations.
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.
bool hasTriggered() const
Check if startTimer() has ever been called on this timer.
void print(raw_ostream &OS, bool ResetAfterPrint=false)
Print any started timers in this group, optionally resetting timers after printing them.
void clear()
Clear all timers in this group.
void operator-=(const TimeRecord &RHS)
static void printAll(raw_ostream &OS)
This static method prints all timers.
void init(StringRef TimerName, StringRef TimerDescription)
This class is used to track the amount of time spent between invocations of its startTimer()/stopTime...
friend void PrintStatisticsJSON(raw_ostream &OS)
Print statistics in JSON format.
Timer(StringRef TimerName, StringRef TimerDescription)
void startTimer()
Start the timer running.
void operator+=(const TimeRecord &RHS)
bool isRunning() const
Check if the timer is currently running.
static TimeRecord getCurrentTime(bool Start=true)
Get the current time and memory usage.
The TimeRegion class is used as a helper class to call the startTimer() and stopTimer() methods of th...
bitcast float %x to i32 %s=and i32 %t, 2147483647 %d=bitcast i32 %s to float ret float %d } declare float @fabsf(float %n) define float @bar(float %x) nounwind { %d=call float @fabsf(float %x) ret float %d } This IR(from PR6194):target datalayout="e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" target triple="x86_64-apple-darwin10.0.0" %0=type { double, double } %struct.float3=type { float, float, float } define void @test(%0, %struct.float3 *nocapture %res) nounwind noinline ssp { entry:%tmp18=extractvalue %0 %0, 0 t
This class implements an extremely fast bulk output stream that can only output to a stream.
const std::string & getDescription() const
static void clearAll()
Clear out all timers.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
static void ConstructTimerLists()
Ensure global timer group lists are initialized.
bool operator<(const TimeRecord &T) const
void setName(StringRef NewName, StringRef NewDescription)
bool isInitialized() const
Timer(StringRef TimerName, StringRef TimerDescription, TimerGroup &tg)
Timer()=default
Create an uninitialized timer, client must use 'init'.
const char * printJSONValues(raw_ostream &OS, const char *delim)
bool operator<(int64_t V1, const APSInt &V2)
double getProcessTime() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void stopTimer()
Stop the timer.
TimeRecord getTotalTime() const
Return the duration for which this timer has been running.
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.
double getWallTime() const
StringRef - Represent a constant reference to a string, i.e.
NamedRegionTimer(StringRef Name, StringRef Description, StringRef GroupName, StringRef GroupDescription, bool Enabled=true)
double getUserTime() const
ssize_t getMemUsed() const
The TimerGroup class is used to group together related timers into a single report that is printed wh...
const Timer & operator=(const Timer &T)
This class is basically a combination of TimeRegion and Timer.
const std::string & getName() const
uint64_t getInstructionsExecuted() const
LLVM Value Representation.
Optional< std::vector< StOtherPiece > > Other
double getSystemTime() const