Update contrib.
1 // Copyright (c) 2005-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\bench\d_kernbm.h
15 // Kernel side header containg internal definitions for d_kernasmbm ldd
19 #ifndef __D_KERNBM_H__
20 #define __D_KERNBM_H__
22 #include "d_kernasmbm.h"
24 /// Base class for kernel benchmarks
25 class TKernelBenchmark
28 const TBmInfo& Info() const;
29 virtual TInt Run(const TBmParams& aParams, TInt& aResult);
31 TKernelBenchmark(const TDesC8& aName);
32 TKernelBenchmark(const TDesC8& aName, TInt aAlignStep);
34 virtual void DoRun(const TBmParams& aParams) = 0;
39 #define CALL_10_TIMES(x) x; x; x; x; x; x; x; x; x; x
41 /// Macro to define a benchmark
42 #define DEFINE_BENCHMARK(name, pre, test, post) \
43 _LIT(KName_##name, #name); \
44 class TGeneralBenchmark_##name : public TKernelBenchmark \
47 TGeneralBenchmark_##name():TKernelBenchmark(KName_##name){} \
48 virtual void DoRun(const TBmParams& aParams) \
50 TInt its = aParams.iIts; \
52 for (TInt j = 0 ; j < its ; ++j) \
54 CALL_10_TIMES(test); \
60 /// Macro to define a memory benchmark
61 #define DEFINE_MEMORY_BENCHMARK(name, step, srcBase, destBase, pre, test, post) \
62 _LIT(KName_##name, #name); \
63 class TMemoryBenchmark_##name : public TKernelBenchmark \
66 TMemoryBenchmark_##name(): \
67 TKernelBenchmark(KName_##name, step){} \
68 virtual void DoRun(const TBmParams& aParams) \
70 TInt its = aParams.iIts; \
71 const TUint8* src = srcBase + aParams.iSourceAlign; \
72 TUint8* dest = destBase + aParams.iDestAlign; \
74 for (TInt j = 0 ; j < its ; ++j) \
76 CALL_10_TIMES(test); \
82 /// Base class for benchmarks using a second thread
83 class TThreadedBenchmark : public TKernelBenchmark
86 virtual TInt Run(const TBmParams& aParams, TInt& aResult);
88 TThreadedBenchmark(const TDesC8& aName, TInt aRelPri);
90 static TInt Thread2Func(TAny *aPtr);
91 virtual void DoRun2(TInt aIts) = 0;
100 /// Macro to define a thread benchmark easily
101 #define DEFINE_THREADED_BENCHMARK(name, relPri, pre, test1, test2, post) \
102 _LIT(KName_##name, #name); \
103 class TKernelBenchmark_##name : public TThreadedBenchmark \
106 TKernelBenchmark_##name():TThreadedBenchmark(KName_##name, relPri){} \
107 virtual void DoRun(const TBmParams& aParams) \
109 TInt its = aParams.iIts; \
111 for (TInt j = 0 ; j < its*10 ; ++j) \
117 virtual void DoRun2(TInt aIts) \
119 for (TInt j = 0 ; j < aIts*10 ; ++j) \
126 /// Initialise data used by benchmarks
129 /// Clean up data used by benchmarks
132 /// Pointer to user-side buffer, needed by some tests
133 extern TUint8* UserPtr;
135 /// List of defined benchmarks
136 extern RPointerArray<TKernelBenchmark> KernelBenchmarks;
138 /// Macro to 32-byte align addresses
139 #define ALIGN_ADDR(a) ((TAny*)((((TInt)a) & ~0x1f) + 0x20))