sl@0: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\bench\t_prof.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include "d_prof.h" sl@0: sl@0: RTest test(_L("T_PROFILE")); sl@0: RProfile Profile; sl@0: sl@0: LOCAL_C void ProfileAllThreads() sl@0: { sl@0: TFindThread ft(_L("*")); sl@0: TFullName fullname; sl@0: test.Console()->ClearScreen(); sl@0: FOREVER sl@0: { sl@0: TInt r=ft.Next(fullname); sl@0: if (r!=KErrNone) sl@0: break; sl@0: RThread t; sl@0: r=t.Open(ft); sl@0: if (r==KErrNone) sl@0: { sl@0: TProfileData data; sl@0: r=Profile.Read(t,data); sl@0: if (r==KErrNone) sl@0: { sl@0: while(fullname.Length()<40) sl@0: fullname.Append(TChar(' ')); sl@0: test.Printf(_L("%S T=%9d C=%9d Y=%9d\n"), sl@0: &fullname,data.iTotalCpuTime,data.iMaxContinuousCpuTime,data.iMaxTimeBeforeYield); sl@0: } sl@0: t.Close(); sl@0: } sl@0: } sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: test.Title(); sl@0: TInt r=User::LoadLogicalDevice(_L("D_PROF")); sl@0: if (r!=KErrNone && r!=KErrAlreadyExists) sl@0: User::Panic(_L("T_PROF0"),r); sl@0: r=Profile.Open(); sl@0: if (r!=KErrNone) sl@0: User::Panic(_L("T_PROF1"),r); sl@0: FOREVER sl@0: { sl@0: TKeyCode key=test.Getch(); sl@0: if (key==TKeyCode('r')) sl@0: { sl@0: Profile.Reset(); sl@0: } sl@0: else if (key==TKeyCode('p')) sl@0: { sl@0: ProfileAllThreads(); sl@0: } sl@0: else if (key==TKeyCode('x')) sl@0: break; sl@0: } sl@0: Profile.Close(); sl@0: User::FreeLogicalDevice(_L("Profile")); sl@0: return KErrNone; sl@0: }