0
|
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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// e32test\bench\t_r64bm.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include <e32std.h>
|
|
19 |
#include <e32std_private.h>
|
|
20 |
#include <e32base.h>
|
|
21 |
#include <e32base_private.h>
|
|
22 |
#include <e32test.h>
|
|
23 |
#include <hal.h>
|
|
24 |
|
|
25 |
const TInt KHeapSize=0x2000;
|
|
26 |
const TInt KAverageOverInSeconds=10;
|
|
27 |
const TInt KNumberOfCalculationsPerLoop=10;
|
|
28 |
|
|
29 |
volatile TUint count;
|
|
30 |
#ifdef T_R64BM_WITH_VFP
|
|
31 |
RTest test(_L("T_VFPBM"));
|
|
32 |
#else
|
|
33 |
RTest test(_L("T_R64BM"));
|
|
34 |
#endif
|
|
35 |
|
|
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*);
|
|
48 |
|
|
49 |
TInt runTest(TThreadFunction aFunction,const TDesC& aTitle)
|
|
50 |
{
|
|
51 |
|
|
52 |
RThread thread;
|
|
53 |
TInt r=thread.Create(aTitle,aFunction,KDefaultStackSize,KHeapSize,KHeapSize,NULL);
|
|
54 |
if(r!=KErrNone)
|
|
55 |
{
|
|
56 |
test.Printf(_L("Failed to create thread with error %d\n"),r);
|
|
57 |
return(r);
|
|
58 |
}
|
|
59 |
thread.Resume();
|
|
60 |
User::After(1000000);
|
|
61 |
count=0;
|
|
62 |
User::After(KAverageOverInSeconds*1000000);
|
|
63 |
TUint64 result = count;
|
|
64 |
result *= TUint64(KNumberOfCalculationsPerLoop);
|
|
65 |
result /= TUint64(KAverageOverInSeconds);
|
|
66 |
TUint r32 = (TUint)result;
|
|
67 |
thread.Kill(0);
|
|
68 |
thread.Close();
|
|
69 |
test.Printf(_L("%S executed %d in 1 second\n"),&aTitle,r32);
|
|
70 |
return r32;
|
|
71 |
}
|
|
72 |
|
|
73 |
TInt E32Main()
|
|
74 |
//
|
|
75 |
// Benchmark for TRealX functions
|
|
76 |
//
|
|
77 |
{
|
|
78 |
|
|
79 |
test.Title();
|
|
80 |
#ifdef T_R64BM_WITH_VFP
|
|
81 |
TInt supportedModes;
|
|
82 |
if (HAL::Get(HALData::EHardwareFloatingPoint, supportedModes) != KErrNone)
|
|
83 |
{
|
|
84 |
test.Printf(_L("Skipping test as this hardware does not have VFP\n"));
|
|
85 |
return(KErrNone);
|
|
86 |
}
|
|
87 |
test.Start(_L("Benchmarks for TReal64 using VFP"));
|
|
88 |
#else
|
|
89 |
test.Start(_L("Benchmarks for TReal64"));
|
|
90 |
#endif
|
|
91 |
|
|
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"));
|
|
104 |
|
|
105 |
test.End();
|
|
106 |
return(KErrNone);
|
|
107 |
}
|
|
108 |
|