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