os/kernelhwsrv/kerneltest/e32test/defrag/perf/t_perf.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/defrag/perf/t_perf.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,137 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32test/defrag/perf/t_perf.h
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#ifndef _DEFRAG_PERF_T_PERF_H_
    1.22 +#define _DEFRAG_PERF_T_PERF_H_
    1.23 +
    1.24 +#include "t_testdll.h"
    1.25 +#include "..\d_pagemove.h"
    1.26 +
    1.27 +typedef TUint32 DTime_t;
    1.28 +//#define EXTRA_TRACE
    1.29 +
    1.30 +#ifdef EXTRA_TRACE
    1.31 +#define TEST_PRINTF(x...) test.Printf(x)
    1.32 +#else
    1.33 +#define TEST_PRINTF(x...)
    1.34 +#endif
    1.35 +
    1.36 +#define MAXCHUNK_SIZE (40 * 1024 * 1024)
    1.37 +#define MINCHUNK_SIZE (2 * 1024 * 1024)
    1.38 +
    1.39 +
    1.40 +extern TInt TestDLLPerformance(TInt aNum); 
    1.41 +class DefragLatency 
    1.42 +{
    1.43 +public:
    1.44 +	DefragLatency()
    1.45 +		{
    1.46 +		iIterations = iCummulative = iResult = 0;
    1.47 +		iMaxTime = (DTime_t)0;
    1.48 +		iMinTime = (DTime_t) -1;
    1.49 +		iCalDelay = 0;
    1.50 +		}
    1.51 +	~DefragLatency() {}
    1.52 +
    1.53 +	void CalibrateTimer(RTest& test);
    1.54 +
    1.55 +private:
    1.56 +	static inline TUint32 GetFastCounter(void)
    1.57 +		{
    1.58 +		return User::FastCounter();
    1.59 +		}
    1.60 +public:
    1.61 +	
    1.62 +	/** Log the new time diff and update iMaxTime and iMinTime appropriately
    1.63 +	*/
    1.64 +	inline void AddIteration(DTime_t aTimeDiff)
    1.65 +		{
    1.66 +		iTime1 = 0;
    1.67 +		iTime2 = 0;
    1.68 +
    1.69 +		if (aTimeDiff > iMaxTime)
    1.70 +			iMaxTime = aTimeDiff;
    1.71 +
    1.72 +		if (aTimeDiff < iMinTime)
    1.73 +			iMinTime = aTimeDiff;
    1.74 +
    1.75 +		iCummulative += aTimeDiff;
    1.76 +		iIterations++;
    1.77 +		}
    1.78 +
    1.79 +	inline void StartTimer(void)
    1.80 +		{
    1.81 +		iTime1 = GetFastCounter();
    1.82 +		}
    1.83 +
    1.84 +	inline TUint32 StopTimer(RTest& aTest)
    1.85 +		{
    1.86 +		iTime2 = GetFastCounter();
    1.87 +		TUint32 diff = iTime2 - iTime1;
    1.88 +		if (iTime2 < iTime1)
    1.89 +			{
    1.90 +			aTest.Printf(_L("WARNING - Fast Counter rolled over.  Assuming only once and continuing\n"));
    1.91 +			diff = (KMaxTUint32 - iTime1) + iTime2;
    1.92 +			}
    1.93 +		AddIteration(diff);
    1.94 +		return diff;
    1.95 +		}
    1.96 +						
    1.97 +	DTime_t GetResult(DTime_t& aMax, DTime_t& aMin, DTime_t& aDelay)
    1.98 +		{
    1.99 +		iResult = (iCummulative / iIterations);
   1.100 +		aMax = iMaxTime;
   1.101 +		aMin = iMinTime;
   1.102 +		aDelay = iCalDelay;
   1.103 +		return iResult;
   1.104 +		}
   1.105 +
   1.106 +
   1.107 +	TInt iFastCounterFreq;
   1.108 +private:
   1.109 +	int iIterations;
   1.110 +	DTime_t iCalDelay;
   1.111 +	DTime_t iTime1, iTime2;
   1.112 +	DTime_t iMaxTime, iMinTime;
   1.113 +	DTime_t iCummulative;
   1.114 +	DTime_t iResult;
   1.115 +};
   1.116 +
   1.117 +
   1.118 +class DllDefrag
   1.119 +{
   1.120 +public:
   1.121 +	DllDefrag()
   1.122 +		{
   1.123 +		iFunc0Addr = (TInt8 *)(-1);
   1.124 +		iFuncNAddr = (TInt8 *)0;
   1.125 +		iLib = new RLibrary;
   1.126 +		}
   1.127 +	~DllDefrag()
   1.128 +		{
   1.129 +		delete iLib;
   1.130 +		}
   1.131 +	TInt LoadTheLib(TInt aIdx, RTest& aTest);
   1.132 +	TInt TestDLLPerformance(TInt aNum, RPageMove& aPageMove, RTest& aTest);
   1.133 +public:	
   1.134 +	RLibrary *iLib;
   1.135 +	TInt8 *iFunc0Addr;
   1.136 +	TInt8 *iFuncNAddr;
   1.137 +};
   1.138 +
   1.139 +#endif // _DEFRAG_PERF_T_PERF_H_
   1.140 +