sl@0: // Copyright (c) 2005-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: // Overview: sl@0: // The test measures the duration of the user-side timer services. sl@0: // API Information: sl@0: // User::After(...) sl@0: // User::At(...) sl@0: // User::AfterHighRes(...) sl@0: // Details: sl@0: // - Calls time services a number of times with the same input arguments. sl@0: // - Records and prints the minimum and maximum duration of each test case. sl@0: // - Tests the duration of User::After and User::AfterHighRes on target. sl@0: // Platforms/Drives/Compatibility: sl@0: // Emulator and Hardware (Automatic). sl@0: // Assumptions/Requirement/Pre-requisites: sl@0: // Failures and causes: sl@0: // The test can fail only on target. sl@0: // - The duration of Timer::After(aTime) is not within the limits (from to ) sl@0: // - The duration of Timer::AfterHighRes(aTime) is not within the limits (from to ) sl@0: // Base Port information: sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: LOCAL_D RTest test(_L("T_TIMERDURATION")); sl@0: sl@0: // Max number of different time values measured sl@0: const TInt KMaxTimeValues = 12; sl@0: sl@0: // number of times measurement taken to average sl@0: const TInt KMaxTimeMeasurements = 20; sl@0: TInt MaxTimeMeasurements; sl@0: TInt TimeRawMS[KMaxTimeMeasurements];//Holds the ROW time in Kernel ticks sl@0: sl@0: TInt* TimeValue; sl@0: TInt TimeMin[KMaxTimeValues]; sl@0: TInt TimeMax[KMaxTimeValues]; sl@0: sl@0: void calcStats(TInt i) sl@0: { sl@0: TimeMin[i]=TimeRawMS[0]; sl@0: TimeMax[i]=TimeRawMS[0]; sl@0: for (TInt j=1; jTimeRawMS[j]) TimeMin[i]=TimeRawMS[j]; sl@0: if (TimeMax[i]= TimeMax[k]); sl@0: } sl@0: #endif sl@0: /////////////////////////////////////////// sl@0: test.Next(_L("User::At")); sl@0: MaxTimeMeasurements = KMaxTimeMeasurements/2; sl@0: TInt TimeValues3[KMaxTimeValues]={950000,1000000,-1}; sl@0: TimeValue = &TimeValues3[0]; sl@0: TTime time; sl@0: time.Set(_L("20050101:000001.000000")); sl@0: User::SetHomeTime(time); sl@0: __BEFORE_WAIT__ sl@0: time.HomeTime(); sl@0: time += (TTimeIntervalMicroSeconds32)value; sl@0: __MEASURE1__ sl@0: User::At(time); sl@0: __MEASURE2__ sl@0: __AFTER_WAIT__ sl@0: /////////////////////////////////////////// sl@0: test.Next(_L("User::AfterHighRes")); sl@0: MaxTimeMeasurements = KMaxTimeMeasurements; sl@0: TInt TimeValues4[KMaxTimeValues]={1000,2000,4000,8000,16000,32000,64000,128000,-1}; sl@0: TimeValue = &TimeValues4[0]; sl@0: __BEFORE_WAIT__ sl@0: __MEASURE1__ sl@0: User::AfterHighRes(value); sl@0: __MEASURE2__ sl@0: __AFTER_WAIT__ sl@0: #if defined(__EPOC32__) sl@0: //Check that User::AfterHighRes calls completed within boundaries sl@0: for (k = 0; k= TimeMax[k]); sl@0: } sl@0: #endif sl@0: /////////////////////////////////////////// sl@0: test.End(); sl@0: return(KErrNone); sl@0: }