author | William Roberts <williamr@symbian.org> |
Thu, 29 Jul 2010 23:52:13 +0100 | |
branch | GCC_SURGE |
changeset 237 | 2604c9de91e0 |
parent 215 | 8096a832df02 |
permissions | -rw-r--r-- |
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_perfdll.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#define __E32TEST_EXTENSION__ |
|
19 |
#include <e32test.h> |
|
20 |
#include <e32hal.h> |
|
215
8096a832df02
Fix for bug 3322 - Non-portable case-sensitivity and path-delimiter fluff in e32test build
Mike Kinghan <mikek@symbian.org>
parents:
0
diff
changeset
|
21 |
#include "../d_pagemove.h" |
0 | 22 |
#include "t_perf.h" |
23 |
#include "t_testdll.h" |
|
24 |
||
25 |
_LIT(KDllbaseName, "t_defragperf"); |
|
26 |
||
27 |
TPtrC TestPlExtNames = _L(".dll"); |
|
28 |
||
29 |
const TInt KIterations = 50; |
|
30 |
||
31 |
#define MAXDLLS 1 |
|
32 |
||
33 |
||
34 |
#define MINDLL_PAGES (100 * E_SIZE) |
|
35 |
||
36 |
typedef TInt (*TCallFunction)(TUint32 funcIndex, TInt param1, TInt param2); |
|
37 |
||
38 |
TInt DllDefrag::LoadTheLib(TInt aIdx, RTest& test) |
|
39 |
{ |
|
40 |
||
41 |
TBuf<128> nameBuffer; |
|
42 |
TUint32 FuncCount; |
|
43 |
TLibraryFunction InitFunc; |
|
44 |
TLibraryFunction FunctionCountFunc; |
|
45 |
TCallFunction CallFunctionFunc; |
|
46 |
TLibraryFunction SetCloseFunc; |
|
47 |
TLibraryFunction Function0AddrFunc, FunctionNAddrFunc; |
|
48 |
TInt retVal; |
|
49 |
||
50 |
if (iLib == NULL) |
|
51 |
return KErrNoMemory; |
|
52 |
||
53 |
||
54 |
nameBuffer.Format(_L("%S%d%S"), &KDllbaseName, aIdx, &TestPlExtNames); |
|
55 |
||
56 |
/* Load the DLL */ |
|
57 |
TEST_PRINTF(_L("Loading the DLL (%S) ...\n"), &nameBuffer); |
|
58 |
||
59 |
retVal = iLib->Load(nameBuffer); |
|
60 |
||
61 |
if (retVal != KErrNone) |
|
62 |
{ |
|
63 |
test.Printf(_L("Load Failed %S (%d)\n"), &nameBuffer, aIdx); |
|
64 |
return KErrGeneral; |
|
65 |
} |
|
66 |
||
67 |
TEST_PRINTF(_L("Loaded %S (%d)\n"), &nameBuffer, aIdx); |
|
68 |
||
69 |
/* Test that the DLL is loaded correctly */ |
|
70 |
InitFunc = iLib->Lookup(DEFRAGDLL_FUNC_Init); |
|
71 |
FunctionCountFunc = iLib->Lookup(DEFRAGDLL_FUNC_FunctionCount); |
|
72 |
CallFunctionFunc = (TCallFunction)iLib->Lookup(DEFRAGDLL_FUNC_CallFunction); |
|
73 |
SetCloseFunc = iLib->Lookup(DEFRAGDLL_FUNC_SetClose); |
|
74 |
Function0AddrFunc = iLib->Lookup(DEFRAGDLL_FUNC_func0); |
|
75 |
FunctionNAddrFunc = iLib->Lookup(DEFRAGDLL_FUNC_funcN); |
|
76 |
||
77 |
if (InitFunc == NULL || |
|
78 |
FunctionCountFunc == NULL || |
|
79 |
CallFunctionFunc == NULL || |
|
80 |
SetCloseFunc == NULL) |
|
81 |
{ |
|
82 |
return KErrGeneral; |
|
83 |
} |
|
84 |
||
85 |
retVal = (InitFunc)(); |
|
86 |
if (retVal != KErrNone) |
|
87 |
return KErrGeneral; |
|
88 |
||
89 |
FuncCount = (FunctionCountFunc)(); |
|
90 |
if (FuncCount == 0) |
|
91 |
return KErrGeneral; |
|
92 |
||
93 |
iFunc0Addr = (TInt8 *)(Function0AddrFunc)(); |
|
94 |
iFuncNAddr = (TInt8 *)(FunctionNAddrFunc)(); |
|
95 |
||
96 |
TEST_PRINTF(_L("%S:Func0 = %x FuncN = %x\n"), &nameBuffer, iFunc0Addr, iFuncNAddr); |
|
97 |
||
98 |
if (iFunc0Addr == NULL || iFuncNAddr == NULL) |
|
99 |
return KErrGeneral; |
|
100 |
||
101 |
if (iFunc0Addr > iFuncNAddr) |
|
102 |
return KErrGeneral; |
|
103 |
||
104 |
return KErrNone; |
|
105 |
} |
|
106 |
||
107 |
TInt DllDefrag::TestDLLPerformance(TInt aDummy, RPageMove& aPageMove, RTest& test) |
|
108 |
{ |
|
109 |
DefragLatency timer; |
|
110 |
TInt size = iFuncNAddr - iFunc0Addr; |
|
111 |
const TUint8 *end = (TUint8 *)iFunc0Addr + size; |
|
112 |
||
113 |
TInt pageSize; |
|
114 |
TInt r = UserHal::PageSizeInBytes(pageSize); |
|
115 |
test_KErrNone(r); |
|
116 |
TEST_PRINTF(_L("size %x"), size); |
|
117 |
TInt pagesToMove = _ALIGN_UP(size, pageSize) / pageSize; |
|
118 |
// Ensure there is at least one page to move |
|
119 |
test_Compare(size, >=, 1); |
|
120 |
||
121 |
timer.CalibrateTimer(test); |
|
122 |
||
123 |
||
124 |
for (TInt j = 0; j < KIterations; j++) |
|
125 |
{ |
|
126 |
TUint8* base = (TUint8 *)iFunc0Addr; |
|
127 |
||
128 |
timer.StartTimer(); |
|
129 |
while (base < end) |
|
130 |
{ |
|
131 |
test_KErrNone(aPageMove.TryMovingUserPage(base)); |
|
132 |
base += pageSize; |
|
133 |
} |
|
134 |
timer.StopTimer(test); |
|
135 |
} |
|
136 |
||
137 |
DTime_t average, max, min, delay; |
|
138 |
TEST_PRINTF(_L("Finished moving %d dll pages\n"), pagesToMove); |
|
139 |
average = timer.GetResult(max, min, delay); |
|
140 |
test.Printf(_L("Fast counter ticks to move %d dll pages: Av %d Min %d Max %d (Overhead %d)\n"), pagesToMove, average, min, max, delay); |
|
141 |
test.Printf(_L("Average of %d ticks to move one page\n\n"), average / pagesToMove); |
|
142 |
||
143 |
return KErrNone; |
|
144 |
} |
|
145 |
||
146 |