sl@0: // Copyright (c) 1997-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_rxbm.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: const TInt KHeapSize=0x2000; sl@0: const TInt KAverageOverInSeconds=10; sl@0: const TInt KNumberOfCalculationsPerLoop=10; sl@0: sl@0: volatile TInt count; sl@0: RTest test(_L("T_RXBM")); sl@0: sl@0: GLREF_C TInt TRealXAddition(TAny*); sl@0: GLREF_C TInt TRealXSubtraction(TAny*); sl@0: GLREF_C TInt TRealXMultiplication(TAny*); sl@0: GLREF_C TInt TRealXDivision(TAny*); sl@0: sl@0: TInt runTest(TThreadFunction aFunction,const TDesC& aTitle) sl@0: { sl@0: sl@0: RThread thread; sl@0: TInt r=thread.Create(aTitle,aFunction,KDefaultStackSize,KHeapSize,KHeapSize,NULL); sl@0: if(r!=KErrNone) sl@0: { sl@0: test.Printf(_L("Failed to create thread with error %d\n"),r); sl@0: return(r); sl@0: } sl@0: thread.Resume(); sl@0: User::After(1000000); sl@0: count=0; sl@0: User::After(KAverageOverInSeconds*1000000); sl@0: TInt result=count; sl@0: thread.Kill(0); sl@0: thread.Close(); sl@0: test.Printf(_L("%S executed %d in 1 second\n"),&aTitle,result*KNumberOfCalculationsPerLoop/KAverageOverInSeconds); sl@0: return(result); sl@0: } sl@0: sl@0: TInt E32Main() sl@0: // sl@0: // Benchmark for TRealX functions sl@0: // sl@0: { sl@0: test.Title(); sl@0: test.Start(_L("Benchmarks for TRealX")); sl@0: sl@0: runTest(TRealXAddition,_L("Addition")); sl@0: runTest(TRealXSubtraction,_L("Subtraction")); sl@0: runTest(TRealXMultiplication,_L("Multiplication")); sl@0: runTest(TRealXDivision,_L("Division")); sl@0: sl@0: test.End(); sl@0: return(KErrNone); sl@0: } sl@0: