Update contrib.
1 // Copyright (c) 2005-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 "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.
19 @internalComponent - Internal Symbian test code
22 #include "tfbsbitmaphandleperf.h"
24 const TInt KIterationsToTest = 1000;
25 const TInt KMaxNumSmallTestBitmaps = 40;
26 const TInt KMaxNumLargeTestBitmaps = 4;
27 const TInt KNumTestBitmapSizes = 8;
28 const TDisplayMode KTestDisplayMode = EColor256;
29 const TDisplayMode KTestDisplayMode2 = EColor64K;
32 CTFbsBitmapHandlePerf::CTFbsBitmapHandlePerf()
34 SetTestStepName(KTFbsBitmapHandlePerfName);
37 CTFbsBitmapHandlePerf::~CTFbsBitmapHandlePerf()
39 iTestBitmaps.ResetAndDestroy();
43 Override of base class pure virtual
44 Our implementation only gets called if the base class doTestStepPreambleL() did
45 not leave. That being the case, the current test result value will be EPass.
47 @return - TVerdict code
49 TVerdict CTFbsBitmapHandlePerf::doTestStepL()
51 SetTestStepID(_L("GRAPHICS-UI-BENCH-0074"));
52 SmallBitmapCreationL(KTestDisplayMode, _L("Small Bitmap-Create")); //8 bit
54 SetTestStepID(_L("GRAPHICS-UI-BENCH-0006"));
55 LargeBitmapCreationL(KTestDisplayMode, _L("Large Bitmap-Create"));
57 SetTestStepID(_L("GRAPHICS-UI-BENCH-0087"));
58 SmallBitmapCreationSimpleL();
60 SetTestStepID(_L("GRAPHICS-UI-BENCH-0088"));
61 LargeBitmapCreationSimpleL();
63 SetTestStepID(_L("GRAPHICS-UI-BENCH-0007"));
66 return TestStepResult();
70 Creates and destroys bitmaps KIterationsToTest times with various sizes
71 using a pseudo-random sequence to try to simulate real usage patterns.
73 @param aSizes Array of KNumTestBitmapSizes sizes to create bitmaps with.
74 @param aMaxNumBitmaps Maximum number of created but not yet deleted bitmaps at any given time.
75 @param aDisplayMode The display mode to create bitmaps with.
77 void CTFbsBitmapHandlePerf::BitmapCreationL(const TSize aSizes[], TInt aMaxNumBitmaps, const TDisplayMode aDisplayMode)
80 iProfiler->InitResults();
81 for (TInt count = KIterationsToTest; count > 0; --count)
83 CFbsBitmap* bitmap = new(ELeave) CFbsBitmap;
84 CleanupStack::PushL(bitmap);
85 TInt err = bitmap->Create(aSizes[count % KNumTestBitmapSizes], aDisplayMode);
86 User::LeaveIfError(err);
87 iTestBitmaps.AppendL(bitmap);
88 CleanupStack::Pop(bitmap);
89 if (iTestBitmaps.Count() >= aMaxNumBitmaps)
91 TInt i = Math::Rand(seed) % aMaxNumBitmaps;
92 delete iTestBitmaps[i];
93 iTestBitmaps.Remove(i);
95 iProfiler->MarkResultSetL();
97 iTestBitmaps.ResetAndDestroy();
101 Creates and destroys bitmaps of the same size KIterationsToTest times.
103 @param aWidth The width of the created bitmaps.
104 @param aHeight The height of the created bitmaps.
105 @param aDisplayMode The display mode to create bitmaps with.
106 @param aTestDescription The description of the test.
108 void CTFbsBitmapHandlePerf::BitmapCreationSimpleL(const TInt aWidth, const TInt aHeight, const TDisplayMode aDisplayMode, const TDesC& aTestDescription)
110 iProfiler->InitResults();
111 for (TInt count = KIterationsToTest; count > 0; --count)
114 TInt err = bitmap.Create(TSize(aWidth, aHeight), aDisplayMode);
115 User::LeaveIfError(err);
116 iProfiler->MarkResultSetL();
118 iProfiler->ResultsAnalysis(aTestDescription, aDisplayMode, 0, 0, KIterationsToTest);
123 GRAPHICS-UI-BENCH-0074
126 The test determines how long it takes to create and destroy small bitmap objects.
129 Compare the results over time, and before and after changes to bitmap construction and destruction code.
131 @SYMTestExpectedResults
132 Test should pass and display total test time and time per bitmap
134 @param aDisplayMode The display mode to create bitmaps with.
135 @param aTestDescription The description of the test.
137 void CTFbsBitmapHandlePerf::SmallBitmapCreationL(const TDisplayMode aDisplayMode, const TDesC& aTestDescription)
139 // width X height X bytes per pixel < KMaxLargeBitmapAlloc (16KB as of writing)
140 const TSize KSmallSizes[KNumTestBitmapSizes] =
142 TSize(20, 20), // 1st
143 TSize(22, 22), // 2nd
144 TSize(24, 24), // 3rd
145 TSize(28, 28), // 4th
146 TSize(32, 32), // 5th
147 TSize(40, 40), // 6th
148 TSize(48, 48), // 7th
151 BitmapCreationL(KSmallSizes, KMaxNumSmallTestBitmaps, aDisplayMode);
152 iProfiler->ResultsAnalysis(aTestDescription, aDisplayMode, 0, 0, KIterationsToTest);
157 GRAPHICS-UI-BENCH-0006
160 The test determines how long it takes to create and destroy large bitmap objects.
163 Compare the results over time, and before and after changes to bitmap construction and destruction code.
165 @SYMTestExpectedResults
166 Test should pass and display total test time and time per bitmap
168 @param aDisplayMode The display mode to create bitmaps with.
169 @param aTestDescription The description of the test.
171 void CTFbsBitmapHandlePerf::LargeBitmapCreationL(const TDisplayMode aDisplayMode, const TDesC& aTestDescription)
173 // width X height X bytes per pixel > KMaxLargeBitmapAlloc (16KB as of writing)
174 const TSize KLargeSizes[KNumTestBitmapSizes] =
176 TSize(200, 200), // 1st
177 TSize(220, 220), // 2nd
178 TSize(240, 240), // 3rd
179 TSize(280, 280), // 4th
180 TSize(320, 320), // 5th
181 TSize(400, 400), // 6th
182 TSize(480, 480), // 7th
183 TSize(600, 600) // 8th
185 BitmapCreationL(KLargeSizes, KMaxNumLargeTestBitmaps, aDisplayMode);
186 iProfiler->ResultsAnalysis(aTestDescription, aDisplayMode, 0, 0, KIterationsToTest);
191 GRAPHICS-UI-BENCH-0007
194 Tests how long it takes to duplicate a bitmap
197 Compare the results over time, and before and after changes to bitmap duplication code.
199 @SYMTestExpectedResults
200 Test should pass and display total test time and time per bitmap
202 void CTFbsBitmapHandlePerf::BitmapDuplicateL()
208 RArray<TInt> handles;
209 RPointerArray<CFbsBitmap> bitmapArray;
210 CleanupClosePushL(bitmapArray);
212 // Create bitmaps for each display mode and store in array
213 for(TInt count=KNumValidBitmapModes-1; count>=0; --count)
215 CFbsBitmap* bitmap=new(ELeave) CFbsBitmap;
216 CleanupStack::PushL(bitmap);
217 TDisplayMode mode = KValidBitmapModes[count];
218 err = bitmap->Create(size, mode);
219 User::LeaveIfError(err);
220 User::LeaveIfError(bitmapArray.Append(bitmap));
221 CleanupStack::Pop(bitmap);
222 User::LeaveIfError(handles.Append(bitmap->Handle()));
225 // Duplicate each bitmap in the array and measure performance
226 iProfiler->InitResults();
227 for(TInt count=KIterationsToTest; count>=0; --count)
229 CFbsBitmap* duplicateBitmap=new (ELeave) CFbsBitmap;
230 CleanupStack::PushL(duplicateBitmap);
231 TInt hn=count%KNumValidBitmapModes;
232 TInt handle=handles[hn];
233 err=duplicateBitmap->Duplicate(handle);
234 User::LeaveIfError(err);
235 CleanupStack::PopAndDestroy(duplicateBitmap);
236 iProfiler->MarkResultSetL();
238 iProfiler->ResultsAnalysis(_L("Bitmap-Duplicate"), 0, 0, 0, KIterationsToTest);
242 bitmapArray.ResetAndDestroy();
243 CleanupStack::PopAndDestroy(&bitmapArray);
248 GRAPHICS-UI-BENCH-0087
251 The test determines how long it takes to create and destroy small simple bitmap objects.
254 Compare the results over time, and before and after changes to bitmap construction and destruction code.
256 @SYMTestExpectedResults
257 Test should pass and display total test time and time per bitmap
259 @param aDisplayMode The display mode to create bitmaps with.
260 @param aTestDescription The description of the test.
262 void CTFbsBitmapHandlePerf::SmallBitmapCreationSimpleL()
264 BitmapCreationSimpleL(32, 32, KTestDisplayMode2, _L("Small Bitmap-Create-64K-Simple"));
269 GRAPHICS-UI-BENCH-0088
272 The test determines how long it takes to create and destroy large simple bitmap objects.
275 Compare the results over time, and before and after changes to bitmap construction and destruction code.
277 @SYMTestExpectedResults
278 Test should pass and display total test time and time per bitmap
280 @param aDisplayMode The display mode to create bitmaps with.
281 @param aTestDescription The description of the test.
283 void CTFbsBitmapHandlePerf::LargeBitmapCreationSimpleL()
285 BitmapCreationSimpleL(500, 500, KTestDisplayMode2, _L("Large Bitmap-Create-64K-Simple"));