Classes | Typedefs
Time measurement

Classes

struct  blaze::timing::CpuPolicy
 Timing policy for the measurement of the CPU time.The CpuPolicy class represents the timing policy for CPU time measurements that can be used in combination with the Timer class template. This combination is realized with the CpuTimer type definition. More...
 
class  blaze::timing::Timer< TP >
 Progress timer for time and performance measurements.The Timer class offers timing & benchmarking functionality for all kinds of applications. The following example code demonstrates the use of the WcTimer class, which combines the Timer class template with the WcPolicy for wall clock time measurements, for a single time measurement: More...
 
struct  blaze::timing::WcPolicy
 Timing policy for the measurement of the wall clock time.The WcPolicy class represents the timing policy for wall clock time measurements that can be used in combination with the Timer class template. This combination is realized with the WcTimer type definition. More...
 

Typedefs

typedef Timer< CpuPolicy > blaze::timing::CpuTimer
 Progress timer for CPU time measurements.The CpuTimer combines the Timer class template with the CpuPolicy timing policy. It measures the amount of time the measured program or code fragment uses in processing central processing unit (CPU) instructions.
 
typedef Timer< WcPolicy > blaze::timing::WcTimer
 Progress timer for wall clock time measurements.The WcTimer combines the Timer class template with the WcPolicy timing policy. It measures the amount of "wall clock" time elapsing for the processing of a programm or code fragment. In contrast to the measurement of CPU time, the wall clock time also contains waiting times such as input/output operations.
 

Detailed Description

clock.png

The timing submodule offers the necessary functionality for timing and benchmarking purposes. The central element of the timing module is the Timer class. Depending on a chosen timing policy, this class offers the possibility to measure both single times and time series. In order to make time measurement as easy as possible, the Blaze library offers the two classes WcTimer and CpuTimer (both using the Timer class) to measure both wall clock and CPU time. The following example gives an impression on how time measurement for a single time works with the the Blaze library. Note that in this example the WcTimer could be easily replaced with the CpuTimer if instead of the wall clock time the CPU time was to be measured.

// Creating a new wall clock timer immediately starts a new time measurement
WcTimer timer;
... // Programm or code fragment to be measured
// Stopping the time measurement
timer.end();
// Evaluation of the measured time
double time = timer.last();

As already mentioned, it is also possible to start several time measurements with a single timer to evaluate for instance the minimal, the maximal or the average time of a specific task. The next example demonstrates a possible setup for such a series of time measurements:

// Creating a new wall clock timer
WcTimer timer;
... // Additional setup code
// Starting 10 wall clock time measurements
for( unsigned int i=0; i<10; ++i ) {
timer.start();
... // Programm or code fragment to be measured
timer.end();
}
// After the measurements, the desired timing results can be calculated, as for instance the
// average wall clock time
double average = timer.average();