Update contrib.
1 // Copyright (c) 1997-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\bench\t_r64bm.cpp
19 #include <e32std_private.h>
21 #include <e32base_private.h>
25 const TInt KHeapSize=0x2000;
26 const TInt KAverageOverInSeconds=10;
27 const TInt KNumberOfCalculationsPerLoop=10;
30 #ifdef T_R64BM_WITH_VFP
31 RTest test(_L("T_VFPBM"));
33 RTest test(_L("T_R64BM"));
36 GLREF_C TInt TReal64Addition(TAny*);
37 GLREF_C TInt TReal64Subtraction(TAny*);
38 GLREF_C TInt TReal64Multiplication(TAny*);
39 GLREF_C TInt TReal64Division(TAny*);
40 GLREF_C TInt TRealSqrt(TAny*);
41 GLREF_C TInt TRealSin(TAny*);
42 GLREF_C TInt TRealTan(TAny*);
43 GLREF_C TInt TRealLn(TAny*);
44 GLREF_C TInt TRealExp(TAny*);
45 GLREF_C TInt TRealAsin(TAny*);
46 GLREF_C TInt TRealAtan(TAny*);
47 GLREF_C TInt TRealPower(TAny*);
49 TInt runTest(TThreadFunction aFunction,const TDesC& aTitle)
53 TInt r=thread.Create(aTitle,aFunction,KDefaultStackSize,KHeapSize,KHeapSize,NULL);
56 test.Printf(_L("Failed to create thread with error %d\n"),r);
62 User::After(KAverageOverInSeconds*1000000);
63 TUint64 result = count;
64 result *= TUint64(KNumberOfCalculationsPerLoop);
65 result /= TUint64(KAverageOverInSeconds);
66 TUint r32 = (TUint)result;
69 test.Printf(_L("%S executed %d in 1 second\n"),&aTitle,r32);
75 // Benchmark for TRealX functions
80 #ifdef T_R64BM_WITH_VFP
82 if (HAL::Get(HALData::EHardwareFloatingPoint, supportedModes) != KErrNone)
84 test.Printf(_L("Skipping test as this hardware does not have VFP\n"));
87 test.Start(_L("Benchmarks for TReal64 using VFP"));
89 test.Start(_L("Benchmarks for TReal64"));
92 runTest(TReal64Addition,_L("Addition"));
93 runTest(TReal64Subtraction,_L("Subtraction"));
94 runTest(TReal64Multiplication,_L("Multiplication"));
95 runTest(TReal64Division,_L("Division"));
96 runTest(TRealSqrt,_L("Square root"));
97 runTest(TRealSin,_L("Sine"));
98 runTest(TRealTan,_L("Tangent"));
99 runTest(TRealLn,_L("Logarithm"));
100 runTest(TRealExp,_L("Exponential"));
101 runTest(TRealAsin,_L("Arcsine"));
102 runTest(TRealAtan,_L("Arctan"));
103 runTest(TRealPower,_L("Powers"));