os/kernelhwsrv/kerneltest/e32test/bench/t_prof.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1998-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_prof.cpp
    15 // 
    16 //
    17 
    18 #include <e32test.h>
    19 #include "d_prof.h"
    20 
    21 RTest test(_L("T_PROFILE"));
    22 RProfile Profile;
    23 
    24 LOCAL_C void ProfileAllThreads()
    25 	{
    26 	TFindThread ft(_L("*"));
    27 	TFullName fullname;
    28 	test.Console()->ClearScreen();
    29 	FOREVER
    30 		{
    31 		TInt r=ft.Next(fullname);
    32 		if (r!=KErrNone)
    33 			break;
    34 		RThread t;
    35 		r=t.Open(ft);
    36 		if (r==KErrNone)
    37 			{
    38 			TProfileData data;
    39 			r=Profile.Read(t,data);
    40 			if (r==KErrNone)
    41 				{
    42 				while(fullname.Length()<40)
    43 					fullname.Append(TChar(' '));
    44 				test.Printf(_L("%S T=%9d C=%9d Y=%9d\n"),
    45 					&fullname,data.iTotalCpuTime,data.iMaxContinuousCpuTime,data.iMaxTimeBeforeYield);
    46 				}
    47 			t.Close();
    48 			}
    49 		}
    50 	}
    51 
    52 GLDEF_C TInt E32Main()
    53 	{
    54 	test.Title();
    55 	TInt r=User::LoadLogicalDevice(_L("D_PROF"));
    56 	if (r!=KErrNone && r!=KErrAlreadyExists)
    57 		User::Panic(_L("T_PROF0"),r);
    58 	r=Profile.Open();
    59 	if (r!=KErrNone)
    60 		User::Panic(_L("T_PROF1"),r);
    61 	FOREVER
    62 		{
    63 		TKeyCode key=test.Getch();
    64 		if (key==TKeyCode('r'))
    65 			{
    66 			Profile.Reset();
    67 			}
    68 		else if (key==TKeyCode('p'))
    69 			{
    70 			ProfileAllThreads();
    71 			}
    72 		else if (key==TKeyCode('x'))
    73 			break;
    74 		}
    75 	Profile.Close();
    76 	User::FreeLogicalDevice(_L("Profile"));
    77 	return KErrNone;
    78 	}