os/kernelhwsrv/kerneltest/e32test/bench/t_prof.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_prof.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,78 @@
     1.4 +// Copyright (c) 1998-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_prof.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include <e32test.h>
    1.22 +#include "d_prof.h"
    1.23 +
    1.24 +RTest test(_L("T_PROFILE"));
    1.25 +RProfile Profile;
    1.26 +
    1.27 +LOCAL_C void ProfileAllThreads()
    1.28 +	{
    1.29 +	TFindThread ft(_L("*"));
    1.30 +	TFullName fullname;
    1.31 +	test.Console()->ClearScreen();
    1.32 +	FOREVER
    1.33 +		{
    1.34 +		TInt r=ft.Next(fullname);
    1.35 +		if (r!=KErrNone)
    1.36 +			break;
    1.37 +		RThread t;
    1.38 +		r=t.Open(ft);
    1.39 +		if (r==KErrNone)
    1.40 +			{
    1.41 +			TProfileData data;
    1.42 +			r=Profile.Read(t,data);
    1.43 +			if (r==KErrNone)
    1.44 +				{
    1.45 +				while(fullname.Length()<40)
    1.46 +					fullname.Append(TChar(' '));
    1.47 +				test.Printf(_L("%S T=%9d C=%9d Y=%9d\n"),
    1.48 +					&fullname,data.iTotalCpuTime,data.iMaxContinuousCpuTime,data.iMaxTimeBeforeYield);
    1.49 +				}
    1.50 +			t.Close();
    1.51 +			}
    1.52 +		}
    1.53 +	}
    1.54 +
    1.55 +GLDEF_C TInt E32Main()
    1.56 +	{
    1.57 +	test.Title();
    1.58 +	TInt r=User::LoadLogicalDevice(_L("D_PROF"));
    1.59 +	if (r!=KErrNone && r!=KErrAlreadyExists)
    1.60 +		User::Panic(_L("T_PROF0"),r);
    1.61 +	r=Profile.Open();
    1.62 +	if (r!=KErrNone)
    1.63 +		User::Panic(_L("T_PROF1"),r);
    1.64 +	FOREVER
    1.65 +		{
    1.66 +		TKeyCode key=test.Getch();
    1.67 +		if (key==TKeyCode('r'))
    1.68 +			{
    1.69 +			Profile.Reset();
    1.70 +			}
    1.71 +		else if (key==TKeyCode('p'))
    1.72 +			{
    1.73 +			ProfileAllThreads();
    1.74 +			}
    1.75 +		else if (key==TKeyCode('x'))
    1.76 +			break;
    1.77 +		}
    1.78 +	Profile.Close();
    1.79 +	User::FreeLogicalDevice(_L("Profile"));
    1.80 +	return KErrNone;
    1.81 +	}