graphicstest/uibench/src/teventhandlingperf.cpp
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2008-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 "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 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @test
       
    19  @internalComponent - Internal Symbian test code 
       
    20 */
       
    21 
       
    22 #include "teventhandlingperf.h"
       
    23 #include <hal.h>
       
    24 
       
    25 // Max length of the descriptor used for results of performance tests  
       
    26 // which are actually done in separate process. And UIBench testcase is 
       
    27 // used to display them according its format
       
    28 // 16 integers plus 8 commas i,e 32 * 16 + 16
       
    29 const TInt KMaxDescLength = 528;
       
    30 
       
    31 CTEventHandlingPerf::CTEventHandlingPerf()
       
    32 	{
       
    33 	SetTestStepName(KEventHandlingPerfName);
       
    34 	}
       
    35 
       
    36 CTEventHandlingPerf::~CTEventHandlingPerf()
       
    37 	{
       
    38 	}
       
    39 
       
    40 TVerdict CTEventHandlingPerf::doTestStepL()
       
    41 	{
       
    42 /**
       
    43 @SYMTestCaseID GRAPHICS-UI-BENCH-0172
       
    44 */
       
    45 	SetTestStepID(_L("GRAPHICS-UI-BENCH-0172"));
       
    46 	TBuf<KMaxDescLength> bufAvg;
       
    47 	TPtr temp(NULL,0);
       
    48 	TPtr temp1(NULL,0);
       
    49 	TPtr temp2(NULL,0);
       
    50 	// Here check if the HAL configuration are correct if not then finish the test case
       
    51 	TInt maxPtr;
       
    52 	TInt ret = HAL::Get(HALData::EPointerMaxPointers, maxPtr);
       
    53 	if (ret != KErrNone || maxPtr < 2 || maxPtr > 8)
       
    54 		{
       
    55 		INFO_PRINTF1(_L("Incorrect HAL configuration. \n"));
       
    56 		SetTestStepResult(EFail);
       
    57 	    CloseTMSGraphicsStep();
       
    58 		RecordTestResultL();
       
    59 		return TestStepResult();
       
    60 		}
       
    61 		
       
    62 	iProfiler->InitResults();
       
    63 	TInt minMemSize = 128;
       
    64 	TInt maxMemSize = KMaxDescLength;
       
    65 	// Create a shared chunk using the userheap function
       
    66 	// Allocate some memory in that and then get the offset from it - chunk's base
       
    67 	_LIT(KPerformanceTimingChunk, "PerformanceTimingChunk");
       
    68 	RHeap* heap = UserHeap::ChunkHeap(&KPerformanceTimingChunk, minMemSize, maxMemSize, 10);
       
    69 	CleanupClosePushL(*heap);
       
    70 	if (heap == NULL)
       
    71 		{
       
    72 		User::LeaveNoMemory();
       
    73 		}
       
    74 	RChunk chunk;
       
    75 	User::LeaveIfError(chunk.OpenGlobal(KPerformanceTimingChunk, ETrue));
       
    76 	CleanupClosePushL(chunk);
       
    77 	
       
    78 	TInt memSize = KMaxDescLength;
       
    79 	TAny* perfDesc = heap->AllocL(memSize);
       
    80 	if (!perfDesc)
       
    81 		{
       
    82 		User::LeaveNoMemory();
       
    83 		}
       
    84 	TInt offset = reinterpret_cast<TUint8*>(perfDesc) - chunk.Base() ;
       
    85 
       
    86 	// Create a process called te_multiptrperf
       
    87 	// Pass in the offset as descriptor
       
    88 	_LIT(KMultiPtrEventHandlingPerf,"z:\\sys\\bin\\te_multiptrperf.exe");
       
    89 	TBuf<128> buf;
       
    90 	buf.Num(offset);
       
    91 	RProcess eventHandPerf;
       
    92 	User::LeaveIfError(eventHandPerf.Create(KMultiPtrEventHandlingPerf, buf));
       
    93 	TRequestStatus stat;
       
    94 	eventHandPerf.Logon(stat);
       
    95 	eventHandPerf.Resume();
       
    96 	User::WaitForRequest(stat);
       
    97 	eventHandPerf.Close();
       
    98 	
       
    99 	// Once the process finished its execution print the result by 
       
   100 	// reading the data from chunk's memory
       
   101 	TPtr8 ptrDes((TUint8*)perfDesc, memSize, memSize);
       
   102 	TPtr8 ptrDesDisplay((TUint8*)perfDesc, memSize, memSize);
       
   103 
       
   104 	// If it has failed then just print description written in the same
       
   105 	// when it is failed description contains '*' at the end
       
   106 	TInt lastChar = 0;
       
   107 	lastChar = ptrDes.Locate('*');
       
   108 	if (KErrNotFound != lastChar)
       
   109 		{
       
   110 		SetTestStepResult(EFail);
       
   111 		TPtr8 temp = ptrDesDisplay.LeftTPtr(lastChar);
       
   112 		TBuf<128> buf;
       
   113 		buf.Copy(temp);
       
   114 		INFO_PRINTF2(_L("%S"), &buf);
       
   115 		RDebug::RawPrint(temp);
       
   116 		goto END;
       
   117 		}
       
   118 	// If it has skipped then just print skip description from the chunk
       
   119 	// when it is skipped description contains '#' at the end
       
   120     lastChar = ptrDes.Locate('#');
       
   121     if (KErrNotFound != lastChar)
       
   122         {
       
   123         SetTestStepResult(EPass);
       
   124         TPtr8 temp = ptrDesDisplay.LeftTPtr(lastChar);
       
   125         TBuf<128> buf;
       
   126         buf.Copy(temp);
       
   127         INFO_PRINTF2(_L("%S"), &buf);
       
   128         RDebug::RawPrint(temp);
       
   129         goto END;
       
   130         }
       
   131 	
       
   132 	// If the every thing goes fine the descriptor is displayed as
       
   133 	// "12345678,123456789,123456789"
       
   134 	TInt avg4Events, avg8Events, avg16Events, avg32Events;
       
   135 	bufAvg.Copy(ptrDesDisplay);
       
   136 	for (TInt i=0; i<4; i++)
       
   137 		{
       
   138 		TInt locate = bufAvg.Locate(',');
       
   139 		if (locate == KErrNotFound)
       
   140 			{
       
   141 			SetTestStepResult(EFail);
       
   142 			goto END;
       
   143 			}
       
   144 		TLex lex(bufAvg.Left(locate));
       
   145 		lex.Val(avg4Events);
       
   146 	
       
   147 		locate++;
       
   148 		temp.Set(bufAvg.MidTPtr(locate));
       
   149 		locate = temp.Locate(',');
       
   150 		if (locate == KErrNotFound)
       
   151 			{
       
   152 			SetTestStepResult(EFail);
       
   153 			goto END;
       
   154 			}
       
   155 		lex = temp.Left(locate);
       
   156 		lex.Val(avg8Events);
       
   157 	
       
   158 		locate++;
       
   159 		temp1.Set(temp.MidTPtr(locate));
       
   160 		locate = temp1.Locate(',');
       
   161 		if (locate == KErrNotFound)
       
   162 			{
       
   163 			SetTestStepResult(EFail);
       
   164 			goto END;
       
   165 			}	
       
   166 		lex = temp.Left(locate);
       
   167 		lex.Val(avg16Events);
       
   168 		
       
   169 		locate++;
       
   170 		temp2.Set(temp1.MidTPtr(locate));
       
   171 		locate = temp2.Locate(',');
       
   172 		if (locate == KErrNotFound)
       
   173 			{
       
   174 			SetTestStepResult(EFail);
       
   175 			goto END;
       
   176 			}	
       
   177 		lex = temp2.Left(locate);
       
   178 		lex.Val(avg32Events);
       
   179 		
       
   180 		locate++;
       
   181 		bufAvg.Copy(temp2.MidTPtr(locate));
       
   182 		
       
   183 		switch (i)
       
   184 			{
       
   185 			case 0:
       
   186 				INFO_PRINTF5(_L("TID: Average time for Single pointer(wait after each event) for 4 events:%i  8 events:%i  16 events:%i  32events:%i"), avg4Events, avg8Events, avg16Events, avg32Events);
       
   187 				break;
       
   188 			case 1:
       
   189 				INFO_PRINTF5(_L("TID: Average time for Multi pointer(wait after each event) for 4 events:%i  8 events:%i  16 events:%i  32events:%i"), avg4Events, avg8Events, avg16Events, avg32Events);
       
   190 				break;
       
   191 			case 2:
       
   192 				INFO_PRINTF5(_L("TID: Average time for single pointer for 4 events:%i  8 events:%i  16 events:%i  32events:%i"), avg4Events, avg8Events, avg16Events, avg32Events);
       
   193 				break;
       
   194 			case 3:
       
   195 				INFO_PRINTF5(_L("TID: Average time for Multi pointer for 4 events:%i  8 events:%i  16 events:%i  32events:%i"), avg4Events, avg8Events, avg16Events, avg32Events);
       
   196 				SetTestStepResult(EPass);
       
   197 				break;
       
   198 			default:
       
   199 				break;
       
   200 			}
       
   201 		}
       
   202 	
       
   203 	iProfiler->ResultsAnalysis(KEventHandlingPerfName, 0, EColor16MA, EColor16MA, 1);
       
   204 	
       
   205 END:	
       
   206 	// Once the data is printed or displyed delete the memory
       
   207 	heap->Free(perfDesc);
       
   208 	
       
   209 	CleanupStack::PopAndDestroy(2, heap);
       
   210 	RecordTestResultL();
       
   211     CloseTMSGraphicsStep();
       
   212 	return TestStepResult();
       
   213 	}
       
   214 
       
   215 TVerdict CTEventHandlingPerf::doTestStepPreambleL()
       
   216 	{
       
   217 	return CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL();
       
   218 	}
       
   219 
       
   220 TVerdict CTEventHandlingPerf::doTestStepPostambleL()
       
   221 	{
       
   222 	return CTe_graphicsperformanceSuiteStepBase::doTestStepPostambleL();
       
   223 	}