traceservices/tracefw/integ_test/ost/TEF/te_ostv2integsuite_performance/src/sanity/te_perfsanitytimer.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 // UTrace Performance Tests Kernel-Side Timer.
       
    15 //
       
    16 
       
    17 
       
    18 
       
    19 /**
       
    20  @file te_perfsanitytimer.cpp
       
    21  @internalTechnology
       
    22  @prototype
       
    23 */
       
    24 #include "te_perfsanitytimer.h"
       
    25 #include "te_apirunconfig.h"
       
    26 #ifndef __KERNEL_MODE__
       
    27 #include "te_instrumentation_enum.h"
       
    28 #include "te_instrumentationpoints.h"
       
    29 
       
    30 #endif
       
    31 #include "te_dataparameters.h"
       
    32 
       
    33 TBool TTestTimer::TestUserTimer(TUint32& aTestTime)
       
    34 	{
       
    35 	return DoTestTrace(ESanityFoo, aTestTime);
       
    36 	}
       
    37 
       
    38 TBool TTestTimer::TestUserLongTimer(TUint32& aTestTime)
       
    39 	{
       
    40 	return DoTestTrace(ESanityFooLong, aTestTime);
       
    41 	}
       
    42 
       
    43 
       
    44 TBool TTestTimer::TestKernelTimer(TUint32& aTestTime)
       
    45 	{
       
    46 	return DoTestTrace(ESanityFoo, aTestTime);
       
    47 	}
       
    48 
       
    49 TBool TTestTimer::TestKernelLongTimer(TUint32& aTestTime)
       
    50 	{
       
    51 	return DoTestTrace(ESanityFooLong, aTestTime);
       
    52 	}
       
    53 
       
    54 TBool TTestTimer::TestUTraceUserTimer(TUint32& aTestTime)
       
    55 	{
       
    56 	return DoTestTrace(EUtraceUsr, aTestTime);
       
    57 	}
       
    58 
       
    59 TBool TTestTimer::TestUTraceKernelTimer(TUint32& aTestTime)
       
    60 	{
       
    61 	return DoTestTrace(EUtraceKrn, aTestTime);
       
    62 	}
       
    63 
       
    64 
       
    65 TBool TTestTimer::DoTestTrace(const TTestMethodType aMethod, TUint32& aTestTime)
       
    66 	{
       
    67 	aTestTime = 0;
       
    68 
       
    69 	//Want to set this up before we run the timers not to affect them
       
    70 	TApiRunConfig apiRunConfig;
       
    71 	TRunConfigurer::Init(apiRunConfig);
       
    72 	if(aMethod == EUtraceUsr)
       
    73 		{
       
    74 		#ifndef __KERNEL_MODE__
       
    75 		apiRunConfig.iApiId = UPTTraceTest;
       
    76 		#endif
       
    77 		}
       
    78 	if(aMethod == EUtraceKrn)
       
    79 		{
       
    80 		#ifndef __KERNEL_MODE__
       
    81 		apiRunConfig.iApiId = UPTKernelTraceTest;
       
    82 		#endif
       
    83 		}
       
    84 	apiRunConfig.iDoMinExecution = ETrue;
       
    85 	TApiRunResults apiRunResults;
       
    86 	TRunConfigurer::Init(apiRunResults);
       
    87 
       
    88 	TUint32 callResults[KNumberOfTraceCallIterations];
       
    89 	for(TInt i = 0; i < KNumberOfTraceCallIterations; i++)
       
    90 		{
       
    91 
       
    92 		TInt error = iTimer.StartBackgroundTimer();
       
    93 		if(!error)
       
    94 			{
       
    95 			while(!iTimer.IsTimerExpired())
       
    96 				{
       
    97 				switch(aMethod)
       
    98 				{
       
    99 				case ESanityFoo:
       
   100 				SanityFoo();
       
   101 				break;
       
   102 				case ESanityFooLong:
       
   103 				SanityFooLong();
       
   104 				break;
       
   105 				case EUtraceUsr:
       
   106 				case EUtraceKrn:
       
   107 				#ifndef __KERNEL_MODE__
       
   108 				TUptTraceCalls::DoSendTraceL(apiRunConfig, apiRunResults);
       
   109 				#endif
       
   110 				break;
       
   111 				}
       
   112 				iTimer.IncreaseCount();
       
   113 				}
       
   114 			iTimer.FinalCount();
       
   115 			aTestTime = iTimer.FinalTime();//in nanosec
       
   116 			}
       
   117 		callResults[i] = aTestTime;
       
   118 		}
       
   119 	TUint32 total = 0;
       
   120 	for(TInt i = 0; i < KNumberOfTraceCallIterations; i++)
       
   121 		total += callResults[i];
       
   122 	aTestTime = total / KNumberOfTraceCallIterations; //average
       
   123 
       
   124 
       
   125 	return VerifyTime(aTestTime);
       
   126 	}
       
   127 
       
   128 TBool TTestTimer::VerifyTime(TUint32 aTime)
       
   129 	{
       
   130 	if(aTime > KMinFooTime && aTime < KMaxFooTime)
       
   131 		return ETrue;
       
   132 	else
       
   133 		return EFalse;
       
   134 	}
       
   135 
       
   136