author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 43 | c1f20ce4abcf |
parent 0 | a41df078684a |
child 44 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
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 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
29 |
volatile TUint Count; |
0 | 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); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
61 |
TUint initial = Count; |
0 | 62 |
User::After(KAverageOverInSeconds*1000000); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
63 |
TUint final = Count; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
64 |
TUint64 result = TUint64(final - initial); |
0 | 65 |
result *= TUint64(KNumberOfCalculationsPerLoop); |
66 |
result /= TUint64(KAverageOverInSeconds); |
|
67 |
TUint r32 = (TUint)result; |
|
68 |
thread.Kill(0); |
|
69 |
thread.Close(); |
|
70 |
test.Printf(_L("%S executed %d in 1 second\n"),&aTitle,r32); |
|
71 |
return r32; |
|
72 |
} |
|
73 |
||
74 |
TInt E32Main() |
|
75 |
// |
|
76 |
// Benchmark for TRealX functions |
|
77 |
// |
|
78 |
{ |
|
79 |
||
80 |
test.Title(); |
|
81 |
#ifdef T_R64BM_WITH_VFP |
|
82 |
TInt supportedModes; |
|
83 |
if (HAL::Get(HALData::EHardwareFloatingPoint, supportedModes) != KErrNone) |
|
84 |
{ |
|
85 |
test.Printf(_L("Skipping test as this hardware does not have VFP\n")); |
|
86 |
return(KErrNone); |
|
87 |
} |
|
88 |
test.Start(_L("Benchmarks for TReal64 using VFP")); |
|
89 |
#else |
|
90 |
test.Start(_L("Benchmarks for TReal64")); |
|
91 |
#endif |
|
92 |
||
93 |
runTest(TReal64Addition,_L("Addition")); |
|
94 |
runTest(TReal64Subtraction,_L("Subtraction")); |
|
95 |
runTest(TReal64Multiplication,_L("Multiplication")); |
|
96 |
runTest(TReal64Division,_L("Division")); |
|
97 |
runTest(TRealSqrt,_L("Square root")); |
|
98 |
runTest(TRealSin,_L("Sine")); |
|
99 |
runTest(TRealTan,_L("Tangent")); |
|
100 |
runTest(TRealLn,_L("Logarithm")); |
|
101 |
runTest(TRealExp,_L("Exponential")); |
|
102 |
runTest(TRealAsin,_L("Arcsine")); |
|
103 |
runTest(TRealAtan,_L("Arctan")); |
|
104 |
runTest(TRealPower,_L("Powers")); |
|
105 |
||
106 |
test.End(); |
|
107 |
return(KErrNone); |
|
108 |
} |
|
109 |