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