gontham
12th November 2010, 08:17
Hello,
I have an email model displayed in a QTreeView with check boxes (~ 1500 emails).
I have a function that loads a string of email addresses(seperated by commas) saved in a SQLite database and translates them to a QStringList (~ 900 emails).
Then I iterate over the email model, if an email address is found in the QStringList the checkbox is checked, otherwise its unchecked.
QTime time1 = QTime::currentTime();
QStringList emails = campaignModel->data(campaignModel->index(index,5)).toString().split(",",QString::SkipEmptyParts);
QStandardItem *parentItem;
for (int i=0;i<emailModel->rowCount();i++) {
qApp->processEvents();
parentItem = emailModel->item(i,0);
if (emails.contains(parentItem->data(0).toString()))
parentItem->setCheckState(Qt::Checked);
else
parentItem->setCheckState(Qt::Unchecked);
}
QTime time2 = QTime::currentTime();
qDebug() << "Benchmark0: " << time1.msecsTo(time2);
My question is how come the first time i run the compiled exe file it takes about 30 msecs to execute the function.
But whenever i call the function after that, it takes about 300 msec ?!
any ideas or feedback would be appreciated ?
Thanks.
I have an email model displayed in a QTreeView with check boxes (~ 1500 emails).
I have a function that loads a string of email addresses(seperated by commas) saved in a SQLite database and translates them to a QStringList (~ 900 emails).
Then I iterate over the email model, if an email address is found in the QStringList the checkbox is checked, otherwise its unchecked.
QTime time1 = QTime::currentTime();
QStringList emails = campaignModel->data(campaignModel->index(index,5)).toString().split(",",QString::SkipEmptyParts);
QStandardItem *parentItem;
for (int i=0;i<emailModel->rowCount();i++) {
qApp->processEvents();
parentItem = emailModel->item(i,0);
if (emails.contains(parentItem->data(0).toString()))
parentItem->setCheckState(Qt::Checked);
else
parentItem->setCheckState(Qt::Unchecked);
}
QTime time2 = QTime::currentTime();
qDebug() << "Benchmark0: " << time1.msecsTo(time2);
My question is how come the first time i run the compiled exe file it takes about 30 msecs to execute the function.
But whenever i call the function after that, it takes about 300 msec ?!
any ideas or feedback would be appreciated ?
Thanks.