First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\bench\t_t64bm.cpp
19 #include <e32std_private.h>
21 #include <e32base_private.h>
24 const TInt KHeapSize=0x2000;
25 const TInt KAverageOverInSeconds=10;
26 const TInt KNumberOfCalculationsPerLoop=100;
28 volatile TInt64 count;
32 volatile TInt64 barrier;
34 RTest test(_L("T_T64BM"));
36 GLREF_C TInt TInt64Addition(TAny*);
37 GLREF_C TInt TInt64Subtraction(TAny*);
38 GLREF_C TInt TInt64Multiplication(TAny*);
39 GLREF_C TInt TInt64Division(TAny*);
41 TInt64 runTest(TThreadFunction aFunction,const TDesC& aTitle)
45 TInt r=thread.Create(aTitle,aFunction,KDefaultStackSize,KHeapSize,KHeapSize,NULL);
48 test.Printf(_L("Failed to create thread with error %d\n"),r);
54 User::After(KAverageOverInSeconds*1000000);
69 result*=KNumberOfCalculationsPerLoop;
70 result/=KAverageOverInSeconds;
72 test.Printf(_L("%S executed %d in 1 second\n"),&aTitle,r);
78 // Benchmark for TInt64 functions
83 test.Start(_L("Benchmarks for TInt64"));
85 runTest(TInt64Addition,_L("Addition"));
86 runTest(TInt64Subtraction,_L("Subtraction"));
87 runTest(TInt64Multiplication,_L("Multiplication"));
88 runTest(TInt64Division,_L("Division"));