performance_counter Class Reference
[Performance Library]

#include <winstl/performance/performance_counter.hpp>

List of all members.


Detailed Description

A performance counter that uses the most accurate measurement APIs available on the host machine.

The following example illustrates the use of the counter to measure an interval:

winstl::performance_counter   counter;

counter.start();
for(volatile size_t i = 0; i != 0x7fffffff; ++i)
counter.stop();

std::cout << "Number of seconds:      " << counter.get_seconds() << std::endl;
std::cout << "Number of milliseconds: " << counter.get_milliseconds() << std::endl;
std::cout << "Number of microseconds: " << counter.get_microseconds() << std::endl;

Note: Some standard libraries' IOStreams do not recognise the 64-bit unsigned integer that is the counter class's interval_type (and epoch_type), in which case you should use an appropriate cast. The following code shows a cast to unsigned long, but be aware that this may cause truncation in the case where, say, the unsigned long type for your compiler is 32-bits and the value returned by a given get_???() method is > 4294967295.

winstl::performance_counter   counter;

counter.start();
for(volatile size_t i = 0; i != 0x7fffffff; ++i)
counter.stop();

std::cout << "Number of seconds:      " << static_cast<unsigned long>(counter.get_seconds()) << std::endl;
std::cout << "Number of milliseconds: " << static_cast<unsigned long>(counter.get_milliseconds()) << std::endl;
std::cout << "Number of microseconds: " << static_cast<unsigned long>(counter.get_microseconds()) << std::endl;

Remarks:
This class attempts to use the high performance hardware counter as its measurement resource, but failing that it defaults to less accurate resources in order to guarantee that meaningful measurements are always available to application code.

Attributes

interval_type get_period_count () const
 The elapsed count in the measurement period.
interval_type get_seconds () const
 The number of whole seconds in the measurement period.
interval_type get_milliseconds () const
 The number of whole milliseconds in the measurement period.
interval_type get_microseconds () const
 The number of whole microseconds in the measurement period.
interval_type stop_get_period_count_and_restart ()
 Stops the current period, starts the next, and returns the period count for the prior period.
interval_type stop_get_seconds_and_restart ()
 Stops the current period, starts the next, and returns the interval, in seconds, for the prior period.
interval_type stop_get_milliseconds_and_restart ()
 Stops the current period, starts the next, and returns the interval, in milliseconds, for the prior period.
interval_type stop_get_microseconds_and_restart ()
 Stops the current period, starts the next, and returns the interval, in microseconds, for the prior period.
static epoch_type get_epoch ()
 The current epoch.
static interval_type get_seconds (epoch_type start, epoch_type end)
 The number of whole seconds in the given measurement period.
static interval_type get_milliseconds (epoch_type start, epoch_type end)
 The number of whole milliseconds in the given measurement period.
static interval_type get_microseconds (epoch_type start, epoch_type end)
 The number of whole microseconds in the given measurement period.

Public Types

Member types
typedef sinteger64 epoch_type
 The epoch type.
typedef sinteger64 interval_type
 The interval type.
typedef performance_counter class_type
 The class type.

Public Member Functions

Operations
void start ()
 Starts measurement.
void stop ()
 Ends measurement.
void restart ()
 Ends the current measurement period and start the next.

Member Typedef Documentation

typedef sinteger64 epoch_type

The epoch type.

The type of the epoch measurement. This will be a 64-bit signed integer for compilers that such types, or a 32-bit integer otherwise.

typedef sinteger64 interval_type

The interval type.

The type of the interval measurement. This will be a 64-bit signed integer for compilers that such types, or a 32-bit integer otherwise.

The class type.


Member Function Documentation

void start (  ) 

Starts measurement.

Begins the measurement period

void stop (  ) 

Ends measurement.

Ends the measurement period

void restart (  ) 

Ends the current measurement period and start the next.

Remarks:
This is equivalent to an atomic invocation of stop() and start()

static epoch_type get_epoch (  )  [static]

The current epoch.

static interval_type get_seconds ( epoch_type  start,
epoch_type  end 
) [static]

The number of whole seconds in the given measurement period.

static interval_type get_milliseconds ( epoch_type  start,
epoch_type  end 
) [static]

The number of whole milliseconds in the given measurement period.

static interval_type get_microseconds ( epoch_type  start,
epoch_type  end 
) [static]

The number of whole microseconds in the given measurement period.

interval_type get_period_count (  )  const

The elapsed count in the measurement period.

This represents the extent, in machine-specific increments, of the measurement period

interval_type get_seconds (  )  const

The number of whole seconds in the measurement period.

This represents the extent, in whole seconds, of the measurement period

interval_type get_milliseconds (  )  const

The number of whole milliseconds in the measurement period.

This represents the extent, in whole milliseconds, of the measurement period

interval_type get_microseconds (  )  const

The number of whole microseconds in the measurement period.

This represents the extent, in whole microseconds, of the measurement period

interval_type stop_get_period_count_and_restart (  ) 

Stops the current period, starts the next, and returns the period count for the prior period.

interval_type stop_get_seconds_and_restart (  ) 

Stops the current period, starts the next, and returns the interval, in seconds, for the prior period.

interval_type stop_get_milliseconds_and_restart (  ) 

Stops the current period, starts the next, and returns the interval, in milliseconds, for the prior period.

interval_type stop_get_microseconds_and_restart (  ) 

Stops the current period, starts the next, and returns the interval, in microseconds, for the prior period.


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

Generated on Thu Jun 10 08:59:32 2010 for STLSoft by  doxygen 1.5.6