sl@0
|
1 |
// Copyright (c) 2005-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\bench\d_kernbm.h
|
sl@0
|
15 |
// Kernel side header containg internal definitions for d_kernasmbm ldd
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
#ifndef __D_KERNBM_H__
|
sl@0
|
20 |
#define __D_KERNBM_H__
|
sl@0
|
21 |
|
sl@0
|
22 |
#include "d_kernasmbm.h"
|
sl@0
|
23 |
|
sl@0
|
24 |
/// Base class for kernel benchmarks
|
sl@0
|
25 |
class TKernelBenchmark
|
sl@0
|
26 |
{
|
sl@0
|
27 |
public:
|
sl@0
|
28 |
const TBmInfo& Info() const;
|
sl@0
|
29 |
virtual TInt Run(const TBmParams& aParams, TInt& aResult);
|
sl@0
|
30 |
protected:
|
sl@0
|
31 |
TKernelBenchmark(const TDesC8& aName);
|
sl@0
|
32 |
TKernelBenchmark(const TDesC8& aName, TInt aAlignStep);
|
sl@0
|
33 |
private:
|
sl@0
|
34 |
virtual void DoRun(const TBmParams& aParams) = 0;
|
sl@0
|
35 |
private:
|
sl@0
|
36 |
TBmInfo iInfo;
|
sl@0
|
37 |
};
|
sl@0
|
38 |
|
sl@0
|
39 |
#define CALL_10_TIMES(x) x; x; x; x; x; x; x; x; x; x
|
sl@0
|
40 |
|
sl@0
|
41 |
/// Macro to define a benchmark
|
sl@0
|
42 |
#define DEFINE_BENCHMARK(name, pre, test, post) \
|
sl@0
|
43 |
_LIT(KName_##name, #name); \
|
sl@0
|
44 |
class TGeneralBenchmark_##name : public TKernelBenchmark \
|
sl@0
|
45 |
{ \
|
sl@0
|
46 |
public: \
|
sl@0
|
47 |
TGeneralBenchmark_##name():TKernelBenchmark(KName_##name){} \
|
sl@0
|
48 |
virtual void DoRun(const TBmParams& aParams) \
|
sl@0
|
49 |
{ \
|
sl@0
|
50 |
TInt its = aParams.iIts; \
|
sl@0
|
51 |
pre; \
|
sl@0
|
52 |
for (TInt j = 0 ; j < its ; ++j) \
|
sl@0
|
53 |
{ \
|
sl@0
|
54 |
CALL_10_TIMES(test); \
|
sl@0
|
55 |
} \
|
sl@0
|
56 |
post; \
|
sl@0
|
57 |
} \
|
sl@0
|
58 |
} Instance_##name
|
sl@0
|
59 |
|
sl@0
|
60 |
/// Macro to define a memory benchmark
|
sl@0
|
61 |
#define DEFINE_MEMORY_BENCHMARK(name, step, srcBase, destBase, pre, test, post) \
|
sl@0
|
62 |
_LIT(KName_##name, #name); \
|
sl@0
|
63 |
class TMemoryBenchmark_##name : public TKernelBenchmark \
|
sl@0
|
64 |
{ \
|
sl@0
|
65 |
public: \
|
sl@0
|
66 |
TMemoryBenchmark_##name(): \
|
sl@0
|
67 |
TKernelBenchmark(KName_##name, step){} \
|
sl@0
|
68 |
virtual void DoRun(const TBmParams& aParams) \
|
sl@0
|
69 |
{ \
|
sl@0
|
70 |
TInt its = aParams.iIts; \
|
sl@0
|
71 |
const TUint8* src = srcBase + aParams.iSourceAlign; \
|
sl@0
|
72 |
TUint8* dest = destBase + aParams.iDestAlign; \
|
sl@0
|
73 |
pre; \
|
sl@0
|
74 |
for (TInt j = 0 ; j < its ; ++j) \
|
sl@0
|
75 |
{ \
|
sl@0
|
76 |
CALL_10_TIMES(test); \
|
sl@0
|
77 |
} \
|
sl@0
|
78 |
post; \
|
sl@0
|
79 |
} \
|
sl@0
|
80 |
} Instance_##name
|
sl@0
|
81 |
|
sl@0
|
82 |
/// Base class for benchmarks using a second thread
|
sl@0
|
83 |
class TThreadedBenchmark : public TKernelBenchmark
|
sl@0
|
84 |
{
|
sl@0
|
85 |
public:
|
sl@0
|
86 |
virtual TInt Run(const TBmParams& aParams, TInt& aResult);
|
sl@0
|
87 |
protected:
|
sl@0
|
88 |
TThreadedBenchmark(const TDesC8& aName, TInt aRelPri);
|
sl@0
|
89 |
private:
|
sl@0
|
90 |
static TInt Thread2Func(TAny *aPtr);
|
sl@0
|
91 |
virtual void DoRun2(TInt aIts) = 0;
|
sl@0
|
92 |
protected:
|
sl@0
|
93 |
DThread* iThread1;
|
sl@0
|
94 |
DThread* iThread2;
|
sl@0
|
95 |
private:
|
sl@0
|
96 |
TInt iRelPri;
|
sl@0
|
97 |
TInt iIts;
|
sl@0
|
98 |
};
|
sl@0
|
99 |
|
sl@0
|
100 |
/// Macro to define a thread benchmark easily
|
sl@0
|
101 |
#define DEFINE_THREADED_BENCHMARK(name, relPri, pre, test1, test2, post) \
|
sl@0
|
102 |
_LIT(KName_##name, #name); \
|
sl@0
|
103 |
class TKernelBenchmark_##name : public TThreadedBenchmark \
|
sl@0
|
104 |
{ \
|
sl@0
|
105 |
public: \
|
sl@0
|
106 |
TKernelBenchmark_##name():TThreadedBenchmark(KName_##name, relPri){} \
|
sl@0
|
107 |
virtual void DoRun(const TBmParams& aParams) \
|
sl@0
|
108 |
{ \
|
sl@0
|
109 |
TInt its = aParams.iIts; \
|
sl@0
|
110 |
pre; \
|
sl@0
|
111 |
for (TInt j = 0 ; j < its*10 ; ++j) \
|
sl@0
|
112 |
{ \
|
sl@0
|
113 |
test1; \
|
sl@0
|
114 |
} \
|
sl@0
|
115 |
post; \
|
sl@0
|
116 |
} \
|
sl@0
|
117 |
virtual void DoRun2(TInt aIts) \
|
sl@0
|
118 |
{ \
|
sl@0
|
119 |
for (TInt j = 0 ; j < aIts*10 ; ++j) \
|
sl@0
|
120 |
{ \
|
sl@0
|
121 |
test2; \
|
sl@0
|
122 |
} \
|
sl@0
|
123 |
} \
|
sl@0
|
124 |
} Instance_##name
|
sl@0
|
125 |
|
sl@0
|
126 |
/// Initialise data used by benchmarks
|
sl@0
|
127 |
TInt InitData();
|
sl@0
|
128 |
|
sl@0
|
129 |
/// Clean up data used by benchmarks
|
sl@0
|
130 |
void CloseData();
|
sl@0
|
131 |
|
sl@0
|
132 |
/// Pointer to user-side buffer, needed by some tests
|
sl@0
|
133 |
extern TUint8* UserPtr;
|
sl@0
|
134 |
|
sl@0
|
135 |
/// List of defined benchmarks
|
sl@0
|
136 |
extern RPointerArray<TKernelBenchmark> KernelBenchmarks;
|
sl@0
|
137 |
|
sl@0
|
138 |
/// Macro to 32-byte align addresses
|
sl@0
|
139 |
#define ALIGN_ADDR(a) ((TAny*)((((TInt)a) & ~0x1f) + 0x20))
|
sl@0
|
140 |
|
sl@0
|
141 |
#endif
|