commonservices/sysutil/test/helper/timelegacyapis/src/timelegacyapis.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     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 // file timelegacyapis.cpp
       
    15 // This executable times how long it takes to call legacy APIs. It should be used when 
       
    16 // new hardware build targets are introduced. The existing performance tests can then be 
       
    17 // updated for these platforms.
       
    18 // Note: The times generated can be used for the following tests:
       
    19 // - PrintSWVersionAPILegacyTimes					SYSLIB-BAFL-CT-4064
       
    20 // - PrintLangVersionAPILegacyTimes				SYSLIB-BAFL-CT-4065
       
    21 // - PrintLangSWVersionAPILegacyTimes				SYSLIB-BAFL-CT-4066
       
    22 // 
       
    23 //
       
    24 
       
    25 #include <e32base.h>
       
    26 #include <e32std.h>
       
    27 #include <e32debug.h>
       
    28 #include <bafl/sysutil.h>
       
    29 #include <hal.h>
       
    30 #include "sysutilfunctions.h"
       
    31 #include "sysutilpatchdata.h"
       
    32 
       
    33 TReal FastCountToMilliseconds(const TUint32 aFastCount)
       
    34 	{
       
    35 	TInt freqInHz;
       
    36 	HAL::Get(HAL::EFastCounterFrequency, freqInHz);
       
    37 	TReal freqInkHz = freqInHz / 1000;
       
    38 	return (TReal)aFastCount / freqInkHz;
       
    39 	}
       
    40 
       
    41 /**
       
    42 Calls SysUtil::GetSWVersion and prints out how long it took for the call to complete.
       
    43 */
       
    44 void PrintSWVersionAPILegacyTimes()
       
    45 	{
       
    46 	TBuf<KSysUtilVersionTextLength> version;
       
    47 	
       
    48 	TUint32 startTime = User::FastCounter();
       
    49 	TInt err = SysUtil::GetSWVersion(version);
       
    50 	TUint32 totalTime = User::FastCounter() - startTime;
       
    51 	
       
    52 	if(KErrNone != err)
       
    53 		{
       
    54 		RDebug::Printf("GetSWVersion return unexpected error. Error = %d", err);
       
    55 		return;
       
    56 		}
       
    57 	RDebug::Printf("GetSWVersion took = %fms", FastCountToMilliseconds(totalTime));
       
    58 	}
       
    59 
       
    60 /**
       
    61 Calls SysUtil::GetLangVersion and prints out how long it took for the call to complete.
       
    62 */
       
    63 void PrintLangVersionAPILegacyTimes()
       
    64 	{
       
    65 	TBuf<KSysUtilVersionTextLength> version;
       
    66 	
       
    67 	TUint32 startTime = User::FastCounter();
       
    68 	TInt err = SysUtil::GetSWVersion(version);
       
    69 	TUint32 totalTime = User::FastCounter() - startTime;
       
    70 	
       
    71 	if(KErrNone != err)
       
    72 		{
       
    73 		RDebug::Printf("GetLangVersion return unexpected error. Error = %d", err);
       
    74 		return;
       
    75 		}
       
    76 	RDebug::Printf("GetLangVersion took = %fms", FastCountToMilliseconds(totalTime));
       
    77 	}
       
    78 
       
    79 /**
       
    80 Calls SysUtil::GetLangSWVersion and prints out how long it took for the call to complete.
       
    81 */
       
    82 void PrintLangSWVersionAPILegacyTimes()
       
    83 	{
       
    84 	TBuf<KSysUtilVersionTextLength> version;
       
    85 	
       
    86 	TUint32 startTime = User::FastCounter();
       
    87 	TInt err = SysUtil::GetLangSWVersion(version);
       
    88 	TUint32 totalTime = User::FastCounter() - startTime;
       
    89 	
       
    90 	if(KErrNone != err)
       
    91 		{
       
    92 		RDebug::Printf("GetLangSWVersion return unexpected error. Error = %d", err);
       
    93 		return;
       
    94 		}
       
    95 	RDebug::Printf("GetLangSWVersion took = %fms", FastCountToMilliseconds(totalTime));
       
    96 	}
       
    97 
       
    98 void Main()
       
    99 	{
       
   100 #ifndef __WINSCW__
       
   101 	if(KSysUtilDisableVersionSetupExe)
       
   102 		{
       
   103 		SetTestPath(EFalse);
       
   104 		PrintSWVersionAPILegacyTimes();
       
   105 		PrintLangVersionAPILegacyTimes();
       
   106 		PrintLangSWVersionAPILegacyTimes();
       
   107 		}
       
   108 	else
       
   109 		{
       
   110 		RDebug::Printf("\n\nMake sure SYMBIAN_BAFL_SYSUTIL_ENABLE_VERSION_SETUP_EXE is not defined when building a ROM.");
       
   111 		}
       
   112 #else
       
   113 	RDebug::Printf("\n\nThis executable should only be run on hardware.");
       
   114 #endif
       
   115 	}
       
   116 
       
   117 TInt E32Main()
       
   118 	{
       
   119 	__UHEAP_MARK;
       
   120 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   121 	if(cleanup == NULL)
       
   122 		return KErrNoMemory;
       
   123 	
       
   124 	Main();
       
   125 	
       
   126 	delete cleanup;
       
   127 	__UHEAP_MARKEND;
       
   128 	return KErrNone;
       
   129 	}