sl@0: /* sl@0: * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include "TCustomWrap.h" sl@0: #include "TGraphicsContext.h" sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS sl@0: #include "TAGMA_INTERNAL.H" sl@0: #endif sl@0: sl@0: #include "tformbenchmark.h" sl@0: sl@0: namespace LocalToTFormBenchmark sl@0: { sl@0: CTFormBenchmarkStep* TestStep = NULL; sl@0: #define TESTPOINT(p) TestStep->testpoint(p,(TText8*)__FILE__,__LINE__) sl@0: #define TESTPRINT(p) TestStep->print(p,(TText8*)__FILE__,__LINE__) sl@0: } sl@0: using namespace LocalToTFormBenchmark; sl@0: sl@0: RFs fs; sl@0: RFile fileTimeStamps; sl@0: sl@0: _LIT(KFormBenchmark, "TFormBenchmark"); sl@0: sl@0: #if ((defined (__WINS__)) || (defined (__X86GCC__))) sl@0: _LIT(KLogTimeStampsName, "c:\\formtimestamps.csv"); sl@0: #else sl@0: _LIT(KLogTimeStampsName, "e:\\formtimestamps.csv"); sl@0: #endif sl@0: sl@0: _LIT(KEnglish, "Whereas recognition of the inherent dignity and of the equal \ sl@0: and inalienable rights of all members of the human family is the foundation \ sl@0: of freedom, justice and peace in the world, "); sl@0: const TInt KEnglishRepeats = 119; sl@0: _LIT(KArabic, "\x644\x645\x651\x627 \x643\x627\x646 \x627\x644\x627\x639\x62A\ sl@0: \x631\x627\x641 \x628\x627\x644\x643\x631\x627\x645\x629 \x627\x644\x645\x62A\ sl@0: \x623\x635\x644\x629 \x641\x64A \x62C\x645\x64A\x639 \x623\x639\x636\x627\ sl@0: \x621 \x627\x644\x623\x633\x631\x629 \x627\x644\x628\x634\x631\x64A\x629\ sl@0: \x648\x628\x62D\x642\x648\x642\x647\x645 \x627\x644\x645\x62A\x633\x627\ sl@0: \x648\x64A\x629 \x627\x644\x62B\x627\x628\x62A\x629 \x647\x648 \x623\x633\ sl@0: \x627\x633 \x627\x644\x62D\x631\x64A\x629 \x648\x627\x644\x639\x62F\x644\ sl@0: \x648\x627\x644\x633\x644\x627\x645 \x641\x64A \x627\x644\x639\x627\x644\ sl@0: \x645. "); sl@0: const TInt KArabicRepeats = 156; sl@0: _LIT(KJapanese, "\x4EBA\x985E\x793E\x4F1A\x306E\x3059\x3079\x3066\x306E\x69CB\ sl@0: \x6210\x54E1\x306E\x56FA\x6709\x306E\x5C0A\x53B3\x3068\x5E73\x7B49\x3067\x8B72\ sl@0: \x308B\x3053\x3068\x306E\x3067\x304D\x306A\x3044\x6A29\x5229\x3068\x3092\ sl@0: \x627F\x8A8D\x3059\x308B\x3053\x3068\x306F\x3001\x4E16\x754C\x306B\x304A\ sl@0: \x3051\x308B\x81EA\x7531\x3001\x6B63\x7FA9\x53CA\x3073\x5E73\x548C\x306E\ sl@0: \x57FA\x790E\x3067\x3042\x308B\x306E\x3067\x3001 "); sl@0: const TInt KJapaneseRepeats = 357; sl@0: const TInt KDisplayWidth = 100; sl@0: const TInt KDisplayHeight = 120; sl@0: sl@0: const TInt KInsertDisplayWidth = 200; sl@0: const TInt KChangedDisplayWidth = 150; sl@0: sl@0: _LIT(KEnglishToInsert1, "Whereas recognition of the inherent dignity"); sl@0: _LIT(KEnglishToInsert2, " and of the equal and inalienable rights of all... and so on"); sl@0: sl@0: const TInt KEnglishInsertRepeats = 400; sl@0: const TInt KEnglishScrollRepeats = 100; sl@0: sl@0: const TInt KDeleteTextInterval = 10;//we measure delete text once for each 10 deletes, to make the output smaller sl@0: sl@0: _LIT8(KDeleteTextFromStart, "Delete text from start\r\n"); sl@0: _LIT8(KInsertTextAtStart, "Insert text at start\r\n"); sl@0: _LIT8(KScrollingUp, "Scrolling up\r\n"); sl@0: _LIT8(KScrollingDown, "Scrolling down\r\n"); sl@0: sl@0: struct TDocInfo sl@0: { sl@0: TDocInfo():iDocLength(0), iDocParaCount(0), iLineCount(0){} sl@0: TInt iDocLength; sl@0: TInt iDocParaCount; sl@0: TInt iLineCount; sl@0: }; sl@0: sl@0: struct TTFTimeStamp sl@0: { sl@0: TInt64 iTime; sl@0: TInt iIteration; sl@0: }; sl@0: sl@0: struct TFormattingObjects sl@0: { sl@0: TRect* iDisplayRect; sl@0: CParaFormatLayer* iParFormat; sl@0: CCharFormatLayer* iCharFormat; sl@0: CRichText* iRichText; sl@0: CTextLayout* iLayout; sl@0: CTestGraphicsDevice* iDevice; sl@0: CTextView* iView; sl@0: }; sl@0: sl@0: /* sl@0: Functions for writing benchmarking data to the CSV sl@0: */ sl@0: void WriteSampleDocInfo(TDocInfo aDocInfo, RFile aDest) sl@0: { sl@0: TBuf8<128> buf; sl@0: buf.Format(_L8("Sample text: %d characters: %d paras: %d lines\r\n"), aDocInfo.iDocLength, aDocInfo.iDocParaCount, aDocInfo.iLineCount); sl@0: aDest.Write(buf); sl@0: } sl@0: sl@0: void WriteTimeStampsL(const TDesC8& aTitle, RArray& aTimeStamps) sl@0: { sl@0: fileTimeStamps.Write(aTitle); sl@0: for (TInt i = 0; i < aTimeStamps.Count(); i++) sl@0: { sl@0: TTFTimeStamp timestamp = aTimeStamps[i]; sl@0: TBuf8<128> buf; sl@0: buf.Format(_L8("%d, %Ld\r\n"), timestamp.iIteration, timestamp.iTime/1000); sl@0: fileTimeStamps.Write(buf); sl@0: } sl@0: } sl@0: sl@0: TDocInfo GetSampleDocInfoL(TFormattingObjects& aFormattingObjects) sl@0: { sl@0: TDocInfo docInfo; sl@0: const CTmTextLayout& layout = aFormattingObjects.iView->Layout()->TagmaTextLayout(); sl@0: docInfo.iDocLength = layout.Source()->DocumentLength(); sl@0: docInfo.iDocParaCount = aFormattingObjects.iRichText->ParagraphCount(); sl@0: //very peculiar way to count the lines... sl@0: TCursorPosition::TMovementType move = TCursorPosition::EFLineDown; sl@0: while (move == TCursorPosition::EFLineDown) sl@0: { sl@0: aFormattingObjects.iView->MoveCursorL(move, EFalse); sl@0: } sl@0: move = TCursorPosition::EFLineUp; sl@0: while (move == TCursorPosition::EFLineUp) sl@0: { sl@0: docInfo.iLineCount++; sl@0: aFormattingObjects.iView->MoveCursorL(move, EFalse); sl@0: } sl@0: return docInfo; sl@0: } sl@0: sl@0: /* sl@0: Set up the test document sl@0: */ sl@0: void SetTextL(CRichText& aText, const TDesC& aSample, TInt aRepeats, TInt aRepeatsPerPara) sl@0: { sl@0: TInt repeatsInThisPar = 0; sl@0: aText.Reset(); sl@0: for (; aRepeats != 0; --aRepeats) sl@0: { sl@0: aText.InsertL(0, aSample); sl@0: repeatsInThisPar ++; sl@0: if (repeatsInThisPar > aRepeatsPerPara) sl@0: { sl@0: TChar paragraphDelimiter(0x2029); sl@0: aText.InsertL(0, paragraphDelimiter); sl@0: repeatsInThisPar = 0; sl@0: } sl@0: } sl@0: } sl@0: sl@0: _LIT(KOneWord, "blahblahblahblahblahblahblahblah"); sl@0: sl@0: void BigBufLC(RBuf& aBigBuf) sl@0: { sl@0: aBigBuf.CreateL(16384); sl@0: aBigBuf.CleanupClosePushL(); sl@0: while(aBigBuf.Length()+KOneWord().Length() < aBigBuf.MaxLength()) sl@0: { sl@0: aBigBuf.Append(KOneWord); sl@0: } sl@0: } sl@0: sl@0: TTimeIntervalMicroSeconds MeasureOpeningL(CTextView& aView) sl@0: { sl@0: TCursorSelection zero(0, 0); sl@0: aView.SetPendingSelection(zero); sl@0: TTime start; sl@0: TTime end; sl@0: start.UniversalTime(); sl@0: aView.HandleGlobalChangeL(); sl@0: end.UniversalTime(); sl@0: return end.MicroSecondsFrom(start); sl@0: } sl@0: sl@0: TTimeIntervalMicroSeconds MeasureRmsCursorDownL(CTextView& aView) sl@0: { sl@0: TInt mem; sl@0: TInt cells = User::AllocSize(mem); sl@0: TReal totalOfSquares = 0; sl@0: TTime start; sl@0: TTime end; sl@0: TCursorPosition::TMovementType move = TCursorPosition::EFLineDown; sl@0: while (move == TCursorPosition::EFLineDown) sl@0: { sl@0: start.UniversalTime(); sl@0: aView.MoveCursorL(move, EFalse); sl@0: end.UniversalTime(); sl@0: TReal us = end.MicroSecondsFrom(start).Int64(); sl@0: totalOfSquares += us*us; sl@0: } sl@0: TReal rms; sl@0: Math::Sqrt(rms, totalOfSquares); sl@0: cells = User::AllocSize(mem); sl@0: return TTimeIntervalMicroSeconds(static_cast(rms)); sl@0: } sl@0: sl@0: TInt NumberOfLines(CTextLayout& aLayout) sl@0: { sl@0: TTmDocPosSpec dp(aLayout.DocumentLength(), TTmDocPosSpec::ETrailing); sl@0: TTmPosInfo2 posInfo; sl@0: TTmLineInfo lineInfo; sl@0: aLayout.FindDocPos(dp, posInfo, &lineInfo); sl@0: return lineInfo.iLineNumber; sl@0: } sl@0: sl@0: TTimeIntervalMicroSeconds MeasureFormattingL(CTextView& aView) sl@0: { sl@0: // This looks to me like a defect. sl@0: // We have to set the actual doc pos to prevent a crash, even sl@0: // though we are setting a pending selection. sl@0: // Probably not too serious, though. sl@0: aView.SetDocPosL(0, ETrue); sl@0: TCursorSelection zero(0, 0); sl@0: aView.SetPendingSelection(zero); sl@0: TTime start; sl@0: TTime end; sl@0: start.UniversalTime(); sl@0: aView.HandleGlobalChangeL(); sl@0: aView.FinishBackgroundFormattingL(); sl@0: end.UniversalTime(); sl@0: end.UniversalTime(); sl@0: return end.MicroSecondsFrom(start); sl@0: } sl@0: sl@0: void MeasureDeleteTextFromStartL(RArray& aTimeStamps, sl@0: TFormattingObjects& aFormattingObjects, TInt64& aSlowest) sl@0: { sl@0: const CTmTextLayout& tmLayout = aFormattingObjects.iLayout->TagmaTextLayout(); sl@0: aTimeStamps.Close(); sl@0: TTime start; sl@0: TTime end; sl@0: TInt iteration = 0; sl@0: TInt64 total = 0; sl@0: sl@0: TInt step = 0; sl@0: while(aFormattingObjects.iRichText->DocumentLength() > 0) sl@0: { sl@0: aFormattingObjects.iRichText->DeleteL(0, 1); sl@0: TCursorSelection cursor(0,0); sl@0: start.UniversalTime(); sl@0: aFormattingObjects.iView->HandleInsertDeleteL(cursor, 1, EFalse); sl@0: end.UniversalTime(); sl@0: sl@0: TInt64 us = end.MicroSecondsFrom(start).Int64(); sl@0: sl@0: if(us > aSlowest) sl@0: { sl@0: aSlowest = us; sl@0: } sl@0: sl@0: total += us; sl@0: step++; sl@0: if(step == KDeleteTextInterval) sl@0: { sl@0: TInt64 average = total/KDeleteTextInterval; sl@0: TTFTimeStamp timestamp; sl@0: timestamp.iTime = average; sl@0: timestamp.iIteration = iteration; sl@0: User::LeaveIfError(aTimeStamps.Append(timestamp)); sl@0: iteration++; sl@0: step = 0; sl@0: total = 0; sl@0: } sl@0: } sl@0: } sl@0: sl@0: void MeasureInsertTextAtStartL(TInt aRepeats, TInt aRepeatsPerPara, RArray& aTimeStamps, sl@0: TFormattingObjects& aFormattingObjects, TInt64& aSlowest) sl@0: { sl@0: aTimeStamps.Close(); sl@0: TTime start; sl@0: TTime end; sl@0: TInt repeatsInThisPar = 0; sl@0: TViewRectChanges changes; sl@0: aFormattingObjects.iRichText->Reset(); sl@0: for (TInt i = 0; i < aRepeats; i++) sl@0: { sl@0: TBuf<128> sample; sl@0: if ((i%2)==0) sl@0: { sl@0: sample = KEnglishToInsert1; sl@0: } sl@0: else sl@0: { sl@0: sample = KEnglishToInsert2; sl@0: } sl@0: aFormattingObjects.iRichText->InsertL(0, sample); sl@0: TCursorSelection cursor(0, sample.Length()); sl@0: sl@0: start.UniversalTime(); sl@0: aFormattingObjects.iLayout->HandleBlockChangeL(cursor, 0, changes, 0); sl@0: end.UniversalTime(); sl@0: sl@0: TInt64 us = end.MicroSecondsFrom(start).Int64(); sl@0: repeatsInThisPar ++; sl@0: TTFTimeStamp timestamp; sl@0: timestamp.iTime = us; sl@0: timestamp.iIteration = i; sl@0: User::LeaveIfError(aTimeStamps.Append(timestamp)); sl@0: if(us > aSlowest) sl@0: { sl@0: aSlowest = us; sl@0: } sl@0: if (repeatsInThisPar > aRepeatsPerPara) sl@0: { sl@0: TChar paragraphDelimiter(0x2029); sl@0: aFormattingObjects.iRichText->InsertL(0, paragraphDelimiter); sl@0: repeatsInThisPar = 0; sl@0: } sl@0: } sl@0: } sl@0: sl@0: void MeasureCursorL(RArray& aTimeStamps, TCursorPosition::TMovementType aType, sl@0: TFormattingObjects& aFormattingObjects, TInt64& aSlowest) sl@0: { sl@0: aTimeStamps.Close(); sl@0: TTime start; sl@0: TTime end; sl@0: TInt lines = 0; sl@0: TCursorPosition::TMovementType move = aType; sl@0: sl@0: while (move == aType) sl@0: { sl@0: lines++; sl@0: start.UniversalTime(); sl@0: aFormattingObjects.iView->MoveCursorL(move, EFalse); sl@0: end.UniversalTime(); sl@0: TInt64 us = end.MicroSecondsFrom(start).Int64(); sl@0: TTFTimeStamp timestamp; sl@0: timestamp.iTime = us; sl@0: timestamp.iIteration = lines; sl@0: User::LeaveIfError(aTimeStamps.Append(timestamp)); sl@0: if(us > aSlowest) sl@0: { sl@0: aSlowest = us; sl@0: } sl@0: const CTmTextLayout& tmLayout = aFormattingObjects.iLayout->TagmaTextLayout(); sl@0: } sl@0: } sl@0: sl@0: void CreateFormattingObjectsLC(TFormattingObjects& aFormattingObjects) sl@0: { sl@0: TRect* displayRect = new(ELeave) TRect(0, 0, KDisplayWidth, KDisplayHeight); sl@0: CleanupStack::PushL(displayRect); sl@0: CParaFormatLayer* paraFormat = CParaFormatLayer::NewL(); sl@0: CleanupStack::PushL(paraFormat); sl@0: CCharFormatLayer* charFormat = CCharFormatLayer::NewL(); sl@0: CleanupStack::PushL(charFormat); sl@0: CRichText* text = CRichText::NewL(paraFormat, charFormat); sl@0: CleanupStack::PushL(text); sl@0: CTextLayout* layout = CTextLayout::NewL(text, displayRect->Width()); sl@0: CleanupStack::PushL(layout); sl@0: CTestGraphicsDevice* device = CTestGraphicsDevice::NewL(displayRect->Size(), 0); sl@0: CleanupStack::PushL(device); sl@0: // Prevent the line array from using up the memory sl@0: device->LineArray().Disable(); sl@0: CTextView* view = CTextView::NewL(layout, *displayRect, sl@0: device, device, 0, 0, 0); sl@0: CleanupStack::PushL(view); sl@0: // must disable flicker-free redraw or Form will try to use sl@0: // the test font with an off-screen (i.e. real) graphics context, sl@0: // which will panic. sl@0: view->DisableFlickerFreeRedraw(); sl@0: sl@0: aFormattingObjects.iDisplayRect = displayRect; sl@0: aFormattingObjects.iParFormat = paraFormat; sl@0: aFormattingObjects.iCharFormat = charFormat; sl@0: aFormattingObjects.iRichText = text; sl@0: aFormattingObjects.iLayout = layout; sl@0: aFormattingObjects.iDevice = device; sl@0: aFormattingObjects.iView = view; sl@0: } sl@0: sl@0: void DestroyFormattingObjects(TFormattingObjects& aFormattingObjects) sl@0: { sl@0: CleanupStack::PopAndDestroy(aFormattingObjects.iView); sl@0: CleanupStack::PopAndDestroy(aFormattingObjects.iDevice); sl@0: CleanupStack::PopAndDestroy(aFormattingObjects.iLayout); sl@0: CleanupStack::PopAndDestroy(aFormattingObjects.iRichText); sl@0: CleanupStack::PopAndDestroy(aFormattingObjects.iCharFormat); sl@0: CleanupStack::PopAndDestroy(aFormattingObjects.iParFormat); sl@0: CleanupStack::PopAndDestroy(aFormattingObjects.iDisplayRect); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-FORMA-UT-1897 sl@0: @SYMTestCaseDesc Benchmarks scrolling text sl@0: @SYMTestPriority High sl@0: @SYMTestActions creates document and scrolls it sl@0: @SYMTestExpectedResults The test must not fail or panic . sl@0: @SYMDEF DEF092140, DEF092139 sl@0: */ sl@0: void RunScrollingTestL(TInt aRepeats, TInt aRepeatsPerParagraph, sl@0: RArray& aTimeStampsDown, RArray& aTimeStampsUp, sl@0: TDocInfo& aDocInfo) sl@0: { sl@0: TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1897 ")); sl@0: TInt docLength = KEnglish().Length() * aRepeats; sl@0: TInt paragraphs = aRepeats/aRepeatsPerParagraph; sl@0: sl@0: TFormattingObjects o; sl@0: CreateFormattingObjectsLC(o); sl@0: o.iLayout->SetWrapWidth(KInsertDisplayWidth); sl@0: o.iLayout->SetAmountToFormat(CTextLayout::EFFormatBand); sl@0: SetTextL(*(o.iRichText), KEnglish, aRepeats, aRepeatsPerParagraph); sl@0: sl@0: TTimeIntervalMicroSeconds opening = MeasureOpeningL(*(o.iView)); sl@0: TInt64 slowest = 0; sl@0: MeasureCursorL(aTimeStampsDown, TCursorPosition::EFLineDown, o, slowest); sl@0: MeasureCursorL(aTimeStampsUp, TCursorPosition::EFLineUp, o, slowest); sl@0: sl@0: TBuf<256> buf; sl@0: buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_Scrolling_Slowest_Doc_with_%d_characters_%d_paragraphs;microseconds: %Ld"), docLength, paragraphs, slowest); sl@0: TESTPRINT(buf); sl@0: sl@0: aDocInfo = GetSampleDocInfoL(o); sl@0: DestroyFormattingObjects(o); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-FORMA-UT-1898 sl@0: @SYMTestCaseDesc Benchmarks inserting, deleting and formatting text sl@0: @SYMTestPriority High sl@0: @SYMTestActions creates documents in each language and performs edits and reformats sl@0: @SYMTestExpectedResults The test must not fail or panic . sl@0: @SYMDEF DEF092140, DEF092139 sl@0: */ sl@0: void RunEnglishArabicJapaneseBenchmarksL(TFormattingObjects& aFormattingObjects) sl@0: { sl@0: TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1898 ")); sl@0: SetTextL(*aFormattingObjects.iRichText, KEnglish, KEnglishRepeats, KEnglishRepeats); sl@0: TTimeIntervalMicroSeconds opening = MeasureOpeningL(*aFormattingObjects.iView); sl@0: TTimeIntervalMicroSeconds rmsCursorDown = MeasureRmsCursorDownL(*aFormattingObjects.iView); sl@0: TTimeIntervalMicroSeconds englishFormatting = MeasureFormattingL(*aFormattingObjects.iView); sl@0: TInt englishLines = NumberOfLines(*aFormattingObjects.iLayout); sl@0: SetTextL(*aFormattingObjects.iRichText, KArabic, KArabicRepeats, KArabicRepeats); sl@0: TTimeIntervalMicroSeconds arabicFormatting = MeasureFormattingL(*aFormattingObjects.iView); sl@0: TInt arabicLines = NumberOfLines(*aFormattingObjects.iLayout); sl@0: SetTextL(*aFormattingObjects.iRichText, KJapanese, KJapaneseRepeats, KJapaneseRepeats); sl@0: TTimeIntervalMicroSeconds japaneseFormatting = MeasureFormattingL(*aFormattingObjects.iView); sl@0: TInt japaneseLines = NumberOfLines(*aFormattingObjects.iLayout); sl@0: sl@0: // Check that the results are fair sl@0: TInt minLines; sl@0: TInt maxLines; sl@0: if (arabicLines < englishLines) sl@0: { sl@0: minLines = arabicLines; sl@0: maxLines = englishLines; sl@0: } sl@0: else sl@0: { sl@0: minLines = englishLines; sl@0: maxLines = arabicLines; sl@0: } sl@0: if (japaneseLines < minLines) sl@0: minLines = japaneseLines; sl@0: else if (maxLines < japaneseLines) sl@0: maxLines = japaneseLines; sl@0: sl@0: //Tests that the number of lines in each test is more or less balanced sl@0: TESTPOINT(maxLines * 100 <= minLines * 105); sl@0: sl@0: TBuf<256> buf; sl@0: buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_OpeningLargeParagraph;microseconds: %d"), sl@0: static_cast(opening.Int64())); sl@0: TESTPRINT(buf); sl@0: buf.Zero(); sl@0: sl@0: buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_RmsCursorDown;microseconds: %d"), sl@0: static_cast(rmsCursorDown.Int64())); sl@0: TESTPRINT(buf); sl@0: buf.Zero(); sl@0: sl@0: buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormattingEnglish;microseconds: %d"), sl@0: static_cast(englishFormatting.Int64())); sl@0: TESTPRINT(buf); sl@0: buf.Zero(); sl@0: sl@0: buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormattingArabic;microseconds: %d"), sl@0: static_cast(arabicFormatting.Int64())); sl@0: TESTPRINT(buf); sl@0: buf.Zero(); sl@0: sl@0: buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormattingJapanese;microseconds: %d"), sl@0: static_cast(japaneseFormatting.Int64())); sl@0: TESTPRINT(buf); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-FORMA-UT-1896 sl@0: @SYMTestCaseDesc Benchmarks inserting text from the beginning of a paragraph sl@0: @SYMTestPriority High sl@0: @SYMTestActions creates a large paragraph containg just one word and inserts text iteratively from sl@0: the beginning sl@0: @SYMTestExpectedResults The test must not fail or panic . sl@0: @SYMDEF DEF092140, DEF092139 sl@0: */ sl@0: void RunInsertTextTestsL(TInt aRepeats, TInt aRepeatsPerParagraph, sl@0: RArray& aTimeStamps, TDocInfo& aDocInfo) sl@0: { sl@0: TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1896 ")); sl@0: TFormattingObjects o; sl@0: CreateFormattingObjectsLC(o); sl@0: TInt64 slowest = 0; sl@0: o.iLayout->SetWrapWidth(KInsertDisplayWidth); sl@0: o.iLayout->SetAmountToFormat(CTextLayout::EFFormatBand); sl@0: MeasureInsertTextAtStartL(aRepeats, aRepeatsPerParagraph, aTimeStamps, o, slowest); sl@0: aDocInfo = GetSampleDocInfoL(o); sl@0: sl@0: TBuf<256> buf; sl@0: buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_InsertText_Slowest;microseconds: %Ld"), slowest); sl@0: TESTPRINT(buf); sl@0: sl@0: DestroyFormattingObjects(o); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-FORMA-UT-1895 sl@0: @SYMTestCaseDesc Benchmarks deleting text from the beginning of a paragraph sl@0: @SYMTestPriority High sl@0: @SYMTestActions creates a large paragraph containg just one word and deletes text iteratively from sl@0: the beginning sl@0: @SYMTestExpectedResults The test must not fail or panic . sl@0: @SYMDEF DEF092140, DEF092139 sl@0: */ sl@0: void RunDeleteTextFromStartTest(RArray& aTimeStamps, TDocInfo& aDocInfo) sl@0: { sl@0: TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1895 ")); sl@0: TFormattingObjects o; sl@0: CreateFormattingObjectsLC(o); sl@0: TInt64 slowest = 0; sl@0: o.iLayout->SetWrapWidth(KInsertDisplayWidth); sl@0: o.iLayout->SetAmountToFormat(CTextLayout::EFFormatBand); sl@0: RBuf bigbuf; sl@0: BigBufLC(bigbuf); sl@0: SetTextL(*o.iRichText, bigbuf, 1, 1); sl@0: TTimeIntervalMicroSeconds opening = MeasureOpeningL(*o.iView); sl@0: sl@0: MeasureDeleteTextFromStartL(aTimeStamps, o, slowest); sl@0: aDocInfo = GetSampleDocInfoL(o); sl@0: sl@0: TBuf<256> buf; sl@0: buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_DeleteText_Slowest;microseconds: %Ld"), slowest); sl@0: TESTPRINT(buf); sl@0: sl@0: CleanupStack::PopAndDestroy();//bigbuf sl@0: DestroyFormattingObjects(o); sl@0: } sl@0: sl@0: void GetFormattingBenchmarkL(TInt aNumberOfIterations, TInt& aNumberOfCharacters, TInt64& aNormalisedBenchmark) sl@0: { sl@0: TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1895 ")); sl@0: TFormattingObjects o; sl@0: CreateFormattingObjectsLC(o); sl@0: o.iLayout->SetWrapWidth(KInsertDisplayWidth); sl@0: o.iLayout->SetAmountToFormat(CTextLayout::EFFormatBand); sl@0: sl@0: SetTextL(*(o.iRichText), KEnglish, aNumberOfIterations, aNumberOfIterations); sl@0: sl@0: TTimeIntervalMicroSeconds ignore = MeasureOpeningL(*(o.iView)); sl@0: o.iView->SetDocPosL(o.iRichText->DocumentLength()); sl@0: //make a global change sl@0: o.iLayout->SetWrapWidth(KChangedDisplayWidth); sl@0: //measure time to reformat for it sl@0: TTime start; sl@0: TTime end; sl@0: start.UniversalTime(); sl@0: o.iView->HandleGlobalChangeL(); sl@0: end.UniversalTime(); sl@0: sl@0: TTimeIntervalMicroSeconds formattingTime = end.MicroSecondsFrom(start); sl@0: sl@0: aNumberOfCharacters = o.iRichText->DocumentLength(); sl@0: aNormalisedBenchmark = formattingTime.Int64()/aNumberOfIterations; sl@0: sl@0: DestroyFormattingObjects(o); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-FORMA-UT-1894 sl@0: @SYMTestCaseDesc Benchmarks formatting text sl@0: @SYMTestPriority High sl@0: @SYMTestActions for a series of documents of increasing size consisting of a single paragraph, sl@0: sets the cursor position to the end of the document, makes a global change and formats it. sl@0: @SYMTestExpectedResults The test must not fail or panic. The increase in time taken should be sl@0: roughly linear with the document size. sl@0: @SYMDEF DEF095401 sl@0: */ sl@0: void RunFormattingBenchmarksL() sl@0: { sl@0: TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1894 ")); sl@0: TInt numberOfCharacters = 0; sl@0: TInt numberOfIterations; sl@0: TInt64 normalisedBenchmark = 0; sl@0: sl@0: TBuf<256> buf; sl@0: sl@0: numberOfIterations = 1; sl@0: GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark); sl@0: buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark); sl@0: TESTPRINT(buf); sl@0: sl@0: buf.Zero(); sl@0: numberOfIterations = 5; sl@0: GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark); sl@0: buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark); sl@0: TESTPRINT(buf); sl@0: sl@0: buf.Zero(); sl@0: numberOfIterations = 10; sl@0: GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark); sl@0: buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark); sl@0: TESTPRINT(buf); sl@0: sl@0: buf.Zero(); sl@0: numberOfIterations = 50; sl@0: GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark); sl@0: buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark); sl@0: TESTPRINT(buf); sl@0: sl@0: buf.Zero(); sl@0: numberOfIterations = 100; sl@0: GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark); sl@0: buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark); sl@0: TESTPRINT(buf); sl@0: sl@0: buf.Zero(); sl@0: numberOfIterations = 250; sl@0: GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark); sl@0: buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark); sl@0: TESTPRINT(buf); sl@0: sl@0: buf.Zero(); sl@0: numberOfIterations = 500; sl@0: GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark); sl@0: buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark); sl@0: TESTPRINT(buf); sl@0: sl@0: buf.Zero(); sl@0: numberOfIterations = 750; sl@0: GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark); sl@0: buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark); sl@0: TESTPRINT(buf); sl@0: sl@0: buf.Zero(); sl@0: numberOfIterations = 1000; sl@0: GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark); sl@0: buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark); sl@0: TESTPRINT(buf); sl@0: } sl@0: sl@0: void RunBenchmarksL() sl@0: { sl@0: CActiveScheduler* scheduler = new(ELeave) CActiveScheduler; sl@0: CleanupStack::PushL(scheduler); sl@0: CActiveScheduler::Install(scheduler); sl@0: sl@0: RunFormattingBenchmarksL(); sl@0: sl@0: TDocInfo docInfo; sl@0: RArray timestampsDown; sl@0: RArray timestampsUp; sl@0: CleanupClosePushL(timestampsDown); sl@0: CleanupClosePushL(timestampsUp); sl@0: sl@0: RunDeleteTextFromStartTest(timestampsUp, docInfo); sl@0: WriteSampleDocInfo(docInfo, fileTimeStamps); sl@0: WriteTimeStampsL(KDeleteTextFromStart, timestampsUp); sl@0: sl@0: RunInsertTextTestsL(KEnglishInsertRepeats, KEnglishInsertRepeats, timestampsUp, docInfo); sl@0: WriteSampleDocInfo(docInfo, fileTimeStamps); sl@0: WriteTimeStampsL(KInsertTextAtStart, timestampsUp); sl@0: sl@0: RunScrollingTestL(KEnglishScrollRepeats, KEnglishScrollRepeats, timestampsDown, timestampsUp, docInfo); sl@0: WriteSampleDocInfo(docInfo, fileTimeStamps); sl@0: WriteTimeStampsL(KScrollingDown, timestampsDown); sl@0: WriteTimeStampsL(KScrollingUp, timestampsUp); sl@0: sl@0: RunScrollingTestL(KEnglishScrollRepeats, KEnglishScrollRepeats/2, timestampsDown, timestampsUp, docInfo); sl@0: WriteSampleDocInfo(docInfo, fileTimeStamps); sl@0: WriteTimeStampsL(KScrollingDown, timestampsDown); sl@0: WriteTimeStampsL(KScrollingUp, timestampsUp); sl@0: sl@0: RunScrollingTestL(KEnglishScrollRepeats, KEnglishScrollRepeats/10, timestampsDown, timestampsUp, docInfo); sl@0: WriteSampleDocInfo(docInfo, fileTimeStamps); sl@0: WriteTimeStampsL(KScrollingDown, timestampsDown); sl@0: WriteTimeStampsL(KScrollingUp, timestampsUp); sl@0: sl@0: TFormattingObjects o; sl@0: CreateFormattingObjectsLC(o); sl@0: RunEnglishArabicJapaneseBenchmarksL(o); sl@0: DestroyFormattingObjects(o); sl@0: sl@0: CleanupStack::PopAndDestroy(2); sl@0: CleanupStack::PopAndDestroy(scheduler); sl@0: sl@0: } sl@0: sl@0: TVerdict CTFormBenchmarkStep::doTestStepL() sl@0: { sl@0: SetTestStepResult(EPass); sl@0: TestStep = this; sl@0: sl@0: TESTPRINT(KFormBenchmark); sl@0: TESTPRINT(_L("Start Font/Bitmap Server")); sl@0: sl@0: TInt error = RFbsSession::Connect(); sl@0: if (error == KErrNotFound) sl@0: { sl@0: FbsStartup(); sl@0: error = RFbsSession::Connect(); sl@0: } sl@0: // Tests that FBServ actually starts sl@0: TESTPOINT(error == KErrNone); sl@0: error = fs.Connect(); sl@0: TESTPOINT(error == KErrNone); sl@0: sl@0: error = fileTimeStamps.Replace(fs, KLogTimeStampsName, EFileWrite); sl@0: sl@0: TBuf<256> buf; sl@0: buf.AppendFormat(_L("> fileTimeStamps.Replace %d"), error); sl@0: TESTPRINT(buf); sl@0: sl@0: TESTPOINT(error == KErrNone); sl@0: sl@0: TESTPRINT(_L("Run Benchmarks")); sl@0: TRAP(error, RunBenchmarksL()); sl@0: // Tests that the Benchmarks did not run out of memory sl@0: // or otherwise leave sl@0: TESTPOINT(error == KErrNone); sl@0: sl@0: fileTimeStamps.Close(); sl@0: fs.Close(); sl@0: RFbsSession::Disconnect(); sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: