Update contrib.
2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #include "TCustomWrap.h"
20 #include "TGraphicsContext.h"
33 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
34 #include "TAGMA_INTERNAL.H"
37 #include "tformbenchmark.h"
39 namespace LocalToTFormBenchmark
41 CTFormBenchmarkStep* TestStep = NULL;
42 #define TESTPOINT(p) TestStep->testpoint(p,(TText8*)__FILE__,__LINE__)
43 #define TESTPRINT(p) TestStep->print(p,(TText8*)__FILE__,__LINE__)
45 using namespace LocalToTFormBenchmark;
50 _LIT(KFormBenchmark, "TFormBenchmark");
52 #if ((defined (__WINS__)) || (defined (__X86GCC__)))
53 _LIT(KLogTimeStampsName, "c:\\formtimestamps.csv");
55 _LIT(KLogTimeStampsName, "e:\\formtimestamps.csv");
58 _LIT(KEnglish, "Whereas recognition of the inherent dignity and of the equal \
59 and inalienable rights of all members of the human family is the foundation \
60 of freedom, justice and peace in the world, ");
61 const TInt KEnglishRepeats = 119;
62 _LIT(KArabic, "\x644\x645\x651\x627 \x643\x627\x646 \x627\x644\x627\x639\x62A\
63 \x631\x627\x641 \x628\x627\x644\x643\x631\x627\x645\x629 \x627\x644\x645\x62A\
64 \x623\x635\x644\x629 \x641\x64A \x62C\x645\x64A\x639 \x623\x639\x636\x627\
65 \x621 \x627\x644\x623\x633\x631\x629 \x627\x644\x628\x634\x631\x64A\x629\
66 \x648\x628\x62D\x642\x648\x642\x647\x645 \x627\x644\x645\x62A\x633\x627\
67 \x648\x64A\x629 \x627\x644\x62B\x627\x628\x62A\x629 \x647\x648 \x623\x633\
68 \x627\x633 \x627\x644\x62D\x631\x64A\x629 \x648\x627\x644\x639\x62F\x644\
69 \x648\x627\x644\x633\x644\x627\x645 \x641\x64A \x627\x644\x639\x627\x644\
71 const TInt KArabicRepeats = 156;
72 _LIT(KJapanese, "\x4EBA\x985E\x793E\x4F1A\x306E\x3059\x3079\x3066\x306E\x69CB\
73 \x6210\x54E1\x306E\x56FA\x6709\x306E\x5C0A\x53B3\x3068\x5E73\x7B49\x3067\x8B72\
74 \x308B\x3053\x3068\x306E\x3067\x304D\x306A\x3044\x6A29\x5229\x3068\x3092\
75 \x627F\x8A8D\x3059\x308B\x3053\x3068\x306F\x3001\x4E16\x754C\x306B\x304A\
76 \x3051\x308B\x81EA\x7531\x3001\x6B63\x7FA9\x53CA\x3073\x5E73\x548C\x306E\
77 \x57FA\x790E\x3067\x3042\x308B\x306E\x3067\x3001 ");
78 const TInt KJapaneseRepeats = 357;
79 const TInt KDisplayWidth = 100;
80 const TInt KDisplayHeight = 120;
82 const TInt KInsertDisplayWidth = 200;
83 const TInt KChangedDisplayWidth = 150;
85 _LIT(KEnglishToInsert1, "Whereas recognition of the inherent dignity");
86 _LIT(KEnglishToInsert2, " and of the equal and inalienable rights of all... and so on");
88 const TInt KEnglishInsertRepeats = 400;
89 const TInt KEnglishScrollRepeats = 100;
91 const TInt KDeleteTextInterval = 10;//we measure delete text once for each 10 deletes, to make the output smaller
93 _LIT8(KDeleteTextFromStart, "Delete text from start\r\n");
94 _LIT8(KInsertTextAtStart, "Insert text at start\r\n");
95 _LIT8(KScrollingUp, "Scrolling up\r\n");
96 _LIT8(KScrollingDown, "Scrolling down\r\n");
100 TDocInfo():iDocLength(0), iDocParaCount(0), iLineCount(0){}
112 struct TFormattingObjects
115 CParaFormatLayer* iParFormat;
116 CCharFormatLayer* iCharFormat;
117 CRichText* iRichText;
118 CTextLayout* iLayout;
119 CTestGraphicsDevice* iDevice;
124 Functions for writing benchmarking data to the CSV
126 void WriteSampleDocInfo(TDocInfo aDocInfo, RFile aDest)
129 buf.Format(_L8("Sample text: %d characters: %d paras: %d lines\r\n"), aDocInfo.iDocLength, aDocInfo.iDocParaCount, aDocInfo.iLineCount);
133 void WriteTimeStampsL(const TDesC8& aTitle, RArray<TTFTimeStamp>& aTimeStamps)
135 fileTimeStamps.Write(aTitle);
136 for (TInt i = 0; i < aTimeStamps.Count(); i++)
138 TTFTimeStamp timestamp = aTimeStamps[i];
140 buf.Format(_L8("%d, %Ld\r\n"), timestamp.iIteration, timestamp.iTime/1000);
141 fileTimeStamps.Write(buf);
145 TDocInfo GetSampleDocInfoL(TFormattingObjects& aFormattingObjects)
148 const CTmTextLayout& layout = aFormattingObjects.iView->Layout()->TagmaTextLayout();
149 docInfo.iDocLength = layout.Source()->DocumentLength();
150 docInfo.iDocParaCount = aFormattingObjects.iRichText->ParagraphCount();
151 //very peculiar way to count the lines...
152 TCursorPosition::TMovementType move = TCursorPosition::EFLineDown;
153 while (move == TCursorPosition::EFLineDown)
155 aFormattingObjects.iView->MoveCursorL(move, EFalse);
157 move = TCursorPosition::EFLineUp;
158 while (move == TCursorPosition::EFLineUp)
160 docInfo.iLineCount++;
161 aFormattingObjects.iView->MoveCursorL(move, EFalse);
167 Set up the test document
169 void SetTextL(CRichText& aText, const TDesC& aSample, TInt aRepeats, TInt aRepeatsPerPara)
171 TInt repeatsInThisPar = 0;
173 for (; aRepeats != 0; --aRepeats)
175 aText.InsertL(0, aSample);
177 if (repeatsInThisPar > aRepeatsPerPara)
179 TChar paragraphDelimiter(0x2029);
180 aText.InsertL(0, paragraphDelimiter);
181 repeatsInThisPar = 0;
186 _LIT(KOneWord, "blahblahblahblahblahblahblahblah");
188 void BigBufLC(RBuf& aBigBuf)
190 aBigBuf.CreateL(16384);
191 aBigBuf.CleanupClosePushL();
192 while(aBigBuf.Length()+KOneWord().Length() < aBigBuf.MaxLength())
194 aBigBuf.Append(KOneWord);
198 TTimeIntervalMicroSeconds MeasureOpeningL(CTextView& aView)
200 TCursorSelection zero(0, 0);
201 aView.SetPendingSelection(zero);
204 start.UniversalTime();
205 aView.HandleGlobalChangeL();
207 return end.MicroSecondsFrom(start);
210 TTimeIntervalMicroSeconds MeasureRmsCursorDownL(CTextView& aView)
213 TInt cells = User::AllocSize(mem);
214 TReal totalOfSquares = 0;
217 TCursorPosition::TMovementType move = TCursorPosition::EFLineDown;
218 while (move == TCursorPosition::EFLineDown)
220 start.UniversalTime();
221 aView.MoveCursorL(move, EFalse);
223 TReal us = end.MicroSecondsFrom(start).Int64();
224 totalOfSquares += us*us;
227 Math::Sqrt(rms, totalOfSquares);
228 cells = User::AllocSize(mem);
229 return TTimeIntervalMicroSeconds(static_cast<TInt64>(rms));
232 TInt NumberOfLines(CTextLayout& aLayout)
234 TTmDocPosSpec dp(aLayout.DocumentLength(), TTmDocPosSpec::ETrailing);
236 TTmLineInfo lineInfo;
237 aLayout.FindDocPos(dp, posInfo, &lineInfo);
238 return lineInfo.iLineNumber;
241 TTimeIntervalMicroSeconds MeasureFormattingL(CTextView& aView)
243 // This looks to me like a defect.
244 // We have to set the actual doc pos to prevent a crash, even
245 // though we are setting a pending selection.
246 // Probably not too serious, though.
247 aView.SetDocPosL(0, ETrue);
248 TCursorSelection zero(0, 0);
249 aView.SetPendingSelection(zero);
252 start.UniversalTime();
253 aView.HandleGlobalChangeL();
254 aView.FinishBackgroundFormattingL();
257 return end.MicroSecondsFrom(start);
260 void MeasureDeleteTextFromStartL(RArray<TTFTimeStamp>& aTimeStamps,
261 TFormattingObjects& aFormattingObjects, TInt64& aSlowest)
263 const CTmTextLayout& tmLayout = aFormattingObjects.iLayout->TagmaTextLayout();
271 while(aFormattingObjects.iRichText->DocumentLength() > 0)
273 aFormattingObjects.iRichText->DeleteL(0, 1);
274 TCursorSelection cursor(0,0);
275 start.UniversalTime();
276 aFormattingObjects.iView->HandleInsertDeleteL(cursor, 1, EFalse);
279 TInt64 us = end.MicroSecondsFrom(start).Int64();
288 if(step == KDeleteTextInterval)
290 TInt64 average = total/KDeleteTextInterval;
291 TTFTimeStamp timestamp;
292 timestamp.iTime = average;
293 timestamp.iIteration = iteration;
294 User::LeaveIfError(aTimeStamps.Append(timestamp));
302 void MeasureInsertTextAtStartL(TInt aRepeats, TInt aRepeatsPerPara, RArray<TTFTimeStamp>& aTimeStamps,
303 TFormattingObjects& aFormattingObjects, TInt64& aSlowest)
308 TInt repeatsInThisPar = 0;
309 TViewRectChanges changes;
310 aFormattingObjects.iRichText->Reset();
311 for (TInt i = 0; i < aRepeats; i++)
316 sample = KEnglishToInsert1;
320 sample = KEnglishToInsert2;
322 aFormattingObjects.iRichText->InsertL(0, sample);
323 TCursorSelection cursor(0, sample.Length());
325 start.UniversalTime();
326 aFormattingObjects.iLayout->HandleBlockChangeL(cursor, 0, changes, 0);
329 TInt64 us = end.MicroSecondsFrom(start).Int64();
331 TTFTimeStamp timestamp;
332 timestamp.iTime = us;
333 timestamp.iIteration = i;
334 User::LeaveIfError(aTimeStamps.Append(timestamp));
339 if (repeatsInThisPar > aRepeatsPerPara)
341 TChar paragraphDelimiter(0x2029);
342 aFormattingObjects.iRichText->InsertL(0, paragraphDelimiter);
343 repeatsInThisPar = 0;
348 void MeasureCursorL(RArray<TTFTimeStamp>& aTimeStamps, TCursorPosition::TMovementType aType,
349 TFormattingObjects& aFormattingObjects, TInt64& aSlowest)
355 TCursorPosition::TMovementType move = aType;
357 while (move == aType)
360 start.UniversalTime();
361 aFormattingObjects.iView->MoveCursorL(move, EFalse);
363 TInt64 us = end.MicroSecondsFrom(start).Int64();
364 TTFTimeStamp timestamp;
365 timestamp.iTime = us;
366 timestamp.iIteration = lines;
367 User::LeaveIfError(aTimeStamps.Append(timestamp));
372 const CTmTextLayout& tmLayout = aFormattingObjects.iLayout->TagmaTextLayout();
376 void CreateFormattingObjectsLC(TFormattingObjects& aFormattingObjects)
378 TRect* displayRect = new(ELeave) TRect(0, 0, KDisplayWidth, KDisplayHeight);
379 CleanupStack::PushL(displayRect);
380 CParaFormatLayer* paraFormat = CParaFormatLayer::NewL();
381 CleanupStack::PushL(paraFormat);
382 CCharFormatLayer* charFormat = CCharFormatLayer::NewL();
383 CleanupStack::PushL(charFormat);
384 CRichText* text = CRichText::NewL(paraFormat, charFormat);
385 CleanupStack::PushL(text);
386 CTextLayout* layout = CTextLayout::NewL(text, displayRect->Width());
387 CleanupStack::PushL(layout);
388 CTestGraphicsDevice* device = CTestGraphicsDevice::NewL(displayRect->Size(), 0);
389 CleanupStack::PushL(device);
390 // Prevent the line array from using up the memory
391 device->LineArray().Disable();
392 CTextView* view = CTextView::NewL(layout, *displayRect,
393 device, device, 0, 0, 0);
394 CleanupStack::PushL(view);
395 // must disable flicker-free redraw or Form will try to use
396 // the test font with an off-screen (i.e. real) graphics context,
398 view->DisableFlickerFreeRedraw();
400 aFormattingObjects.iDisplayRect = displayRect;
401 aFormattingObjects.iParFormat = paraFormat;
402 aFormattingObjects.iCharFormat = charFormat;
403 aFormattingObjects.iRichText = text;
404 aFormattingObjects.iLayout = layout;
405 aFormattingObjects.iDevice = device;
406 aFormattingObjects.iView = view;
409 void DestroyFormattingObjects(TFormattingObjects& aFormattingObjects)
411 CleanupStack::PopAndDestroy(aFormattingObjects.iView);
412 CleanupStack::PopAndDestroy(aFormattingObjects.iDevice);
413 CleanupStack::PopAndDestroy(aFormattingObjects.iLayout);
414 CleanupStack::PopAndDestroy(aFormattingObjects.iRichText);
415 CleanupStack::PopAndDestroy(aFormattingObjects.iCharFormat);
416 CleanupStack::PopAndDestroy(aFormattingObjects.iParFormat);
417 CleanupStack::PopAndDestroy(aFormattingObjects.iDisplayRect);
421 @SYMTestCaseID SYSLIB-FORMA-UT-1897
422 @SYMTestCaseDesc Benchmarks scrolling text
423 @SYMTestPriority High
424 @SYMTestActions creates document and scrolls it
425 @SYMTestExpectedResults The test must not fail or panic .
426 @SYMDEF DEF092140, DEF092139
428 void RunScrollingTestL(TInt aRepeats, TInt aRepeatsPerParagraph,
429 RArray<TTFTimeStamp>& aTimeStampsDown, RArray<TTFTimeStamp>& aTimeStampsUp,
432 TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1897 "));
433 TInt docLength = KEnglish().Length() * aRepeats;
434 TInt paragraphs = aRepeats/aRepeatsPerParagraph;
436 TFormattingObjects o;
437 CreateFormattingObjectsLC(o);
438 o.iLayout->SetWrapWidth(KInsertDisplayWidth);
439 o.iLayout->SetAmountToFormat(CTextLayout::EFFormatBand);
440 SetTextL(*(o.iRichText), KEnglish, aRepeats, aRepeatsPerParagraph);
442 TTimeIntervalMicroSeconds opening = MeasureOpeningL(*(o.iView));
444 MeasureCursorL(aTimeStampsDown, TCursorPosition::EFLineDown, o, slowest);
445 MeasureCursorL(aTimeStampsUp, TCursorPosition::EFLineUp, o, slowest);
448 buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_Scrolling_Slowest_Doc_with_%d_characters_%d_paragraphs;microseconds: %Ld"), docLength, paragraphs, slowest);
451 aDocInfo = GetSampleDocInfoL(o);
452 DestroyFormattingObjects(o);
456 @SYMTestCaseID SYSLIB-FORMA-UT-1898
457 @SYMTestCaseDesc Benchmarks inserting, deleting and formatting text
458 @SYMTestPriority High
459 @SYMTestActions creates documents in each language and performs edits and reformats
460 @SYMTestExpectedResults The test must not fail or panic .
461 @SYMDEF DEF092140, DEF092139
463 void RunEnglishArabicJapaneseBenchmarksL(TFormattingObjects& aFormattingObjects)
465 TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1898 "));
466 SetTextL(*aFormattingObjects.iRichText, KEnglish, KEnglishRepeats, KEnglishRepeats);
467 TTimeIntervalMicroSeconds opening = MeasureOpeningL(*aFormattingObjects.iView);
468 TTimeIntervalMicroSeconds rmsCursorDown = MeasureRmsCursorDownL(*aFormattingObjects.iView);
469 TTimeIntervalMicroSeconds englishFormatting = MeasureFormattingL(*aFormattingObjects.iView);
470 TInt englishLines = NumberOfLines(*aFormattingObjects.iLayout);
471 SetTextL(*aFormattingObjects.iRichText, KArabic, KArabicRepeats, KArabicRepeats);
472 TTimeIntervalMicroSeconds arabicFormatting = MeasureFormattingL(*aFormattingObjects.iView);
473 TInt arabicLines = NumberOfLines(*aFormattingObjects.iLayout);
474 SetTextL(*aFormattingObjects.iRichText, KJapanese, KJapaneseRepeats, KJapaneseRepeats);
475 TTimeIntervalMicroSeconds japaneseFormatting = MeasureFormattingL(*aFormattingObjects.iView);
476 TInt japaneseLines = NumberOfLines(*aFormattingObjects.iLayout);
478 // Check that the results are fair
481 if (arabicLines < englishLines)
483 minLines = arabicLines;
484 maxLines = englishLines;
488 minLines = englishLines;
489 maxLines = arabicLines;
491 if (japaneseLines < minLines)
492 minLines = japaneseLines;
493 else if (maxLines < japaneseLines)
494 maxLines = japaneseLines;
496 //Tests that the number of lines in each test is more or less balanced
497 TESTPOINT(maxLines * 100 <= minLines * 105);
500 buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_OpeningLargeParagraph;microseconds: %d"),
501 static_cast<TInt>(opening.Int64()));
505 buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_RmsCursorDown;microseconds: %d"),
506 static_cast<TInt>(rmsCursorDown.Int64()));
510 buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormattingEnglish;microseconds: %d"),
511 static_cast<TInt>(englishFormatting.Int64()));
515 buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormattingArabic;microseconds: %d"),
516 static_cast<TInt>(arabicFormatting.Int64()));
520 buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormattingJapanese;microseconds: %d"),
521 static_cast<TInt>(japaneseFormatting.Int64()));
526 @SYMTestCaseID SYSLIB-FORMA-UT-1896
527 @SYMTestCaseDesc Benchmarks inserting text from the beginning of a paragraph
528 @SYMTestPriority High
529 @SYMTestActions creates a large paragraph containg just one word and inserts text iteratively from
531 @SYMTestExpectedResults The test must not fail or panic .
532 @SYMDEF DEF092140, DEF092139
534 void RunInsertTextTestsL(TInt aRepeats, TInt aRepeatsPerParagraph,
535 RArray<TTFTimeStamp>& aTimeStamps, TDocInfo& aDocInfo)
537 TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1896 "));
538 TFormattingObjects o;
539 CreateFormattingObjectsLC(o);
541 o.iLayout->SetWrapWidth(KInsertDisplayWidth);
542 o.iLayout->SetAmountToFormat(CTextLayout::EFFormatBand);
543 MeasureInsertTextAtStartL(aRepeats, aRepeatsPerParagraph, aTimeStamps, o, slowest);
544 aDocInfo = GetSampleDocInfoL(o);
547 buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_InsertText_Slowest;microseconds: %Ld"), slowest);
550 DestroyFormattingObjects(o);
554 @SYMTestCaseID SYSLIB-FORMA-UT-1895
555 @SYMTestCaseDesc Benchmarks deleting text from the beginning of a paragraph
556 @SYMTestPriority High
557 @SYMTestActions creates a large paragraph containg just one word and deletes text iteratively from
559 @SYMTestExpectedResults The test must not fail or panic .
560 @SYMDEF DEF092140, DEF092139
562 void RunDeleteTextFromStartTest(RArray<TTFTimeStamp>& aTimeStamps, TDocInfo& aDocInfo)
564 TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1895 "));
565 TFormattingObjects o;
566 CreateFormattingObjectsLC(o);
568 o.iLayout->SetWrapWidth(KInsertDisplayWidth);
569 o.iLayout->SetAmountToFormat(CTextLayout::EFFormatBand);
572 SetTextL(*o.iRichText, bigbuf, 1, 1);
573 TTimeIntervalMicroSeconds opening = MeasureOpeningL(*o.iView);
575 MeasureDeleteTextFromStartL(aTimeStamps, o, slowest);
576 aDocInfo = GetSampleDocInfoL(o);
579 buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_DeleteText_Slowest;microseconds: %Ld"), slowest);
582 CleanupStack::PopAndDestroy();//bigbuf
583 DestroyFormattingObjects(o);
586 void GetFormattingBenchmarkL(TInt aNumberOfIterations, TInt& aNumberOfCharacters, TInt64& aNormalisedBenchmark)
588 TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1895 "));
589 TFormattingObjects o;
590 CreateFormattingObjectsLC(o);
591 o.iLayout->SetWrapWidth(KInsertDisplayWidth);
592 o.iLayout->SetAmountToFormat(CTextLayout::EFFormatBand);
594 SetTextL(*(o.iRichText), KEnglish, aNumberOfIterations, aNumberOfIterations);
596 TTimeIntervalMicroSeconds ignore = MeasureOpeningL(*(o.iView));
597 o.iView->SetDocPosL(o.iRichText->DocumentLength());
598 //make a global change
599 o.iLayout->SetWrapWidth(KChangedDisplayWidth);
600 //measure time to reformat for it
603 start.UniversalTime();
604 o.iView->HandleGlobalChangeL();
607 TTimeIntervalMicroSeconds formattingTime = end.MicroSecondsFrom(start);
609 aNumberOfCharacters = o.iRichText->DocumentLength();
610 aNormalisedBenchmark = formattingTime.Int64()/aNumberOfIterations;
612 DestroyFormattingObjects(o);
616 @SYMTestCaseID SYSLIB-FORMA-UT-1894
617 @SYMTestCaseDesc Benchmarks formatting text
618 @SYMTestPriority High
619 @SYMTestActions for a series of documents of increasing size consisting of a single paragraph,
620 sets the cursor position to the end of the document, makes a global change and formats it.
621 @SYMTestExpectedResults The test must not fail or panic. The increase in time taken should be
622 roughly linear with the document size.
625 void RunFormattingBenchmarksL()
627 TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1894 "));
628 TInt numberOfCharacters = 0;
629 TInt numberOfIterations;
630 TInt64 normalisedBenchmark = 0;
634 numberOfIterations = 1;
635 GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark);
636 buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark);
640 numberOfIterations = 5;
641 GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark);
642 buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark);
646 numberOfIterations = 10;
647 GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark);
648 buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark);
652 numberOfIterations = 50;
653 GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark);
654 buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark);
658 numberOfIterations = 100;
659 GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark);
660 buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark);
664 numberOfIterations = 250;
665 GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark);
666 buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark);
670 numberOfIterations = 500;
671 GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark);
672 buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark);
676 numberOfIterations = 750;
677 GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark);
678 buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark);
682 numberOfIterations = 1000;
683 GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark);
684 buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark);
688 void RunBenchmarksL()
690 CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
691 CleanupStack::PushL(scheduler);
692 CActiveScheduler::Install(scheduler);
694 RunFormattingBenchmarksL();
697 RArray<TTFTimeStamp> timestampsDown;
698 RArray<TTFTimeStamp> timestampsUp;
699 CleanupClosePushL(timestampsDown);
700 CleanupClosePushL(timestampsUp);
702 RunDeleteTextFromStartTest(timestampsUp, docInfo);
703 WriteSampleDocInfo(docInfo, fileTimeStamps);
704 WriteTimeStampsL(KDeleteTextFromStart, timestampsUp);
706 RunInsertTextTestsL(KEnglishInsertRepeats, KEnglishInsertRepeats, timestampsUp, docInfo);
707 WriteSampleDocInfo(docInfo, fileTimeStamps);
708 WriteTimeStampsL(KInsertTextAtStart, timestampsUp);
710 RunScrollingTestL(KEnglishScrollRepeats, KEnglishScrollRepeats, timestampsDown, timestampsUp, docInfo);
711 WriteSampleDocInfo(docInfo, fileTimeStamps);
712 WriteTimeStampsL(KScrollingDown, timestampsDown);
713 WriteTimeStampsL(KScrollingUp, timestampsUp);
715 RunScrollingTestL(KEnglishScrollRepeats, KEnglishScrollRepeats/2, timestampsDown, timestampsUp, docInfo);
716 WriteSampleDocInfo(docInfo, fileTimeStamps);
717 WriteTimeStampsL(KScrollingDown, timestampsDown);
718 WriteTimeStampsL(KScrollingUp, timestampsUp);
720 RunScrollingTestL(KEnglishScrollRepeats, KEnglishScrollRepeats/10, timestampsDown, timestampsUp, docInfo);
721 WriteSampleDocInfo(docInfo, fileTimeStamps);
722 WriteTimeStampsL(KScrollingDown, timestampsDown);
723 WriteTimeStampsL(KScrollingUp, timestampsUp);
725 TFormattingObjects o;
726 CreateFormattingObjectsLC(o);
727 RunEnglishArabicJapaneseBenchmarksL(o);
728 DestroyFormattingObjects(o);
730 CleanupStack::PopAndDestroy(2);
731 CleanupStack::PopAndDestroy(scheduler);
735 TVerdict CTFormBenchmarkStep::doTestStepL()
737 SetTestStepResult(EPass);
740 TESTPRINT(KFormBenchmark);
741 TESTPRINT(_L("Start Font/Bitmap Server"));
743 TInt error = RFbsSession::Connect();
744 if (error == KErrNotFound)
747 error = RFbsSession::Connect();
749 // Tests that FBServ actually starts
750 TESTPOINT(error == KErrNone);
751 error = fs.Connect();
752 TESTPOINT(error == KErrNone);
754 error = fileTimeStamps.Replace(fs, KLogTimeStampsName, EFileWrite);
757 buf.AppendFormat(_L("> fileTimeStamps.Replace %d"), error);
760 TESTPOINT(error == KErrNone);
762 TESTPRINT(_L("Run Benchmarks"));
763 TRAP(error, RunBenchmarksL());
764 // Tests that the Benchmarks did not run out of memory
765 // or otherwise leave
766 TESTPOINT(error == KErrNone);
768 fileTimeStamps.Close();
770 RFbsSession::Disconnect();
772 return TestStepResult();