os/kernelhwsrv/kerneltest/e32test/bench/t_desfnc.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 1996-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 the License "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 // e32test\bench\t_desfnc.cpp
    15 // 
    16 //
    17 
    18 #include "t_userbm.h"
    19 #include <e32std.h>
    20 #include <e32std_private.h>
    21 
    22 _LIT(KCompare16, "abcdefghijklmnopqrstuvwxyz123456");
    23 _LIT(KCompare16_2, "ABcdEfGhijklmnopqrstUVWxYZ123456");
    24 _LIT(KMatch16, "qrstu");
    25 _LIT(KMatch16_2, "qRStU");
    26 const TDesC16& KString16 = KCompare16_2();
    27 const TUint16* KCharData16 = KString16.Ptr();
    28 TChar KChar;
    29 
    30 _LIT8(KCompare8, "abcdefghijklmnopqrstuvwxyz123456");
    31 _LIT8(KCompare8_2, "ABcdEfGhijklmnopqrstUVWxYZ123456");
    32 _LIT8(KMatch8, "qrstu");
    33 _LIT8(KMatch8_2, "qRStU");
    34 const TDesC8& KString8 = KCompare8_2();
    35 const TUint8* KCharData8 = KString8.Ptr();
    36 
    37 void InitDataL()
    38 	{
    39 	}
    40 
    41 // 16 bit descriptors
    42 
    43 // Original t_desbm benchmarks first
    44 DEFINE_USER_BENCHMARK(TDes16_Num,
    45 					  TBuf16<32> buf,
    46 					  buf.Num(0x35241525));
    47 
    48 DEFINE_USER_BENCHMARK(TDes16_Num_RadixHex,
    49 					  TBuf16<256> buf,
    50 					  buf.Num(0x35241525,EHex));
    51 
    52 DEFINE_USER_BENCHMARK(TDes16_Num_RadixDecimal,
    53 					  TBuf16<256> buf,
    54 					  buf.Num(0x35241525,EDecimal));
    55 
    56 DEFINE_USER_BENCHMARK(TDes16_Num_RadixOctal,
    57 					  TBuf16<256> buf,
    58 					  buf.Num(0x35241525,EOctal));
    59 
    60 DEFINE_USER_BENCHMARK(TDes16_Num_RadixBinary,
    61 					  TBuf16<256> buf,
    62 					  buf.Num(0x35241525,EBinary));
    63 
    64 DEFINE_USER_BENCHMARK(TDesC16_Compare,
    65 					  TBuf16<256> buf(KCompare16); TBuf16<256> str(KCompare16),
    66 					  buf.Compare(str));
    67 
    68 DEFINE_EXTRA_BENCHMARK(TDesC16_CompareC,
    69 					   TBuf16<256> buf(KCompare16); TBuf16<256> str(KCompare16_2),
    70 					   buf.CompareC(str));
    71 
    72 DEFINE_USER_BENCHMARK(TDesC16_CompareF,
    73 					  TBuf16<256> buf(KCompare16); TBuf16<256> str(KCompare16_2),
    74 					  buf.CompareF(str));
    75 
    76 DEFINE_USER_BENCHMARK(TDesC16_Match,
    77 					  TBuf16<256> buf(KCompare16); TBuf16<256> str(KMatch16),
    78 					  buf.Match(str));
    79 
    80 DEFINE_USER_BENCHMARK(TDesC16_MatchF,
    81 					  TBuf16<256> buf(KCompare16); TBuf16<256> str(KMatch16_2),
    82 					  buf.MatchF(str));
    83 
    84 
    85 DEFINE_EXTRA_BENCHMARK(TDes16_Append_TChar,
    86 					   TBuf16<256> buf(KCompare16),
    87 					   buf.SetLength(32); buf.Append(KChar));
    88 
    89 DEFINE_EXTRA_BENCHMARK(TDes16_Append_TDesC16,
    90 					   TBuf16<256> buf(KCompare16),
    91 					   buf.SetLength(32); buf.Append(KString16));
    92 
    93 DEFINE_EXTRA_BENCHMARK(TDes16_Append_pTUint16,
    94 					   TBuf16<256> buf(KCompare16),
    95 					   buf.SetLength(32); buf.Append(KCharData16, 32));
    96 
    97 DEFINE_EXTRA_BENCHMARK(TDes16_Copy_TDesC16,
    98 					   TBuf16<256> buf,
    99 					   buf.Copy(KString16));
   100 
   101 DEFINE_EXTRA_BENCHMARK(TDes16_Copy_pTUint16,
   102 					   TBuf16<256> buf,
   103 					   buf.Copy(KCharData16));
   104 
   105 DEFINE_EXTRA_BENCHMARK(TDes16_Copy_pTUint16_TInt,
   106 					   TBuf16<256> buf,
   107 					   buf.Copy(KCharData16, 32));
   108 
   109 DEFINE_EXTRA_BENCHMARK(TDes16_Fill,
   110 					   TBuf16<256> buf(KCompare16),
   111 					   buf.Fill(KChar));
   112 
   113 DEFINE_EXTRA_BENCHMARK(TDes16_FillZ,
   114 					   TBuf16<256> buf(KCompare16),
   115 					   buf.FillZ());
   116 
   117 DEFINE_EXTRA_BENCHMARK(TDes16_LeftTPtr,
   118 					   TBuf16<256> buf(KCompare16),
   119 					   buf.LeftTPtr(10));
   120 
   121 DEFINE_EXTRA_BENCHMARK(TDes16_RightTPtr,
   122 					   TBuf16<256> buf(KCompare16),
   123 					   buf.RightTPtr(10));
   124 
   125 DEFINE_EXTRA_BENCHMARK(TDes16_MidTPtr,
   126 					   TBuf16<256> buf(KCompare16),
   127 					   buf.MidTPtr(10));
   128 
   129 DEFINE_EXTRA_BENCHMARK(TDes16_PtrZ,
   130 					   TBuf16<256> buf(KCompare16),
   131 					   buf.PtrZ());
   132 
   133 DEFINE_EXTRA_BENCHMARK(TDes16_SetLength,
   134 					   TBuf16<256> buf(KCompare16),
   135 					   buf.SetLength(10));
   136 
   137 DEFINE_EXTRA_BENCHMARK(TDes16_SetMax,
   138 					   TBuf16<256> buf(KCompare16),
   139 					   buf.SetMax());
   140 
   141 DEFINE_EXTRA_BENCHMARK(TDes16_ZeroTerminate,
   142 					   TBuf16<256> buf(KCompare16),
   143 					   buf.ZeroTerminate());
   144 
   145 DEFINE_EXTRA_BENCHMARK(TDesC16_AtC,
   146 					   ,
   147 					   KString16[10]);
   148 
   149 DEFINE_EXTRA_BENCHMARK(TDesC16_Left,
   150 					   ,
   151 					   KString16.Left(10));
   152 
   153 DEFINE_EXTRA_BENCHMARK(TDesC16_Right,
   154 					   ,
   155 					   KString16.Right(10));
   156 
   157 DEFINE_EXTRA_BENCHMARK(TDesC16_Mid,
   158 					   ,
   159 					   KString16.Mid(10));
   160 
   161 DEFINE_EXTRA_BENCHMARK(TDesC16_Locate,
   162 					   ,
   163 					   KString16.Locate(KChar));
   164 
   165 DEFINE_EXTRA_BENCHMARK(TDesC16_LocateReverse,
   166 					   ,
   167 					   KString16.LocateReverse(KChar));
   168 
   169 DEFINE_EXTRA_BENCHMARK(TDesC16_Ptr,
   170 					   ,
   171 					   KString16.Ptr());
   172 
   173 DEFINE_EXTRA_BENCHMARK(TPtr16_TPtr16,
   174 					   TPtr16 p(NULL, 0),
   175 					   new (&p) TPtr16(NULL, 0));
   176 
   177 DEFINE_EXTRA_BENCHMARK(TPtr16_TPtr16_2,
   178 					   TPtr16 p(NULL, 0),
   179 					   new (&p) TPtr16(NULL, 0, 0));
   180 
   181 DEFINE_EXTRA_BENCHMARK(TPtrC16_TPtrC16,
   182 					   TPtrC16 p,
   183 					   new (&p) TPtrC16());
   184 
   185 DEFINE_EXTRA_BENCHMARK(TPtrC16_TPtrC16_2,
   186 					   TPtrC16 p,
   187 					   new (&p) TPtrC16(KString16));
   188 
   189 DEFINE_EXTRA_BENCHMARK(TPtrC16_TPtrC16_3,
   190 					   TPtrC16 p,
   191 					   new (&p) TPtrC16(KCharData16));
   192 
   193 DEFINE_EXTRA_BENCHMARK(TPtrC16_TPtrC16_4,
   194 					   TPtrC16 p,
   195 					   new (&p) TPtrC16(KCharData16, 32));
   196 
   197 DEFINE_EXTRA_BENCHMARK(TBufBase16_TBufBase16_1,
   198 					   TBuf16<256> b,
   199 					   new (&b) TBuf16<256>());
   200 
   201 DEFINE_EXTRA_BENCHMARK(TBufBase16_TBufBase16_2,
   202 					   TBuf16<256> b,
   203 					   new (&b) TBuf16<256>(32));
   204 
   205 DEFINE_EXTRA_BENCHMARK(TBufBase16_TBufBase16_3,
   206 					   TBuf16<256> b,
   207 					   new (&b) TBuf16<256>(KCharData16));
   208 
   209 DEFINE_EXTRA_BENCHMARK(TBufBase16_TBufBase16_4,
   210 					   TBuf16<256> b,
   211 					   new (&b) TBuf16<256>(KString16));
   212 
   213 DEFINE_EXTRA_BENCHMARK(TBufCBase16_TBufBaseC16_1,
   214 					   TBufC16<256> b,
   215 					   new (&b) TBufC16<256>());
   216 
   217 DEFINE_EXTRA_BENCHMARK(TBufCBase16_TBufBaseC16_2,
   218 					   TBufC16<256> b,
   219 					   new (&b) TBufC16<256>(KCharData16));
   220 
   221 DEFINE_EXTRA_BENCHMARK(TBufCBase16_TBufBaseC16_3,
   222 					   TBufC16<256> b,
   223 					   new (&b) TBufC16<256>(KString16));
   224 
   225 // 8 bit descriptors
   226 
   227 DEFINE_EXTRA_BENCHMARK(TDes8_Num,
   228 					   TBuf8<32> buf,
   229 					   buf.Num(0x35241525));
   230 
   231 DEFINE_EXTRA_BENCHMARK(TDes8_Num_RadixHex,
   232 					   TBuf8<256> buf,
   233 					   buf.Num(0x35241525,EHex));
   234 
   235 DEFINE_EXTRA_BENCHMARK(TDes8_Num_RadixDecimal,
   236 					   TBuf8<256> buf,
   237 					   buf.Num(0x35241525,EDecimal));
   238 
   239 DEFINE_EXTRA_BENCHMARK(TDes8_Num_RadixOctal,
   240 					   TBuf8<256> buf,
   241 					   buf.Num(0x35241525,EOctal));
   242 
   243 DEFINE_EXTRA_BENCHMARK(TDes8_Num_RadixBinary,
   244 					   TBuf8<256> buf,
   245 					   buf.Num(0x35241525,EBinary));
   246 
   247 DEFINE_EXTRA_BENCHMARK(TDesC8_Compare,
   248 					   TBuf8<256> buf(KCompare8); TBuf8<256> str(KCompare8),
   249 					   buf.Compare(str));
   250 
   251 DEFINE_EXTRA_BENCHMARK(TDesC8_CompareC,
   252 					   TBuf8<256> buf(KCompare8); TBuf8<256> str(KCompare8_2),
   253 					   buf.CompareC(str));
   254 
   255 DEFINE_EXTRA_BENCHMARK(TDesC8_CompareF,
   256 					   TBuf8<256> buf(KCompare8); TBuf8<256> str(KCompare8_2),
   257 					   buf.CompareF(str));
   258 
   259 DEFINE_EXTRA_BENCHMARK(TDesC8_Match,
   260 					   TBuf8<256> buf(KCompare8); TBuf8<256> str(KMatch8),
   261 					   buf.Match(str));
   262 
   263 DEFINE_EXTRA_BENCHMARK(TDesC8_MatchF,
   264 					   TBuf8<256> buf(KCompare8); TBuf8<256> str(KMatch8_2),
   265 					   buf.MatchF(str));
   266 
   267 DEFINE_EXTRA_BENCHMARK(TDes8_Append_TChar,
   268 					   TBuf8<256> buf(KCompare8),
   269 					   buf.SetLength(32); buf.Append(KChar));
   270 
   271 DEFINE_EXTRA_BENCHMARK(TDes8_Append_TDesC8,
   272 					   TBuf8<256> buf(KCompare8),
   273 					   buf.SetLength(32); buf.Append(KString8));
   274 
   275 DEFINE_EXTRA_BENCHMARK(TDes8_Append_pTUint8,
   276 					   TBuf8<256> buf(KCompare8),
   277 					   buf.SetLength(32); buf.Append(KCharData8, 32));
   278 
   279 DEFINE_EXTRA_BENCHMARK(TDes8_Copy_TDesC8,
   280 					   TBuf8<256> buf,
   281 					   buf.Copy(KString8));
   282 
   283 DEFINE_EXTRA_BENCHMARK(TDes8_Copy_pTUint8,
   284 					   TBuf8<256> buf,
   285 					   buf.Copy(KCharData8));
   286 
   287 DEFINE_EXTRA_BENCHMARK(TDes8_Copy_pTUint8_TInt,
   288 					   TBuf8<256> buf,
   289 					   buf.Copy(KCharData8, 32));
   290 
   291 DEFINE_EXTRA_BENCHMARK(TDes8_Fill,
   292 					   TBuf8<256> buf(KCompare8),
   293 					   buf.Fill(KChar));
   294 
   295 DEFINE_EXTRA_BENCHMARK(TDes8_FillZ,
   296 					   TBuf8<256> buf(KCompare8),
   297 					   buf.FillZ());
   298 
   299 DEFINE_EXTRA_BENCHMARK(TDes8_LeftTPtr,
   300 					   TBuf8<256> buf(KCompare8),
   301 					   buf.LeftTPtr(10));
   302 
   303 DEFINE_EXTRA_BENCHMARK(TDes8_RightTPtr,
   304 					   TBuf8<256> buf(KCompare8),
   305 					   buf.RightTPtr(10));
   306 
   307 DEFINE_EXTRA_BENCHMARK(TDes8_MidTPtr,
   308 					   TBuf8<256> buf(KCompare8),
   309 					   buf.MidTPtr(10));
   310 
   311 DEFINE_EXTRA_BENCHMARK(TDes8_PtrZ,
   312 					   TBuf8<256> buf(KCompare8),
   313 					   buf.PtrZ());
   314 
   315 DEFINE_EXTRA_BENCHMARK(TDes8_SetLength,
   316 					   TBuf8<256> buf(KCompare8),
   317 					   buf.SetLength(10));
   318 
   319 DEFINE_EXTRA_BENCHMARK(TDes8_SetMax,
   320 					   TBuf8<256> buf(KCompare8),
   321 					   buf.SetMax());
   322 
   323 DEFINE_EXTRA_BENCHMARK(TDes8_ZeroTerminate,
   324 					   TBuf8<256> buf(KCompare8),
   325 					   buf.ZeroTerminate());
   326 
   327 DEFINE_EXTRA_BENCHMARK(TDesC8_AtC,
   328 					   ,
   329 					   KString8[10]);
   330 
   331 DEFINE_EXTRA_BENCHMARK(TDesC8_Left,
   332 					   ,
   333 					   KString8.Left(10));
   334 
   335 DEFINE_EXTRA_BENCHMARK(TDesC8_Right,
   336 					   ,
   337 					   KString8.Right(10));
   338 
   339 DEFINE_EXTRA_BENCHMARK(TDesC8_Mid,
   340 					   ,
   341 					   KString8.Mid(10));
   342 
   343 DEFINE_EXTRA_BENCHMARK(TDesC8_Locate,
   344 					   ,
   345 					   KString8.Locate(KChar));
   346 
   347 DEFINE_EXTRA_BENCHMARK(TDesC8_LocateReverse,
   348 					   ,
   349 					   KString8.LocateReverse(KChar));
   350 
   351 DEFINE_EXTRA_BENCHMARK(TDesC8_Ptr,
   352 					   ,
   353 					   KString8.Ptr());
   354 
   355 DEFINE_EXTRA_BENCHMARK(TPtr8_TPtr8,
   356 					   TPtr8 p(NULL, 0),
   357 					   new (&p) TPtr8(NULL, 0));
   358 
   359 DEFINE_EXTRA_BENCHMARK(TPtr8_TPtr8_2,
   360 					   TPtr8 p(NULL, 0),
   361 					   new (&p) TPtr8(NULL, 0, 0));
   362 
   363 DEFINE_EXTRA_BENCHMARK(TPtrC8_TPtrC8,
   364 					   TPtrC8 p,
   365 					   new (&p) TPtrC8());
   366 
   367 DEFINE_EXTRA_BENCHMARK(TPtrC8_TPtrC8_2,
   368 					   TPtrC8 p,
   369 					   new (&p) TPtrC8(KString8));
   370 
   371 DEFINE_EXTRA_BENCHMARK(TPtrC8_TPtrC8_3,
   372 					   TPtrC8 p,
   373 					   new (&p) TPtrC8(KCharData8));
   374 
   375 DEFINE_EXTRA_BENCHMARK(TPtrC8_TPtrC8_4,
   376 					   TPtrC8 p,
   377 					   new (&p) TPtrC8(KCharData8, 32));
   378 
   379 DEFINE_EXTRA_BENCHMARK(TBufBase8_TBufBase8_1,
   380 					   TBuf8<256> b,
   381 					   new (&b) TBuf8<256>());
   382 
   383 DEFINE_EXTRA_BENCHMARK(TBufBase8_TBufBase8_2,
   384 					   TBuf8<256> b,
   385 					   new (&b) TBuf8<256>(32));
   386 
   387 DEFINE_EXTRA_BENCHMARK(TBufBase8_TBufBase8_3,
   388 					   TBuf8<256> b,
   389 					   new (&b) TBuf8<256>(KCharData8));
   390 
   391 DEFINE_EXTRA_BENCHMARK(TBufBase8_TBufBase8_4,
   392 					   TBuf8<256> b,
   393 					   new (&b) TBuf8<256>(KString8));
   394 
   395 DEFINE_EXTRA_BENCHMARK(TBufCBase8_TBufBaseC8_1,
   396 					   TBufC8<256> b,
   397 					   new (&b) TBufC8<256>());
   398 
   399 DEFINE_EXTRA_BENCHMARK(TBufCBase8_TBufBaseC8_2,
   400 					   TBufC8<256> b,
   401 					   new (&b) TBufC8<256>(KCharData8));
   402 
   403 DEFINE_EXTRA_BENCHMARK(TBufCBase8_TBufBaseC8_3,
   404 					   TBufC8<256> b,
   405 					   new (&b) TBufC8<256>(KString8));