os/kernelhwsrv/kerneltest/e32test/defrag/perf/t_perf.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32test/defrag/perf/t_perf.h
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#ifndef _DEFRAG_PERF_T_PERF_H_
sl@0
    19
#define _DEFRAG_PERF_T_PERF_H_
sl@0
    20
sl@0
    21
#include "t_testdll.h"
sl@0
    22
#include "..\d_pagemove.h"
sl@0
    23
sl@0
    24
typedef TUint32 DTime_t;
sl@0
    25
//#define EXTRA_TRACE
sl@0
    26
sl@0
    27
#ifdef EXTRA_TRACE
sl@0
    28
#define TEST_PRINTF(x...) test.Printf(x)
sl@0
    29
#else
sl@0
    30
#define TEST_PRINTF(x...)
sl@0
    31
#endif
sl@0
    32
sl@0
    33
#define MAXCHUNK_SIZE (40 * 1024 * 1024)
sl@0
    34
#define MINCHUNK_SIZE (2 * 1024 * 1024)
sl@0
    35
sl@0
    36
sl@0
    37
extern TInt TestDLLPerformance(TInt aNum); 
sl@0
    38
class DefragLatency 
sl@0
    39
{
sl@0
    40
public:
sl@0
    41
	DefragLatency()
sl@0
    42
		{
sl@0
    43
		iIterations = iCummulative = iResult = 0;
sl@0
    44
		iMaxTime = (DTime_t)0;
sl@0
    45
		iMinTime = (DTime_t) -1;
sl@0
    46
		iCalDelay = 0;
sl@0
    47
		}
sl@0
    48
	~DefragLatency() {}
sl@0
    49
sl@0
    50
	void CalibrateTimer(RTest& test);
sl@0
    51
sl@0
    52
private:
sl@0
    53
	static inline TUint32 GetFastCounter(void)
sl@0
    54
		{
sl@0
    55
		return User::FastCounter();
sl@0
    56
		}
sl@0
    57
public:
sl@0
    58
	
sl@0
    59
	/** Log the new time diff and update iMaxTime and iMinTime appropriately
sl@0
    60
	*/
sl@0
    61
	inline void AddIteration(DTime_t aTimeDiff)
sl@0
    62
		{
sl@0
    63
		iTime1 = 0;
sl@0
    64
		iTime2 = 0;
sl@0
    65
sl@0
    66
		if (aTimeDiff > iMaxTime)
sl@0
    67
			iMaxTime = aTimeDiff;
sl@0
    68
sl@0
    69
		if (aTimeDiff < iMinTime)
sl@0
    70
			iMinTime = aTimeDiff;
sl@0
    71
sl@0
    72
		iCummulative += aTimeDiff;
sl@0
    73
		iIterations++;
sl@0
    74
		}
sl@0
    75
sl@0
    76
	inline void StartTimer(void)
sl@0
    77
		{
sl@0
    78
		iTime1 = GetFastCounter();
sl@0
    79
		}
sl@0
    80
sl@0
    81
	inline TUint32 StopTimer(RTest& aTest)
sl@0
    82
		{
sl@0
    83
		iTime2 = GetFastCounter();
sl@0
    84
		TUint32 diff = iTime2 - iTime1;
sl@0
    85
		if (iTime2 < iTime1)
sl@0
    86
			{
sl@0
    87
			aTest.Printf(_L("WARNING - Fast Counter rolled over.  Assuming only once and continuing\n"));
sl@0
    88
			diff = (KMaxTUint32 - iTime1) + iTime2;
sl@0
    89
			}
sl@0
    90
		AddIteration(diff);
sl@0
    91
		return diff;
sl@0
    92
		}
sl@0
    93
						
sl@0
    94
	DTime_t GetResult(DTime_t& aMax, DTime_t& aMin, DTime_t& aDelay)
sl@0
    95
		{
sl@0
    96
		iResult = (iCummulative / iIterations);
sl@0
    97
		aMax = iMaxTime;
sl@0
    98
		aMin = iMinTime;
sl@0
    99
		aDelay = iCalDelay;
sl@0
   100
		return iResult;
sl@0
   101
		}
sl@0
   102
sl@0
   103
sl@0
   104
	TInt iFastCounterFreq;
sl@0
   105
private:
sl@0
   106
	int iIterations;
sl@0
   107
	DTime_t iCalDelay;
sl@0
   108
	DTime_t iTime1, iTime2;
sl@0
   109
	DTime_t iMaxTime, iMinTime;
sl@0
   110
	DTime_t iCummulative;
sl@0
   111
	DTime_t iResult;
sl@0
   112
};
sl@0
   113
sl@0
   114
sl@0
   115
class DllDefrag
sl@0
   116
{
sl@0
   117
public:
sl@0
   118
	DllDefrag()
sl@0
   119
		{
sl@0
   120
		iFunc0Addr = (TInt8 *)(-1);
sl@0
   121
		iFuncNAddr = (TInt8 *)0;
sl@0
   122
		iLib = new RLibrary;
sl@0
   123
		}
sl@0
   124
	~DllDefrag()
sl@0
   125
		{
sl@0
   126
		delete iLib;
sl@0
   127
		}
sl@0
   128
	TInt LoadTheLib(TInt aIdx, RTest& aTest);
sl@0
   129
	TInt TestDLLPerformance(TInt aNum, RPageMove& aPageMove, RTest& aTest);
sl@0
   130
public:	
sl@0
   131
	RLibrary *iLib;
sl@0
   132
	TInt8 *iFunc0Addr;
sl@0
   133
	TInt8 *iFuncNAddr;
sl@0
   134
};
sl@0
   135
sl@0
   136
#endif // _DEFRAG_PERF_T_PERF_H_
sl@0
   137