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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\bench\t_desfnc.cpp
20 #include <e32std_private.h>
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();
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();
43 // Original t_desbm benchmarks first
44 DEFINE_USER_BENCHMARK(TDes16_Num,
48 DEFINE_USER_BENCHMARK(TDes16_Num_RadixHex,
50 buf.Num(0x35241525,EHex));
52 DEFINE_USER_BENCHMARK(TDes16_Num_RadixDecimal,
54 buf.Num(0x35241525,EDecimal));
56 DEFINE_USER_BENCHMARK(TDes16_Num_RadixOctal,
58 buf.Num(0x35241525,EOctal));
60 DEFINE_USER_BENCHMARK(TDes16_Num_RadixBinary,
62 buf.Num(0x35241525,EBinary));
64 DEFINE_USER_BENCHMARK(TDesC16_Compare,
65 TBuf16<256> buf(KCompare16); TBuf16<256> str(KCompare16),
68 DEFINE_EXTRA_BENCHMARK(TDesC16_CompareC,
69 TBuf16<256> buf(KCompare16); TBuf16<256> str(KCompare16_2),
72 DEFINE_USER_BENCHMARK(TDesC16_CompareF,
73 TBuf16<256> buf(KCompare16); TBuf16<256> str(KCompare16_2),
76 DEFINE_USER_BENCHMARK(TDesC16_Match,
77 TBuf16<256> buf(KCompare16); TBuf16<256> str(KMatch16),
80 DEFINE_USER_BENCHMARK(TDesC16_MatchF,
81 TBuf16<256> buf(KCompare16); TBuf16<256> str(KMatch16_2),
85 DEFINE_EXTRA_BENCHMARK(TDes16_Append_TChar,
86 TBuf16<256> buf(KCompare16),
87 buf.SetLength(32); buf.Append(KChar));
89 DEFINE_EXTRA_BENCHMARK(TDes16_Append_TDesC16,
90 TBuf16<256> buf(KCompare16),
91 buf.SetLength(32); buf.Append(KString16));
93 DEFINE_EXTRA_BENCHMARK(TDes16_Append_pTUint16,
94 TBuf16<256> buf(KCompare16),
95 buf.SetLength(32); buf.Append(KCharData16, 32));
97 DEFINE_EXTRA_BENCHMARK(TDes16_Copy_TDesC16,
101 DEFINE_EXTRA_BENCHMARK(TDes16_Copy_pTUint16,
103 buf.Copy(KCharData16));
105 DEFINE_EXTRA_BENCHMARK(TDes16_Copy_pTUint16_TInt,
107 buf.Copy(KCharData16, 32));
109 DEFINE_EXTRA_BENCHMARK(TDes16_Fill,
110 TBuf16<256> buf(KCompare16),
113 DEFINE_EXTRA_BENCHMARK(TDes16_FillZ,
114 TBuf16<256> buf(KCompare16),
117 DEFINE_EXTRA_BENCHMARK(TDes16_LeftTPtr,
118 TBuf16<256> buf(KCompare16),
121 DEFINE_EXTRA_BENCHMARK(TDes16_RightTPtr,
122 TBuf16<256> buf(KCompare16),
125 DEFINE_EXTRA_BENCHMARK(TDes16_MidTPtr,
126 TBuf16<256> buf(KCompare16),
129 DEFINE_EXTRA_BENCHMARK(TDes16_PtrZ,
130 TBuf16<256> buf(KCompare16),
133 DEFINE_EXTRA_BENCHMARK(TDes16_SetLength,
134 TBuf16<256> buf(KCompare16),
137 DEFINE_EXTRA_BENCHMARK(TDes16_SetMax,
138 TBuf16<256> buf(KCompare16),
141 DEFINE_EXTRA_BENCHMARK(TDes16_ZeroTerminate,
142 TBuf16<256> buf(KCompare16),
143 buf.ZeroTerminate());
145 DEFINE_EXTRA_BENCHMARK(TDesC16_AtC,
149 DEFINE_EXTRA_BENCHMARK(TDesC16_Left,
153 DEFINE_EXTRA_BENCHMARK(TDesC16_Right,
155 KString16.Right(10));
157 DEFINE_EXTRA_BENCHMARK(TDesC16_Mid,
161 DEFINE_EXTRA_BENCHMARK(TDesC16_Locate,
163 KString16.Locate(KChar));
165 DEFINE_EXTRA_BENCHMARK(TDesC16_LocateReverse,
167 KString16.LocateReverse(KChar));
169 DEFINE_EXTRA_BENCHMARK(TDesC16_Ptr,
173 DEFINE_EXTRA_BENCHMARK(TPtr16_TPtr16,
175 new (&p) TPtr16(NULL, 0));
177 DEFINE_EXTRA_BENCHMARK(TPtr16_TPtr16_2,
179 new (&p) TPtr16(NULL, 0, 0));
181 DEFINE_EXTRA_BENCHMARK(TPtrC16_TPtrC16,
185 DEFINE_EXTRA_BENCHMARK(TPtrC16_TPtrC16_2,
187 new (&p) TPtrC16(KString16));
189 DEFINE_EXTRA_BENCHMARK(TPtrC16_TPtrC16_3,
191 new (&p) TPtrC16(KCharData16));
193 DEFINE_EXTRA_BENCHMARK(TPtrC16_TPtrC16_4,
195 new (&p) TPtrC16(KCharData16, 32));
197 DEFINE_EXTRA_BENCHMARK(TBufBase16_TBufBase16_1,
199 new (&b) TBuf16<256>());
201 DEFINE_EXTRA_BENCHMARK(TBufBase16_TBufBase16_2,
203 new (&b) TBuf16<256>(32));
205 DEFINE_EXTRA_BENCHMARK(TBufBase16_TBufBase16_3,
207 new (&b) TBuf16<256>(KCharData16));
209 DEFINE_EXTRA_BENCHMARK(TBufBase16_TBufBase16_4,
211 new (&b) TBuf16<256>(KString16));
213 DEFINE_EXTRA_BENCHMARK(TBufCBase16_TBufBaseC16_1,
215 new (&b) TBufC16<256>());
217 DEFINE_EXTRA_BENCHMARK(TBufCBase16_TBufBaseC16_2,
219 new (&b) TBufC16<256>(KCharData16));
221 DEFINE_EXTRA_BENCHMARK(TBufCBase16_TBufBaseC16_3,
223 new (&b) TBufC16<256>(KString16));
227 DEFINE_EXTRA_BENCHMARK(TDes8_Num,
229 buf.Num(0x35241525));
231 DEFINE_EXTRA_BENCHMARK(TDes8_Num_RadixHex,
233 buf.Num(0x35241525,EHex));
235 DEFINE_EXTRA_BENCHMARK(TDes8_Num_RadixDecimal,
237 buf.Num(0x35241525,EDecimal));
239 DEFINE_EXTRA_BENCHMARK(TDes8_Num_RadixOctal,
241 buf.Num(0x35241525,EOctal));
243 DEFINE_EXTRA_BENCHMARK(TDes8_Num_RadixBinary,
245 buf.Num(0x35241525,EBinary));
247 DEFINE_EXTRA_BENCHMARK(TDesC8_Compare,
248 TBuf8<256> buf(KCompare8); TBuf8<256> str(KCompare8),
251 DEFINE_EXTRA_BENCHMARK(TDesC8_CompareC,
252 TBuf8<256> buf(KCompare8); TBuf8<256> str(KCompare8_2),
255 DEFINE_EXTRA_BENCHMARK(TDesC8_CompareF,
256 TBuf8<256> buf(KCompare8); TBuf8<256> str(KCompare8_2),
259 DEFINE_EXTRA_BENCHMARK(TDesC8_Match,
260 TBuf8<256> buf(KCompare8); TBuf8<256> str(KMatch8),
263 DEFINE_EXTRA_BENCHMARK(TDesC8_MatchF,
264 TBuf8<256> buf(KCompare8); TBuf8<256> str(KMatch8_2),
267 DEFINE_EXTRA_BENCHMARK(TDes8_Append_TChar,
268 TBuf8<256> buf(KCompare8),
269 buf.SetLength(32); buf.Append(KChar));
271 DEFINE_EXTRA_BENCHMARK(TDes8_Append_TDesC8,
272 TBuf8<256> buf(KCompare8),
273 buf.SetLength(32); buf.Append(KString8));
275 DEFINE_EXTRA_BENCHMARK(TDes8_Append_pTUint8,
276 TBuf8<256> buf(KCompare8),
277 buf.SetLength(32); buf.Append(KCharData8, 32));
279 DEFINE_EXTRA_BENCHMARK(TDes8_Copy_TDesC8,
283 DEFINE_EXTRA_BENCHMARK(TDes8_Copy_pTUint8,
285 buf.Copy(KCharData8));
287 DEFINE_EXTRA_BENCHMARK(TDes8_Copy_pTUint8_TInt,
289 buf.Copy(KCharData8, 32));
291 DEFINE_EXTRA_BENCHMARK(TDes8_Fill,
292 TBuf8<256> buf(KCompare8),
295 DEFINE_EXTRA_BENCHMARK(TDes8_FillZ,
296 TBuf8<256> buf(KCompare8),
299 DEFINE_EXTRA_BENCHMARK(TDes8_LeftTPtr,
300 TBuf8<256> buf(KCompare8),
303 DEFINE_EXTRA_BENCHMARK(TDes8_RightTPtr,
304 TBuf8<256> buf(KCompare8),
307 DEFINE_EXTRA_BENCHMARK(TDes8_MidTPtr,
308 TBuf8<256> buf(KCompare8),
311 DEFINE_EXTRA_BENCHMARK(TDes8_PtrZ,
312 TBuf8<256> buf(KCompare8),
315 DEFINE_EXTRA_BENCHMARK(TDes8_SetLength,
316 TBuf8<256> buf(KCompare8),
319 DEFINE_EXTRA_BENCHMARK(TDes8_SetMax,
320 TBuf8<256> buf(KCompare8),
323 DEFINE_EXTRA_BENCHMARK(TDes8_ZeroTerminate,
324 TBuf8<256> buf(KCompare8),
325 buf.ZeroTerminate());
327 DEFINE_EXTRA_BENCHMARK(TDesC8_AtC,
331 DEFINE_EXTRA_BENCHMARK(TDesC8_Left,
335 DEFINE_EXTRA_BENCHMARK(TDesC8_Right,
339 DEFINE_EXTRA_BENCHMARK(TDesC8_Mid,
343 DEFINE_EXTRA_BENCHMARK(TDesC8_Locate,
345 KString8.Locate(KChar));
347 DEFINE_EXTRA_BENCHMARK(TDesC8_LocateReverse,
349 KString8.LocateReverse(KChar));
351 DEFINE_EXTRA_BENCHMARK(TDesC8_Ptr,
355 DEFINE_EXTRA_BENCHMARK(TPtr8_TPtr8,
357 new (&p) TPtr8(NULL, 0));
359 DEFINE_EXTRA_BENCHMARK(TPtr8_TPtr8_2,
361 new (&p) TPtr8(NULL, 0, 0));
363 DEFINE_EXTRA_BENCHMARK(TPtrC8_TPtrC8,
367 DEFINE_EXTRA_BENCHMARK(TPtrC8_TPtrC8_2,
369 new (&p) TPtrC8(KString8));
371 DEFINE_EXTRA_BENCHMARK(TPtrC8_TPtrC8_3,
373 new (&p) TPtrC8(KCharData8));
375 DEFINE_EXTRA_BENCHMARK(TPtrC8_TPtrC8_4,
377 new (&p) TPtrC8(KCharData8, 32));
379 DEFINE_EXTRA_BENCHMARK(TBufBase8_TBufBase8_1,
381 new (&b) TBuf8<256>());
383 DEFINE_EXTRA_BENCHMARK(TBufBase8_TBufBase8_2,
385 new (&b) TBuf8<256>(32));
387 DEFINE_EXTRA_BENCHMARK(TBufBase8_TBufBase8_3,
389 new (&b) TBuf8<256>(KCharData8));
391 DEFINE_EXTRA_BENCHMARK(TBufBase8_TBufBase8_4,
393 new (&b) TBuf8<256>(KString8));
395 DEFINE_EXTRA_BENCHMARK(TBufCBase8_TBufBaseC8_1,
397 new (&b) TBufC8<256>());
399 DEFINE_EXTRA_BENCHMARK(TBufCBase8_TBufBaseC8_2,
401 new (&b) TBufC8<256>(KCharData8));
403 DEFINE_EXTRA_BENCHMARK(TBufCBase8_TBufBaseC8_3,
405 new (&b) TBufC8<256>(KString8));