// TimingTestSample.C // Copyright (C) 1995 Taligent, Inc. All rights reserved. #ifndef Taligent_TIMINGTEST #include <Taligent/TimingTest.h> #endif //------------------------------------------------------------------------------ // TDequeAddTimingTest Declaration //------------------------------------------------------------------------------ class TDequeAddTimingTest : public TTimingTest { public: TDequeAddTimingTest(); virtual ~TDequeAddTimingTest(); MCollectibleDeclarationsMacro(TDequeAddTimingTest); protected: virtual void TimingSetup(); virtual void TimingTest(); virtual void TimingCleanup(); private: TCollectibleLong **fObject; // Array of pointers to objects to be added long fObjectArraySize; // Number of items in fObject TCollectibleLong **fNextObject; // Pointer to next pointer to add TDequeOf<TCollectibleLong> fDeque; // Deque to add to }; //------------------------------------------------------------------------------ // TDequeAddTimingTest member functions //------------------------------------------------------------------------------ TDequeAddTimingTest::TDequeAddTimingTest() { fObject = NULL; fObjectArraySize = 0; } TDequeAddTimingTest::~TDequeAddTimingTest() { TimingCleanup(); // Just in case TimingSetup was called without TimingCleanup } MCollectibleDefinitionsMacro(TDequeAddTimingTest,0); void TDequeAddTimingTest::TimingSetup() { TAllocationHeap heap(this); TimingCleanup(); // Just in case TimingSetup was called without TimingCleanup // GetTimingCount gets the number of times that TimingTest will be called (Default timing count is 100) fObjectArraySize = GetTimingCount(); fObject = new(heap) TCollectibleLong*[fObjectArraySize]; for (long i=0; i<fObjectArraySize; i++) fObject[i] = new(heap) TCollectibleLong; fNextObject = &fObject[0]; } void TDequeAddTimingTest::TimingTest() { // This is the only part of the test that is timed fDeque.Add(*fNextObject++); } void TDequeAddTimingTest::TimingCleanup() { fDeque.RemoveAll(); if (fObject != NULL) { for (long i=0; i<fObjectArraySize; i++) delete fObject[i]; delete[] fObject; fObject = NULL; } }
Test TDequeAddTimingTest ( Pass ) {time 44 +/- 4 us}