os/kernelhwsrv/kerneltest/e32test/bench/t_t64bm.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/bench/t_t64bm.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,93 @@
     1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32test\bench\t_t64bm.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include <e32std.h>
    1.22 +#include <e32std_private.h>
    1.23 +#include <e32base.h>
    1.24 +#include <e32base_private.h>
    1.25 +#include <e32test.h>
    1.26 +
    1.27 +const TInt KHeapSize=0x2000;
    1.28 +const TInt KAverageOverInSeconds=10;
    1.29 +const TInt KNumberOfCalculationsPerLoop=100;
    1.30 +
    1.31 +volatile TInt64 count;
    1.32 +volatile TInt64 a;
    1.33 +volatile TInt64 b;
    1.34 +volatile TInt64 c;
    1.35 +volatile TInt64 barrier;
    1.36 +
    1.37 +RTest test(_L("T_T64BM"));
    1.38 +
    1.39 +GLREF_C TInt TInt64Addition(TAny*);
    1.40 +GLREF_C TInt TInt64Subtraction(TAny*);
    1.41 +GLREF_C TInt TInt64Multiplication(TAny*);
    1.42 +GLREF_C TInt TInt64Division(TAny*);
    1.43 +
    1.44 +TInt64 runTest(TThreadFunction aFunction,const TDesC& aTitle)
    1.45 +    {
    1.46 +
    1.47 +    RThread thread;
    1.48 +	TInt r=thread.Create(aTitle,aFunction,KDefaultStackSize,KHeapSize,KHeapSize,NULL);
    1.49 +	if(r!=KErrNone)
    1.50 +		{
    1.51 +		test.Printf(_L("Failed to create thread with error %d\n"),r);
    1.52 +		return(r);
    1.53 +		}
    1.54 +    thread.Resume();
    1.55 +    User::After(1000000);
    1.56 +    count=0;
    1.57 +    User::After(KAverageOverInSeconds*1000000);
    1.58 +    TInt64 result=count;
    1.59 +
    1.60 +	barrier = a;
    1.61 +	if (!barrier)
    1.62 +		barrier = c;
    1.63 +	barrier = b;
    1.64 +	if (!barrier)
    1.65 +		barrier = a;
    1.66 +	barrier = c;
    1.67 +	if (!barrier)
    1.68 +		barrier = b;
    1.69 +
    1.70 +	thread.Kill(0);
    1.71 +	thread.Close();
    1.72 +	result*=KNumberOfCalculationsPerLoop;
    1.73 +	result/=KAverageOverInSeconds;
    1.74 +	r=I64INT(result);
    1.75 +    test.Printf(_L("%S executed %d in 1 second\n"),&aTitle,r);
    1.76 +    return(result);
    1.77 +    }
    1.78 +
    1.79 +TInt E32Main()
    1.80 +//
    1.81 +// Benchmark for TInt64 functions
    1.82 +//
    1.83 +    {
    1.84 +
    1.85 +    test.Title();
    1.86 +    test.Start(_L("Benchmarks for TInt64"));
    1.87 +
    1.88 +	runTest(TInt64Addition,_L("Addition"));
    1.89 +	runTest(TInt64Subtraction,_L("Subtraction"));
    1.90 +	runTest(TInt64Multiplication,_L("Multiplication"));
    1.91 +	runTest(TInt64Division,_L("Division"));
    1.92 +
    1.93 +	test.End();
    1.94 +	return(KErrNone);
    1.95 +    }
    1.96 +