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\t_userbm.h
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#ifndef __T_USERBM_H__
|
sl@0
|
19 |
#define __T_USERBM_H__
|
sl@0
|
20 |
|
sl@0
|
21 |
#include "t_asmbm.h"
|
sl@0
|
22 |
#include <e32std.h>
|
sl@0
|
23 |
|
sl@0
|
24 |
/// Base class for user benchmarks
|
sl@0
|
25 |
class TUserBenchmark : public TBmInfo
|
sl@0
|
26 |
{
|
sl@0
|
27 |
public:
|
sl@0
|
28 |
virtual void Run(TInt aIts) = 0;
|
sl@0
|
29 |
protected:
|
sl@0
|
30 |
TUserBenchmark(const TDesC8& aName, TUint aCategory);
|
sl@0
|
31 |
};
|
sl@0
|
32 |
|
sl@0
|
33 |
class TUserBenchmarkList : public MBenchmarkList
|
sl@0
|
34 |
{
|
sl@0
|
35 |
virtual TInt Count();
|
sl@0
|
36 |
virtual TInt Info(TInt aIndex, TBmInfo& aInfoOut);
|
sl@0
|
37 |
virtual TInt Run(TInt aIndex, const TBmParams& aParams, TInt& aDeltaOut);
|
sl@0
|
38 |
};
|
sl@0
|
39 |
|
sl@0
|
40 |
/// List containing all defined benchmarks
|
sl@0
|
41 |
extern RPointerArray<TUserBenchmark> UserBenchmarks;
|
sl@0
|
42 |
|
sl@0
|
43 |
#define CALL_10_TIMES(x) x; x; x; x; x; x; x; x; x; x
|
sl@0
|
44 |
|
sl@0
|
45 |
/// Macro to define a benchmark easily
|
sl@0
|
46 |
#define DEFINE_USER_BENCHMARK(name, pre, test) \
|
sl@0
|
47 |
_LIT8(KName_##name, #name); \
|
sl@0
|
48 |
class TBenchmark_##name : public TUserBenchmark \
|
sl@0
|
49 |
{ \
|
sl@0
|
50 |
public: \
|
sl@0
|
51 |
TBenchmark_##name() : \
|
sl@0
|
52 |
TUserBenchmark(KName_##name, KCategoryGeneral)\
|
sl@0
|
53 |
{} \
|
sl@0
|
54 |
virtual void Run(TInt aIts) \
|
sl@0
|
55 |
{ \
|
sl@0
|
56 |
pre; \
|
sl@0
|
57 |
for (TInt j = 0 ; j < aIts ; ++j) \
|
sl@0
|
58 |
{ \
|
sl@0
|
59 |
CALL_10_TIMES(test); \
|
sl@0
|
60 |
} \
|
sl@0
|
61 |
} \
|
sl@0
|
62 |
} Instance_##name
|
sl@0
|
63 |
|
sl@0
|
64 |
/// Macro to define a benchmark in category 'extra'
|
sl@0
|
65 |
#define DEFINE_EXTRA_BENCHMARK(name, pre, test) \
|
sl@0
|
66 |
_LIT8(KName_##name, #name); \
|
sl@0
|
67 |
class TBenchmark_##name : public TUserBenchmark \
|
sl@0
|
68 |
{ \
|
sl@0
|
69 |
public: \
|
sl@0
|
70 |
TBenchmark_##name() : \
|
sl@0
|
71 |
TUserBenchmark(KName_##name, KCategoryExtra) \
|
sl@0
|
72 |
{} \
|
sl@0
|
73 |
virtual void Run(TInt aIts) \
|
sl@0
|
74 |
{ \
|
sl@0
|
75 |
pre; \
|
sl@0
|
76 |
for (TInt j = 0 ; j < aIts ; ++j) \
|
sl@0
|
77 |
{ \
|
sl@0
|
78 |
CALL_10_TIMES(test); \
|
sl@0
|
79 |
} \
|
sl@0
|
80 |
} \
|
sl@0
|
81 |
} Instance_##name
|
sl@0
|
82 |
|
sl@0
|
83 |
#endif
|