traceservices/tracefw/ost_trace_api/unit_test/te_ost/src/te_tracer.cpp
changeset 0 08ec8eefde2f
child 23 26645d81f48d
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 2007-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 
       
    18 /**
       
    19  @file te_tracer.cpp
       
    20  @internalTechnology
       
    21 */
       
    22 #include "d32utrace.h"
       
    23 #include "te_tracer.h"
       
    24 #include "te_timer.h"
       
    25 #include "te_apicaller.h"
       
    26 
       
    27 
       
    28 TInt TTraceTester::TimeTraceL(TTraceConfigs& aTraceData, TUint32& aTime, TUint32& aCount) //pass the configuration here
       
    29 	{
       
    30 	TInt error = KErrNone;
       
    31 	TUint32 callResults[KNumberOfTraceCallIterations];
       
    32 	for(TInt i = 0; i < KNumberOfTraceCallIterations; i++)
       
    33 		{
       
    34 		error = TimeTraceCall(aTraceData, aTime, aCount);
       
    35 		callResults[i] = aTime;
       
    36 		}
       
    37 	TUint32 total = 0;
       
    38 	for(TInt i = 0; i < KNumberOfTraceCallIterations; i++)
       
    39 		total += callResults[i];
       
    40 	aTime = total / KNumberOfTraceCallIterations; //average
       
    41 	return error;
       
    42 	}
       
    43 
       
    44 
       
    45 TInt TTraceTester::TimeTraceCall(TTraceConfigs& aTraceData, TUint32& aTime, TUint32& aCount)
       
    46 	{
       
    47 	TInt error = KErrNotSupported;
       
    48  	if(TApiCaller::IsKernelTrace(aTraceData.iApiUsed))
       
    49  		{
       
    50  		// kernel side removed for now
       
    51 /*			RUTrace utracedriver;
       
    52 			error = utracedriver.Open();
       
    53 			if(!error)
       
    54 				{
       
    55 				error = utracedriver.TimeTraces(aTraceData, aTime, aCount);
       
    56 				}
       
    57 			utracedriver.Close();
       
    58 			*/
       
    59  		}
       
    60  	else//it's a user side trace, call it directly
       
    61  		{
       
    62  		CUtfTimer timer;
       
    63  		aCount = 0;
       
    64  		TRequestStatus status;
       
    65  		error = timer.StartBackgroundTimer(status);
       
    66  		if(!error)
       
    67  			{
       
    68 	 		do
       
    69 	 			{
       
    70 	 			error = TApiCaller::DoSendTraceL(aTraceData);
       
    71 	 			aCount++;
       
    72 #ifdef __WINS__
       
    73 	 			// under WINSCW this code never completes as status is never KErrNone	 			
       
    74 				// and as timings are not valid for emulator - we should just exit the loop here
       
    75 	 			
       
    76 	 			TRequestStatus* pStatus = &status;
       
    77 	 			User::RequestComplete(pStatus, KErrNone);
       
    78 #endif
       
    79 	 			
       
    80 	 			}
       
    81 	 		while(status != KErrNone);	// while (timer is still waiting)
       
    82 	 		aTime = timer.CalculateTime(aCount);
       
    83  			}
       
    84  		}	
       
    85 	return error;
       
    86 	}
       
    87 
       
    88 
       
    89 TInt TTraceTester::SendTraceL(TTraceConfigs& aTraceData)
       
    90 	{
       
    91  	TInt error = KErrNotSupported;
       
    92  	if(TApiCaller::IsKernelTrace(aTraceData.iApiUsed))
       
    93  		{
       
    94  		// kernel side removed for now
       
    95 /*			RUTrace utracedriver;
       
    96 			error = utracedriver.Open();
       
    97 			if(!error)
       
    98 				{
       
    99 				error = utracedriver.TestTraces(aTraceData);
       
   100 				}
       
   101 			utracedriver.Close();
       
   102 */ 		}
       
   103 
       
   104  	else//it's a user side trace, call it directly
       
   105  		{
       
   106 		error = TApiCaller::DoSendTraceL(aTraceData);
       
   107  		}
       
   108 	return error;
       
   109 	}