phonebookengines_old/contactsmodel/tsrc/cntmatchlog/inc/test.h
changeset 40 b46a585f6909
equal deleted inserted replaced
37:fd64c38c277d 40:b46a585f6909
       
     1 // Copyright (c) 2006-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 #ifndef __TEST_H__
       
    17 #define __TEST_H__
       
    18 
       
    19 #define TEST(arg) theTest(arg, __LINE__)
       
    20 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
       
    21 
       
    22 //-----------------------------------------------------------------------------
       
    23 //
       
    24 // Timing macros.
       
    25 //
       
    26 //-----------------------------------------------------------------------------
       
    27 #define TIMERINSTALL \
       
    28 	TTime start(static_cast<TInt64>(0)); \
       
    29 	TTime end(static_cast<TInt64>(0));   \
       
    30 	TUint delta = 0; \
       
    31 	TUint cummulative = 0; \
       
    32 	TUint iterations = 0;
       
    33 
       
    34 
       
    35 #define TIMERRESET \
       
    36 	delta = 0, cummulative = 0, iterations = 0;
       
    37 
       
    38 
       
    39 #define TIMERSTART \
       
    40 	start.UniversalTime();
       
    41 
       
    42 
       
    43 #define TIMERSTOP \
       
    44 	end.UniversalTime(); \
       
    45 	delta = I64LOW(end.MicroSecondsFrom(start).Int64()); \
       
    46 	iterations++; \
       
    47 	cummulative += delta;
       
    48 	
       
    49 
       
    50 #ifdef INCLUDE_VERBOSE
       
    51 _LIT(KExecutionTime, "Iteration %3d, execution Time: %dus\n");
       
    52 _LIT(KTimerResult,   "Average time = %dus over %d iterations\n");
       
    53 _LIT(KTimingError,   "Error - no timing results to display\n");
       
    54 
       
    55 # define TIMERPRINT \
       
    56 	theTest.Printf(KExecutionTime, iterations, delta);
       
    57 
       
    58 
       
    59 # define TIMERRESULT \
       
    60 	if (iterations) \
       
    61 		{ \
       
    62 		theTest.Printf(KTimerResult, cummulative/iterations, iterations); \
       
    63 		} \
       
    64 	else \
       
    65 		{ \
       
    66 		theTest.Printf(KTimingError); \
       
    67 		}
       
    68 
       
    69 #else
       
    70 # define TIMERPRINT
       
    71 # define TIMERRESULT
       
    72 #endif
       
    73 	
       
    74 
       
    75 #define TIMERAVERAGE \
       
    76 		(iterations ? cummulative/iterations : 0xFFFFFFFF)
       
    77 
       
    78 
       
    79 #endif//__TEST_H__