vSMC
vSMC: Scalable Monte Carlo
Public Member Functions | List of all members
vsmc::RDTSCCounter Class Reference

CPU clock cycle counter using rdtsc More...

#include <vsmc/utility/rdtsc.hpp>

Public Member Functions

 RDTSCCounter ()
 
uint64_t cycles () const
 Return the accumulated elapsed cycle count. More...
 
void reset ()
 Stop and reset the elapsed cycle count to zero. More...
 
bool running () const
 If the counter is running. More...
 
bool start ()
 Start the counter, no effect if already started. More...
 
bool stop ()
 Stop the counter, no effect if already stopped. More...
 

Detailed Description

CPU clock cycle counter using rdtsc

Definition at line 88 of file rdtsc.hpp.

Constructor & Destructor Documentation

vsmc::RDTSCCounter::RDTSCCounter ( )
inline

Definition at line 92 of file rdtsc.hpp.

Member Function Documentation

uint64_t vsmc::RDTSCCounter::cycles ( ) const
inline

Return the accumulated elapsed cycle count.

Definition at line 150 of file rdtsc.hpp.

void vsmc::RDTSCCounter::reset ( )
inline

Stop and reset the elapsed cycle count to zero.

Definition at line 143 of file rdtsc.hpp.

bool vsmc::RDTSCCounter::running ( ) const
inline

If the counter is running.

If start() has been called and no stop() call since, then it is running, otherwise it is stoped.

Definition at line 99 of file rdtsc.hpp.

bool vsmc::RDTSCCounter::start ( )
inline

Start the counter, no effect if already started.

Returns
true if it is started by this call, and the elapsed cycle count will be incremented next time stop() is called. The increment will be relative to the time point of this call. false if it is already started earlier.

Definition at line 107 of file rdtsc.hpp.

bool vsmc::RDTSCCounter::stop ( )
inline

Stop the counter, no effect if already stopped.

Returns
true if it is stoped by this call, and the elapsed cycle count has been incremented. false in one of the following situations. In all these situations, the elapsed cycle count will not be incremented.
  • It already stopped or wasn't started before.
  • The cycle count appears to decrease. This is most likely in the case that the TSC MSR has been reset.

Definition at line 127 of file rdtsc.hpp.