1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
/*
* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
/**
@SYMPREQ PREQ1132 PREQ1187
@SYMComponent app-engines_cntmodel
@SYMAuthor Simon Mellor, JamesCl
@SYMTestStatus Implemented
@SYMTestType CT
@SYMTestCaseDesc Tests the performance of a bulk delete operation on a corporate-profile
database of 1000 contacts.
@SYMTestActions Measures the time taken to perform a bulk delete on the contacts database
by passing a CContactIdArray to:
-- CContactDatabase::DeleteContactsL()
@SYMTestExpectedResults Test case will run without leaving and will output timing information.
*/
#include "t_perfbulkdelete.h"
#include "../t_utils.h"
#include <cntitem.h>
// Constants
_LIT(KDbPathName,"C:Contacts.cdb");
const TPtrC KDbPath( (KDbPathName) );
_LIT(KOutputFormat,"Bulk Delete, deleting %d of %d contacts, took: %d s %03d\n");
_LIT(KOutputFormat2, "Db size before/after delete: %d / %d bytes\n");
CDeleteMany::CDeleteMany()
{
}
CDeleteMany::~CDeleteMany()
{
delete iDb;
}
CDeleteMany* CDeleteMany::NewLC(RTest& aTest)
{
CDeleteMany* self = new(ELeave) CDeleteMany();
CleanupStack::PushL(self);
self->ConstructL(aTest);
return(self);
}
void CDeleteMany::ConstructL(RTest& aTest)
{
iTest = &aTest;
iDb = CContactDatabase::OpenL(KDbPath);
CCntTest::ProfileReset(0, 59);
}
/*
Creates a random array of numbers corresponding to the Contacts Id in the
Contacts model. No Contact Id is repeated
*/
void CDeleteMany::CreateRandomIdArrayL(CContactIdArray& aUids, TInt aNumIds, TInt aNumEntriesInDb)
{
TTime now;
now.UniversalTime();
TInt64 KRandomSeed = now.DateTime().MicroSecond();
TInt uid(0);
for(TInt i = 0; i < aNumIds; ++i)
{
uid = (Math::Rand(KRandomSeed) % aNumEntriesInDb) + 1;
while(aUids.Find(uid) != KErrNotFound)
{
uid = (Math::Rand(KRandomSeed) % aNumEntriesInDb) + 1;
}
aUids.AddL(uid);
}
}
/**
Static convenience cleanup method copied from CSmlContactsDba
*/
void CDeleteMany::CleanupPtrArray(TAny* aCArrayPtr)
{
CArrayPtr<CContactItem>* array = reinterpret_cast<CArrayPtr<CContactItem>*>(aCArrayPtr);
array->ResetAndDestroy();
delete array;
}
/**
Main test routine. Calls and times CContactDatabase::DeleteContactsL
*/
void CDeleteMany::DelDataL(TInt aEntryCount, TInt aNumEntriesInDb, TInt aNumMsToGet20ItemsFromView)
{
TInt dbSizeBefore = iDb->FileSize();
CContactIdArray* idArray = CContactIdArray::NewLC();
// create an array of random, non-repeating contact ids
CreateRandomIdArrayL(*idArray, aEntryCount, aNumEntriesInDb);
TCntPerfTimer timer;
timer.StartTimer();
iDb->DeleteContactsL(*idArray);
timer.StopTimer();
CleanupStack::PopAndDestroy(); // idArray
const TInt KTransactionSize(50); // num records deleted in a transaction
// add in number of screen updates need in UI: (time to fetch 20 view items) * number of transactions
TInt result = timer.Result() +
(aNumMsToGet20ItemsFromView * ( (aEntryCount / KTransactionSize) + (aEntryCount % 20 ? 1 : 0) ) );
TBuf<64> formattable;
formattable.Format(KOutputFormat, aEntryCount, aNumEntriesInDb, result / 1000000, (result / 1000) % 1000);
iTest->Printf(formattable);
formattable.Format(KOutputFormat2, dbSizeBefore, iDb->FileSize());
iTest->Printf(formattable);
}
|