0
|
1 |
// Copyright (c) 1996-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_t64bm.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=100;
|
|
27 |
|
|
28 |
volatile TInt64 count;
|
|
29 |
volatile TInt64 a;
|
|
30 |
volatile TInt64 b;
|
|
31 |
volatile TInt64 c;
|
|
32 |
volatile TInt64 barrier;
|
|
33 |
|
|
34 |
RTest test(_L("T_T64BM"));
|
|
35 |
|
|
36 |
GLREF_C TInt TInt64Addition(TAny*);
|
|
37 |
GLREF_C TInt TInt64Subtraction(TAny*);
|
|
38 |
GLREF_C TInt TInt64Multiplication(TAny*);
|
|
39 |
GLREF_C TInt TInt64Division(TAny*);
|
|
40 |
|
|
41 |
TInt64 runTest(TThreadFunction aFunction,const TDesC& aTitle)
|
|
42 |
{
|
|
43 |
|
|
44 |
RThread thread;
|
|
45 |
TInt r=thread.Create(aTitle,aFunction,KDefaultStackSize,KHeapSize,KHeapSize,NULL);
|
|
46 |
if(r!=KErrNone)
|
|
47 |
{
|
|
48 |
test.Printf(_L("Failed to create thread with error %d\n"),r);
|
|
49 |
return(r);
|
|
50 |
}
|
|
51 |
thread.Resume();
|
|
52 |
User::After(1000000);
|
|
53 |
count=0;
|
|
54 |
User::After(KAverageOverInSeconds*1000000);
|
|
55 |
TInt64 result=count;
|
|
56 |
|
|
57 |
barrier = a;
|
|
58 |
if (!barrier)
|
|
59 |
barrier = c;
|
|
60 |
barrier = b;
|
|
61 |
if (!barrier)
|
|
62 |
barrier = a;
|
|
63 |
barrier = c;
|
|
64 |
if (!barrier)
|
|
65 |
barrier = b;
|
|
66 |
|
|
67 |
thread.Kill(0);
|
|
68 |
thread.Close();
|
|
69 |
result*=KNumberOfCalculationsPerLoop;
|
|
70 |
result/=KAverageOverInSeconds;
|
|
71 |
r=I64INT(result);
|
|
72 |
test.Printf(_L("%S executed %d in 1 second\n"),&aTitle,r);
|
|
73 |
return(result);
|
|
74 |
}
|
|
75 |
|
|
76 |
TInt E32Main()
|
|
77 |
//
|
|
78 |
// Benchmark for TInt64 functions
|
|
79 |
//
|
|
80 |
{
|
|
81 |
|
|
82 |
test.Title();
|
|
83 |
test.Start(_L("Benchmarks for TInt64"));
|
|
84 |
|
|
85 |
runTest(TInt64Addition,_L("Addition"));
|
|
86 |
runTest(TInt64Subtraction,_L("Subtraction"));
|
|
87 |
runTest(TInt64Multiplication,_L("Multiplication"));
|
|
88 |
runTest(TInt64Division,_L("Division"));
|
|
89 |
|
|
90 |
test.End();
|
|
91 |
return(KErrNone);
|
|
92 |
}
|
|
93 |
|