kerneltest/e32test/bench/t_userbm.cpp
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // e32test\bench\t_userbm.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "t_userbm.h"
       
    19 #include <hal.h>
       
    20 
       
    21 RPointerArray<TUserBenchmark> UserBenchmarks;
       
    22 
       
    23 TInt TUserBenchmarkList::Count()
       
    24 	{
       
    25 	return UserBenchmarks.Count();
       
    26 	}
       
    27 
       
    28 TInt TUserBenchmarkList::Info(TInt aIndex, TBmInfo& aInfoOut)
       
    29 	{
       
    30 	aInfoOut = *(TBmInfo*)UserBenchmarks[aIndex];
       
    31 	return KErrNone;
       
    32 	}
       
    33 
       
    34 TInt TUserBenchmarkList::Run(TInt aIndex, const TBmParams& aParams, TInt& aDeltaOut)
       
    35 	{
       
    36 	RThread thread;
       
    37 	thread.SetPriority(EPriorityAbsoluteHigh);
       
    38 
       
    39 	TUserBenchmark& bm = *UserBenchmarks[aIndex];
       
    40 	TUint init, final;
       
    41 	init = User::FastCounter();
       
    42 	bm.Run(aParams.iIts);
       
    43 	final = User::FastCounter();
       
    44 	aDeltaOut = final - init;
       
    45 
       
    46 	thread.SetPriority(EPriorityNormal);
       
    47 	return KErrNone;
       
    48 	}
       
    49 
       
    50 TUserBenchmark::TUserBenchmark(const TDesC8& aName, TUint aCategory)
       
    51 	{
       
    52 	iName = aName;
       
    53 	iCategories = aCategory;
       
    54 	iAlignStep = 0;
       
    55 	__ASSERT_ALWAYS(UserBenchmarks.Append(this) == KErrNone, User::Invariant());
       
    56 	}