|
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_rxbm.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 |
|
24 const TInt KHeapSize=0x2000; |
|
25 const TInt KAverageOverInSeconds=10; |
|
26 const TInt KNumberOfCalculationsPerLoop=10; |
|
27 |
|
28 volatile TInt count; |
|
29 RTest test(_L("T_RXBM")); |
|
30 |
|
31 GLREF_C TInt TRealXAddition(TAny*); |
|
32 GLREF_C TInt TRealXSubtraction(TAny*); |
|
33 GLREF_C TInt TRealXMultiplication(TAny*); |
|
34 GLREF_C TInt TRealXDivision(TAny*); |
|
35 |
|
36 TInt runTest(TThreadFunction aFunction,const TDesC& aTitle) |
|
37 { |
|
38 |
|
39 RThread thread; |
|
40 TInt r=thread.Create(aTitle,aFunction,KDefaultStackSize,KHeapSize,KHeapSize,NULL); |
|
41 if(r!=KErrNone) |
|
42 { |
|
43 test.Printf(_L("Failed to create thread with error %d\n"),r); |
|
44 return(r); |
|
45 } |
|
46 thread.Resume(); |
|
47 User::After(1000000); |
|
48 count=0; |
|
49 User::After(KAverageOverInSeconds*1000000); |
|
50 TInt result=count; |
|
51 thread.Kill(0); |
|
52 thread.Close(); |
|
53 test.Printf(_L("%S executed %d in 1 second\n"),&aTitle,result*KNumberOfCalculationsPerLoop/KAverageOverInSeconds); |
|
54 return(result); |
|
55 } |
|
56 |
|
57 TInt E32Main() |
|
58 // |
|
59 // Benchmark for TRealX functions |
|
60 // |
|
61 { |
|
62 test.Title(); |
|
63 test.Start(_L("Benchmarks for TRealX")); |
|
64 |
|
65 runTest(TRealXAddition,_L("Addition")); |
|
66 runTest(TRealXSubtraction,_L("Subtraction")); |
|
67 runTest(TRealXMultiplication,_L("Multiplication")); |
|
68 runTest(TRealXDivision,_L("Division")); |
|
69 |
|
70 test.End(); |
|
71 return(KErrNone); |
|
72 } |
|
73 |