TSCClock Class Reference

The TSCClock is a Clock using the Time Stamp Counter which may be found in Pentium-like processors http://en.wikipedia.org/wiki/Time_Stamp_Counter Note that using TSC on a symmetric (or multi-core) multi-processor system may gives unexpected results moreover TSC behavior may be biaised if processor supports dynamic frequency scaling such as Pentium M used on mobile device. More...

#include <TSCClock.hh>

Inheritance diagram for TSCClock:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 TSCClock ()
virtual double getResolution ()
 Get the clock resolution in nano-seconds.
virtual uint64_t getCurrentTicksValue ()
 Get the current ticks value.
virtual double tick2NanoSecond (const uint64_t ticks)
 Convert a number of ticks into a double value representing nanoseconds.
virtual ~TSCClock ()

Private Member Functions

uint64_t readTSC ()
 Read the Time Stamp Counter using rdtsc assembly instruction.

Static Private Member Functions

static double getProcessorFrequency ()
 Get processor frequency.

Private Attributes

double resolution
 The TSC clock resolution in nano-seconds.


Detailed Description

The TSCClock is a Clock using the Time Stamp Counter which may be found in Pentium-like processors http://en.wikipedia.org/wiki/Time_Stamp_Counter Note that using TSC on a symmetric (or multi-core) multi-processor system may gives unexpected results moreover TSC behavior may be biaised if processor supports dynamic frequency scaling such as Pentium M used on mobile device.

If you want a more "robust" Clock class you may use PosixClock.

Definition at line 18 of file TSCClock.hh.


Constructor & Destructor Documentation

TSCClock (  ) 

Definition at line 8 of file TSCClock.cc.

References TSCClock::getProcessorFrequency(), and TSCClock::resolution.

Here is the call graph for this function:

~TSCClock (  )  [virtual]

Definition at line 28 of file TSCClock.cc.


Member Function Documentation

double getResolution (  )  [virtual]

Get the clock resolution in nano-seconds.

Returns:
the clock resolution in nano-seconds

Implements Clock.

Definition at line 14 of file TSCClock.cc.

References TSCClock::resolution.

uint64_t getCurrentTicksValue (  )  [virtual]

Get the current ticks value.

Returns:
the current ticks value

Implements Clock.

Definition at line 19 of file TSCClock.cc.

References TSCClock::readTSC().

Here is the call graph for this function:

double tick2NanoSecond ( const uint64_t  ticks  )  [virtual]

Convert a number of ticks into a double value representing nanoseconds.

Parameters:
[in] ticks the number of tick to convert
Returns:
the nano-seconds value

Implements Clock.

Definition at line 24 of file TSCClock.cc.

References TSCClock::resolution.

double getProcessorFrequency (  )  [static, private]

Get processor frequency.

Returns:
the processor frequency in MHz

Definition at line 32 of file TSCClock.cc.

Referenced by TSCClock::TSCClock().

uint64_t readTSC (  )  [inline, private]

Read the Time Stamp Counter using rdtsc assembly instruction.

Definition at line 51 of file TSCClock.hh.

Referenced by TSCClock::getCurrentTicksValue().


Member Data Documentation

double resolution [private]

The TSC clock resolution in nano-seconds.

Definition at line 55 of file TSCClock.hh.

Referenced by TSCClock::getResolution(), TSCClock::tick2NanoSecond(), and TSCClock::TSCClock().


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

Generated on Thu Apr 30 15:58:49 2009 for CERTIDeveloperDocumentation by doxygen 1.5.5