os/kernelhwsrv/kerneltest/e32test/bench/t_rxbm.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_rxbm.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,73 @@
     1.4 +// Copyright (c) 1997-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_rxbm.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=10;
    1.30 +
    1.31 +volatile TInt count;
    1.32 +RTest test(_L("T_RXBM"));
    1.33 +
    1.34 +GLREF_C TInt TRealXAddition(TAny*);
    1.35 +GLREF_C TInt TRealXSubtraction(TAny*);
    1.36 +GLREF_C TInt TRealXMultiplication(TAny*);
    1.37 +GLREF_C TInt TRealXDivision(TAny*);
    1.38 +
    1.39 +TInt runTest(TThreadFunction aFunction,const TDesC& aTitle)
    1.40 +    {
    1.41 +
    1.42 +    RThread thread;
    1.43 +	TInt r=thread.Create(aTitle,aFunction,KDefaultStackSize,KHeapSize,KHeapSize,NULL);
    1.44 +	if(r!=KErrNone)
    1.45 +		{
    1.46 +		test.Printf(_L("Failed to create thread with error %d\n"),r);
    1.47 +		return(r);
    1.48 +		}
    1.49 +    thread.Resume();
    1.50 +    User::After(1000000);
    1.51 +    count=0;
    1.52 +    User::After(KAverageOverInSeconds*1000000);
    1.53 +    TInt result=count;
    1.54 +    thread.Kill(0);
    1.55 +	thread.Close();
    1.56 +    test.Printf(_L("%S executed %d in 1 second\n"),&aTitle,result*KNumberOfCalculationsPerLoop/KAverageOverInSeconds);
    1.57 +    return(result);
    1.58 +    }
    1.59 +
    1.60 +TInt E32Main()
    1.61 +//
    1.62 +// Benchmark for TRealX functions
    1.63 +//
    1.64 +    {
    1.65 +    test.Title();
    1.66 +    test.Start(_L("Benchmarks for TRealX"));
    1.67 +
    1.68 +	runTest(TRealXAddition,_L("Addition"));
    1.69 +	runTest(TRealXSubtraction,_L("Subtraction"));
    1.70 +	runTest(TRealXMultiplication,_L("Multiplication"));
    1.71 +	runTest(TRealXDivision,_L("Division"));
    1.72 +
    1.73 +	test.End();
    1.74 +	return(KErrNone);
    1.75 +    }
    1.76 +