An Abstract base class that represents the tests that measure the median and time required to execute a well-defined operation. It is the main class used to measure CPU performance.
Instead of the usual setup, test, and cleanup framework methods, ITimingTest has timingSetup, timingTest, and timingCleanup framework methods. These methods behave somewhat differently from their namesakes. Subclasses place the code to be timed in timingTest. The methods timingSetup and timingCleanup allow subclasses to do any setup and cleanup for the timingTest method; code in these methods is NOT timed.
The ITimingTest base class enables you to write tests that measure the time taken by a specific operation to complete. The derived class IStartStopTimingTest allows you more control in timing events.
ITimingTest expects the operation to show some variation in execution time due to multitasking, varying CPU load, and other variable conditions. Consequently, the class takes multiple measurements and reports the median.
ITimingTest measures the time needed to execute the TimingTest member function. It does this by taking some number of samples, the "sample count". Each sample consists of a call to TimingSetup, some number of calls to TimingTest, and a call to TimingCleanup.
The calls to TimingTest happen in a tight loop, the "timing loop". Derived classes, or the caller through a RunTest option, can control how many iterations comprise the timing loop by changing the "timing count". The total time taken by the timing loop is divided by the number of iterations to get a single "sample time". The median of all sample times is taken as the estimate of the time to execute the TimingTest member function.
To create a timed test, do the following:
The default settings are as follows:
kDefaultTimingCount = 500,
kDefaultSampleCount = 10,
kDefaultMaximumSampleWindows = 10
kDefaultAutomaticSamplingTolerance = 0.1
kDefaultMinimumCorrelation = .4
Constructors & DestructorClass constructors and destructors.
![]() |
public:
virtual ~ITimingTest()
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
ITimingTest(const ITimingTest& source)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
protected:
ITimingTest( unsigned long timingCount, unsigned long sampleCount )
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
protected:
ITimingTest()
Constructs an ITimingTest specifying a timing count, sample count, maximum sample count, minimum correlation, and an automatic sample tolerance. The default values are:
kDefaultTimingCount = 500,
kDefaultSampleCount = 10,
kDefaultMaximumSampleWindows = 10
kDefaultAutomaticSamplingTolerance = 0.1
kDefaultMinimumCorrelation = .4
automatic sampling ON
no maximum allowed median time
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
Advanced Subclass Specialization MethodsAdvanced timing member functions. These should only be used by those users with a good understanding of the timing tests.
![]() |
protected:
virtual void doUntimedTest()
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual double oneEmptySample()
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual double oneSample()
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual double samplingErrorMicroseconds() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
Assignment OperatorUse this operator to assign an ITimingTest class to another.
![]() |
public:
ITimingTest& operator =(const ITimingTest& rhs)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
Automatic Sampling MethodsMember functions used to configure the automatic timing sampling.
![]() |
public:
double automaticSampleTolerance() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
bool automaticSampling() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
unsigned long maximumSampleWindows() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
double minimumSampleCorrelation() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
void setAutomaticSampleTolerance(double tolerance)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
void setAutomaticSampling(bool doAutomaticSampling)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
void setMaximumSampleWindows(unsigned long maxWindows)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
void setMinimumSampleCorrelation(double minSampleCorr)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
static const double kDefaultAutomaticSamplingTolerance
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
static const double kDefaultMinimumCorrelation
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
Timing MethodsClass member functions used to control and perform the timing tests.
![]() |
public:
void calibrate()
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
double calibratedMeanMicroseconds()
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
double calibratedMedianMicroseconds()
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
double clockNowOverhead() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
bool continualCalibration() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
void copySamples(long& count, double *&) const
Note: The caller owns its storage for the elements in the array.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
double correlationMicroseconds() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
bool correlationTooLarge() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
double errorMicroseconds() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
bool errorTooLarge() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
double maximumAllowedMedianMicroseconds() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
double relativeErrorMicroseconds() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
unsigned long sampleCount() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
unsigned long samplesDiscarded() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
unsigned long samplesTaken() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
void setContinualCalibration(bool continuallyCalibrate)
Continual calibration is off by default under the assumption that the empty method time is relatively constant. If the client or subclass is varying the load, then continual calibration may provide more accurate timing results.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
void setMaximumAllowedMedianMicroseconds(double timeLimit)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
void setSampleCount(unsigned long sampleCount)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
void setTimingCount(unsigned long timingCount)
Note: This timing count also applies to the calibration method.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
void setTimingOn(bool timingOn)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
unsigned long timingCount() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
bool timingOn() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual void cleanup()
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual void print(ITieredTextBuffer& out)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual void setup()
The test should override this function to execute any setup code that only needs to be called once.
It is also a good place to parse command line arguments. If this method is overridden it must call the parent ITimingTest::setup method.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual void test()
Note: Do NOT override this method!
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual void timingCleanup()
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual void timingSetup()
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
protected:
virtual void timingTest() = 0
For each timing sample, ITimingTest calls timingSetup once, followed by timingCount calls to timingTest, followed by a call to timingCleanup. The loop of calls to timingTest is timed, and this time is divided by timingCount to get the uncalibrated sample time. The median empty time is subtracted from this to get the calibrated sample time.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
Miscellaneous Members![]() |
public:
virtual void copyInfo()
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
enum { kDefaultTimingCount=500,
kDefaultSampleCount=10,
kDefaultMaximumSampleWindows=10 }| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
virtual ~ITest()
void copyInputs(int& argc, char * *& argv) const
virtual EStage exceptionStage() const
virtual bool lookupInfo(const IString& key, IString& info)
ITest& operator =(const ITest& test)
ITieredTextBuffer& outputTextStream()
virtual void run()
virtual unsigned long runCount() const
void setInputs(const int argc, const char * const* argv)
bool success() const
static const IString& kComponentKey
static const IString & _Import kComponentKey
static const IString & _Import kDescriptionKey
static const IString& kDescriptionKey
static const IString& kInputSyntaxKey
static const IString & _Import kInputSyntaxKey
static const IString& kTargetClassKey
static const IString & _Import kTargetClassKey
static const IString& kTestNameKey
static const IString & _Import kTestNameKey
static const IString & _Import kTestTypeKey
static const IString& kTestTypeKey
static const IString& kTestVersionKey
static const IString & _Import kTestVersionKey
virtual void addInfo(const IString&, const IString&)
virtual bool isReset() const
virtual bool isSuccessUndecided() const
ITest()
ITest(const ITest& test)
virtual void print(ITieredTextBuffer&)
virtual void reset()
virtual void setStickySuccess(bool success)
virtual void setSuccess(bool success)
virtual void test() = 0