sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\bench\t_userbm.h sl@0: // sl@0: // sl@0: sl@0: #ifndef __T_USERBM_H__ sl@0: #define __T_USERBM_H__ sl@0: sl@0: #include "t_asmbm.h" sl@0: #include sl@0: sl@0: /// Base class for user benchmarks sl@0: class TUserBenchmark : public TBmInfo sl@0: { sl@0: public: sl@0: virtual void Run(TInt aIts) = 0; sl@0: protected: sl@0: TUserBenchmark(const TDesC8& aName, TUint aCategory); sl@0: }; sl@0: sl@0: class TUserBenchmarkList : public MBenchmarkList sl@0: { sl@0: virtual TInt Count(); sl@0: virtual TInt Info(TInt aIndex, TBmInfo& aInfoOut); sl@0: virtual TInt Run(TInt aIndex, const TBmParams& aParams, TInt& aDeltaOut); sl@0: }; sl@0: sl@0: /// List containing all defined benchmarks sl@0: extern RPointerArray UserBenchmarks; sl@0: sl@0: #define CALL_10_TIMES(x) x; x; x; x; x; x; x; x; x; x sl@0: sl@0: /// Macro to define a benchmark easily sl@0: #define DEFINE_USER_BENCHMARK(name, pre, test) \ sl@0: _LIT8(KName_##name, #name); \ sl@0: class TBenchmark_##name : public TUserBenchmark \ sl@0: { \ sl@0: public: \ sl@0: TBenchmark_##name() : \ sl@0: TUserBenchmark(KName_##name, KCategoryGeneral)\ sl@0: {} \ sl@0: virtual void Run(TInt aIts) \ sl@0: { \ sl@0: pre; \ sl@0: for (TInt j = 0 ; j < aIts ; ++j) \ sl@0: { \ sl@0: CALL_10_TIMES(test); \ sl@0: } \ sl@0: } \ sl@0: } Instance_##name sl@0: sl@0: /// Macro to define a benchmark in category 'extra' sl@0: #define DEFINE_EXTRA_BENCHMARK(name, pre, test) \ sl@0: _LIT8(KName_##name, #name); \ sl@0: class TBenchmark_##name : public TUserBenchmark \ sl@0: { \ sl@0: public: \ sl@0: TBenchmark_##name() : \ sl@0: TUserBenchmark(KName_##name, KCategoryExtra) \ sl@0: {} \ sl@0: virtual void Run(TInt aIts) \ sl@0: { \ sl@0: pre; \ sl@0: for (TInt j = 0 ; j < aIts ; ++j) \ sl@0: { \ sl@0: CALL_10_TIMES(test); \ sl@0: } \ sl@0: } \ sl@0: } Instance_##name sl@0: sl@0: #endif