sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test/defrag/perf/t_perf.h sl@0: // sl@0: // sl@0: sl@0: #ifndef _DEFRAG_PERF_T_PERF_H_ sl@0: #define _DEFRAG_PERF_T_PERF_H_ sl@0: sl@0: #include "t_testdll.h" sl@0: #include "..\d_pagemove.h" sl@0: sl@0: typedef TUint32 DTime_t; sl@0: //#define EXTRA_TRACE sl@0: sl@0: #ifdef EXTRA_TRACE sl@0: #define TEST_PRINTF(x...) test.Printf(x) sl@0: #else sl@0: #define TEST_PRINTF(x...) sl@0: #endif sl@0: sl@0: #define MAXCHUNK_SIZE (40 * 1024 * 1024) sl@0: #define MINCHUNK_SIZE (2 * 1024 * 1024) sl@0: sl@0: sl@0: extern TInt TestDLLPerformance(TInt aNum); sl@0: class DefragLatency sl@0: { sl@0: public: sl@0: DefragLatency() sl@0: { sl@0: iIterations = iCummulative = iResult = 0; sl@0: iMaxTime = (DTime_t)0; sl@0: iMinTime = (DTime_t) -1; sl@0: iCalDelay = 0; sl@0: } sl@0: ~DefragLatency() {} sl@0: sl@0: void CalibrateTimer(RTest& test); sl@0: sl@0: private: sl@0: static inline TUint32 GetFastCounter(void) sl@0: { sl@0: return User::FastCounter(); sl@0: } sl@0: public: sl@0: sl@0: /** Log the new time diff and update iMaxTime and iMinTime appropriately sl@0: */ sl@0: inline void AddIteration(DTime_t aTimeDiff) sl@0: { sl@0: iTime1 = 0; sl@0: iTime2 = 0; sl@0: sl@0: if (aTimeDiff > iMaxTime) sl@0: iMaxTime = aTimeDiff; sl@0: sl@0: if (aTimeDiff < iMinTime) sl@0: iMinTime = aTimeDiff; sl@0: sl@0: iCummulative += aTimeDiff; sl@0: iIterations++; sl@0: } sl@0: sl@0: inline void StartTimer(void) sl@0: { sl@0: iTime1 = GetFastCounter(); sl@0: } sl@0: sl@0: inline TUint32 StopTimer(RTest& aTest) sl@0: { sl@0: iTime2 = GetFastCounter(); sl@0: TUint32 diff = iTime2 - iTime1; sl@0: if (iTime2 < iTime1) sl@0: { sl@0: aTest.Printf(_L("WARNING - Fast Counter rolled over. Assuming only once and continuing\n")); sl@0: diff = (KMaxTUint32 - iTime1) + iTime2; sl@0: } sl@0: AddIteration(diff); sl@0: return diff; sl@0: } sl@0: sl@0: DTime_t GetResult(DTime_t& aMax, DTime_t& aMin, DTime_t& aDelay) sl@0: { sl@0: iResult = (iCummulative / iIterations); sl@0: aMax = iMaxTime; sl@0: aMin = iMinTime; sl@0: aDelay = iCalDelay; sl@0: return iResult; sl@0: } sl@0: sl@0: sl@0: TInt iFastCounterFreq; sl@0: private: sl@0: int iIterations; sl@0: DTime_t iCalDelay; sl@0: DTime_t iTime1, iTime2; sl@0: DTime_t iMaxTime, iMinTime; sl@0: DTime_t iCummulative; sl@0: DTime_t iResult; sl@0: }; sl@0: sl@0: sl@0: class DllDefrag sl@0: { sl@0: public: sl@0: DllDefrag() sl@0: { sl@0: iFunc0Addr = (TInt8 *)(-1); sl@0: iFuncNAddr = (TInt8 *)0; sl@0: iLib = new RLibrary; sl@0: } sl@0: ~DllDefrag() sl@0: { sl@0: delete iLib; sl@0: } sl@0: TInt LoadTheLib(TInt aIdx, RTest& aTest); sl@0: TInt TestDLLPerformance(TInt aNum, RPageMove& aPageMove, RTest& aTest); sl@0: public: sl@0: RLibrary *iLib; sl@0: TInt8 *iFunc0Addr; sl@0: TInt8 *iFuncNAddr; sl@0: }; sl@0: sl@0: #endif // _DEFRAG_PERF_T_PERF_H_ sl@0: