LLVM 22.0.0git
llvm::Timer Class Reference

This class is used to track the amount of time spent between invocations of its startTimer()/stopTimer() methods. More...

#include "llvm/Support/Timer.h"

Public Member Functions

 Timer (StringRef TimerName, StringRef TimerDescription)
 Timer (StringRef TimerName, StringRef TimerDescription, TimerGroup &tg)
 Timer (const Timer &RHS)
const Timeroperator= (const Timer &T)
LLVM_ABI ~Timer ()
 Timer ()=default
 Create an uninitialized timer, client must use 'init'.
LLVM_ABI void init (StringRef TimerName, StringRef TimerDescription)
LLVM_ABI void init (StringRef TimerName, StringRef TimerDescription, TimerGroup &tg)
const std::string & getName () const
const std::string & getDescription () const
bool isInitialized () const
bool isRunning () const
 Check if the timer is currently running.
bool hasTriggered () const
 Check if startTimer() has ever been called on this timer.
LLVM_ABI void startTimer ()
 Start the timer running.
LLVM_ABI void stopTimer ()
 Stop the timer.
LLVM_ABI void clear ()
 Clear the timer state.
LLVM_ABI void yieldTo (Timer &)
 Stop the timer and start another timer.
TimeRecord getTotalTime () const
 Return the duration for which this timer has been running.

Friends

class TimerGroup

Detailed Description

This class is used to track the amount of time spent between invocations of its startTimer()/stopTimer() methods.

Given appropriate OS support it can also keep track of the RSS of the program at various points. By default, the Timer will print the amount of time it has captured to standard error when the last timer is destroyed, otherwise it is printed when its TimerGroup is destroyed. Timers do not print their information if they are never started.

Definition at line 82 of file Timer.h.

Constructor & Destructor Documentation

◆ Timer() [1/4]

llvm::Timer::Timer ( StringRef TimerName,
StringRef TimerDescription )
inlineexplicit

Definition at line 94 of file Timer.h.

References init().

Referenced by operator=(), Timer(), and yieldTo().

◆ Timer() [2/4]

llvm::Timer::Timer ( StringRef TimerName,
StringRef TimerDescription,
TimerGroup & tg )
inline

Definition at line 97 of file Timer.h.

References init(), and TimerGroup.

◆ Timer() [3/4]

llvm::Timer::Timer ( const Timer & RHS)
inline

Definition at line 100 of file Timer.h.

References assert(), RHS, and Timer().

◆ ~Timer()

Timer::~Timer ( )

Definition at line 105 of file Timer.cpp.

◆ Timer() [4/4]

llvm::Timer::Timer ( )
explicitdefault

Create an uninitialized timer, client must use 'init'.

References LLVM_ABI, and TimerGroup.

Member Function Documentation

◆ clear()

void Timer::clear ( )

Clear the timer state.

Definition at line 168 of file Timer.cpp.

◆ getDescription()

const std::string & llvm::Timer::getDescription ( ) const
inline

Definition at line 116 of file Timer.h.

◆ getName()

const std::string & llvm::Timer::getName ( ) const
inline

Definition at line 115 of file Timer.h.

Referenced by startTimer(), and stopTimer().

◆ getTotalTime()

TimeRecord llvm::Timer::getTotalTime ( ) const
inline

Return the duration for which this timer has been running.

Definition at line 140 of file Timer.h.

Referenced by llvm::object::CompressedOffloadBundle::compress(), and llvm::object::CompressedOffloadBundle::decompress().

◆ hasTriggered()

bool llvm::Timer::hasTriggered ( ) const
inline

Check if startTimer() has ever been called on this timer.

Definition at line 123 of file Timer.h.

◆ init() [1/2]

void Timer::init ( StringRef TimerName,
StringRef TimerDescription )

Definition at line 91 of file Timer.cpp.

References defaultTimerGroup(), and init().

Referenced by init(), Timer(), and Timer().

◆ init() [2/2]

void Timer::init ( StringRef TimerName,
StringRef TimerDescription,
TimerGroup & tg )

Definition at line 95 of file Timer.cpp.

References assert(), llvm::StringRef::begin(), llvm::StringRef::end(), and TimerGroup.

◆ isInitialized()

bool llvm::Timer::isInitialized ( ) const
inline

Definition at line 117 of file Timer.h.

◆ isRunning()

bool llvm::Timer::isRunning ( ) const
inline

Check if the timer is currently running.

Definition at line 120 of file Timer.h.

◆ operator=()

const Timer & llvm::Timer::operator= ( const Timer & T)
inline

Definition at line 103 of file Timer.h.

References assert(), T, and Timer().

◆ startTimer()

void Timer::startTimer ( )

Start the timer running.

Time between calls to startTimer/stopTimer is counted by the Timer class. Note that these calls must be correctly paired.

Definition at line 149 of file Timer.cpp.

References assert(), llvm::TimeRecord::getCurrentTime(), getName(), signposts(), and llvm::SignpostEmitter::startInterval().

Referenced by llvm::object::CompressedOffloadBundle::compress(), llvm::object::CompressedOffloadBundle::decompress(), and llvm::TableGenMain().

◆ stopTimer()

◆ yieldTo()

void Timer::yieldTo ( Timer & O)

Stop the timer and start another timer.

Definition at line 173 of file Timer.cpp.

References stopTimer(), and Timer().

◆ TimerGroup

friend class TimerGroup
friend

Definition at line 143 of file Timer.h.

References TimerGroup.

Referenced by init(), Timer(), Timer(), and TimerGroup.


The documentation for this class was generated from the following files: