1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/bench/t_userbm.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,83 @@
1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// e32test\bench\t_userbm.h
1.18 +//
1.19 +//
1.20 +
1.21 +#ifndef __T_USERBM_H__
1.22 +#define __T_USERBM_H__
1.23 +
1.24 +#include "t_asmbm.h"
1.25 +#include <e32std.h>
1.26 +
1.27 +/// Base class for user benchmarks
1.28 +class TUserBenchmark : public TBmInfo
1.29 + {
1.30 +public:
1.31 + virtual void Run(TInt aIts) = 0;
1.32 +protected:
1.33 + TUserBenchmark(const TDesC8& aName, TUint aCategory);
1.34 + };
1.35 +
1.36 +class TUserBenchmarkList : public MBenchmarkList
1.37 + {
1.38 + virtual TInt Count();
1.39 + virtual TInt Info(TInt aIndex, TBmInfo& aInfoOut);
1.40 + virtual TInt Run(TInt aIndex, const TBmParams& aParams, TInt& aDeltaOut);
1.41 + };
1.42 +
1.43 +/// List containing all defined benchmarks
1.44 +extern RPointerArray<TUserBenchmark> UserBenchmarks;
1.45 +
1.46 +#define CALL_10_TIMES(x) x; x; x; x; x; x; x; x; x; x
1.47 +
1.48 +/// Macro to define a benchmark easily
1.49 +#define DEFINE_USER_BENCHMARK(name, pre, test) \
1.50 +_LIT8(KName_##name, #name); \
1.51 +class TBenchmark_##name : public TUserBenchmark \
1.52 + { \
1.53 +public: \
1.54 + TBenchmark_##name() : \
1.55 + TUserBenchmark(KName_##name, KCategoryGeneral)\
1.56 + {} \
1.57 + virtual void Run(TInt aIts) \
1.58 + { \
1.59 + pre; \
1.60 + for (TInt j = 0 ; j < aIts ; ++j) \
1.61 + { \
1.62 + CALL_10_TIMES(test); \
1.63 + } \
1.64 + } \
1.65 + } Instance_##name
1.66 +
1.67 +/// Macro to define a benchmark in category 'extra'
1.68 +#define DEFINE_EXTRA_BENCHMARK(name, pre, test) \
1.69 +_LIT8(KName_##name, #name); \
1.70 +class TBenchmark_##name : public TUserBenchmark \
1.71 + { \
1.72 +public: \
1.73 + TBenchmark_##name() : \
1.74 + TUserBenchmark(KName_##name, KCategoryExtra) \
1.75 + {} \
1.76 + virtual void Run(TInt aIts) \
1.77 + { \
1.78 + pre; \
1.79 + for (TInt j = 0 ; j < aIts ; ++j) \
1.80 + { \
1.81 + CALL_10_TIMES(test); \
1.82 + } \
1.83 + } \
1.84 + } Instance_##name
1.85 +
1.86 +#endif