os/kernelhwsrv/kerneltest/e32test/bench/t_prof.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32test\bench\t_prof.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <e32test.h>
sl@0
    19
#include "d_prof.h"
sl@0
    20
sl@0
    21
RTest test(_L("T_PROFILE"));
sl@0
    22
RProfile Profile;
sl@0
    23
sl@0
    24
LOCAL_C void ProfileAllThreads()
sl@0
    25
	{
sl@0
    26
	TFindThread ft(_L("*"));
sl@0
    27
	TFullName fullname;
sl@0
    28
	test.Console()->ClearScreen();
sl@0
    29
	FOREVER
sl@0
    30
		{
sl@0
    31
		TInt r=ft.Next(fullname);
sl@0
    32
		if (r!=KErrNone)
sl@0
    33
			break;
sl@0
    34
		RThread t;
sl@0
    35
		r=t.Open(ft);
sl@0
    36
		if (r==KErrNone)
sl@0
    37
			{
sl@0
    38
			TProfileData data;
sl@0
    39
			r=Profile.Read(t,data);
sl@0
    40
			if (r==KErrNone)
sl@0
    41
				{
sl@0
    42
				while(fullname.Length()<40)
sl@0
    43
					fullname.Append(TChar(' '));
sl@0
    44
				test.Printf(_L("%S T=%9d C=%9d Y=%9d\n"),
sl@0
    45
					&fullname,data.iTotalCpuTime,data.iMaxContinuousCpuTime,data.iMaxTimeBeforeYield);
sl@0
    46
				}
sl@0
    47
			t.Close();
sl@0
    48
			}
sl@0
    49
		}
sl@0
    50
	}
sl@0
    51
sl@0
    52
GLDEF_C TInt E32Main()
sl@0
    53
	{
sl@0
    54
	test.Title();
sl@0
    55
	TInt r=User::LoadLogicalDevice(_L("D_PROF"));
sl@0
    56
	if (r!=KErrNone && r!=KErrAlreadyExists)
sl@0
    57
		User::Panic(_L("T_PROF0"),r);
sl@0
    58
	r=Profile.Open();
sl@0
    59
	if (r!=KErrNone)
sl@0
    60
		User::Panic(_L("T_PROF1"),r);
sl@0
    61
	FOREVER
sl@0
    62
		{
sl@0
    63
		TKeyCode key=test.Getch();
sl@0
    64
		if (key==TKeyCode('r'))
sl@0
    65
			{
sl@0
    66
			Profile.Reset();
sl@0
    67
			}
sl@0
    68
		else if (key==TKeyCode('p'))
sl@0
    69
			{
sl@0
    70
			ProfileAllThreads();
sl@0
    71
			}
sl@0
    72
		else if (key==TKeyCode('x'))
sl@0
    73
			break;
sl@0
    74
		}
sl@0
    75
	Profile.Close();
sl@0
    76
	User::FreeLogicalDevice(_L("Profile"));
sl@0
    77
	return KErrNone;
sl@0
    78
	}