miraks
14th September 2008, 17:08
Hi all,
I am trying to populate a QTableWidget with 50 lines and 50 columns with the following code:
{
SKGTRACEIN(10, "test-Filltable");
ui.kTable->clear();
ui.kTable->setRowCount(50);
ui.kTable->setColumnCount(50);
for (int i=0; i<49; ++i) {
for (int j=0; j<49; ++j) {
SKGTRACEIN(10, "test-setItem");
QTableWidgetItem* item=new QTableWidgetItem("A");
ui.kTable->setItem(i, j, item);
}
}
}
The macro SKGTRACEIN allows to measure the time consumed by the code in of the scope.
The first call of the code returns following traces:
## >test-Filltable
## >test-setItem
## <test-setItem TIME=0.100014 ms
## >test-setItem
## <test-setItem TIME=0.0169843 ms
## >test-setItem
## <test-setItem TIME=0.0140117 ms
## >test-setItem
## <test-setItem TIME=0.0148984 ms
## >test-setItem
## <test-setItem TIME=0.0140293 ms
...
...
## >test-setItem
## <test-setItem TIME=0.0139316 ms
## >test-setItem
## <test-setItem TIME=0.0148886 ms
## >test-setItem
## <test-setItem TIME=0.0138925 ms
## >test-setItem
## <test-setItem TIME=0.0150938 ms
## >test-setItem
## <test-setItem TIME=0.0150508 ms
## <test-Filltable TIME=431.761 ms
As you can see, performances are very good. Table is done in around 431ms. :D
The second call of this same code returns following traces:
## >test-Filltable
## >test-setItem
## <test-setItem TIME=27.6061 ms
## >test-setItem
## <test-setItem TIME=13.549 ms
## >test-setItem
## <test-setItem TIME=14.058 ms
## >test-setItem
## <test-setItem TIME=14.132 ms
## >test-setItem
## <test-setItem TIME=13.943 ms
...
...
## <test-setItem TIME=77.392 ms
## >test-setItem
## <test-setItem TIME=133.818 ms
## >test-setItem
## <test-setItem TIME=89.083 ms
## >test-setItem
## <test-setItem TIME=60.1529 ms
## >test-setItem
## <test-setItem TIME=61.99 ms
## <test-Filltable TIME=109696 ms
Now, performances are very bad (+25000%) and it seems to be due to setItem. :crying:
Why ? What is the solution to have good performances each time ?
Thank you in advance for your help.
I am trying to populate a QTableWidget with 50 lines and 50 columns with the following code:
{
SKGTRACEIN(10, "test-Filltable");
ui.kTable->clear();
ui.kTable->setRowCount(50);
ui.kTable->setColumnCount(50);
for (int i=0; i<49; ++i) {
for (int j=0; j<49; ++j) {
SKGTRACEIN(10, "test-setItem");
QTableWidgetItem* item=new QTableWidgetItem("A");
ui.kTable->setItem(i, j, item);
}
}
}
The macro SKGTRACEIN allows to measure the time consumed by the code in of the scope.
The first call of the code returns following traces:
## >test-Filltable
## >test-setItem
## <test-setItem TIME=0.100014 ms
## >test-setItem
## <test-setItem TIME=0.0169843 ms
## >test-setItem
## <test-setItem TIME=0.0140117 ms
## >test-setItem
## <test-setItem TIME=0.0148984 ms
## >test-setItem
## <test-setItem TIME=0.0140293 ms
...
...
## >test-setItem
## <test-setItem TIME=0.0139316 ms
## >test-setItem
## <test-setItem TIME=0.0148886 ms
## >test-setItem
## <test-setItem TIME=0.0138925 ms
## >test-setItem
## <test-setItem TIME=0.0150938 ms
## >test-setItem
## <test-setItem TIME=0.0150508 ms
## <test-Filltable TIME=431.761 ms
As you can see, performances are very good. Table is done in around 431ms. :D
The second call of this same code returns following traces:
## >test-Filltable
## >test-setItem
## <test-setItem TIME=27.6061 ms
## >test-setItem
## <test-setItem TIME=13.549 ms
## >test-setItem
## <test-setItem TIME=14.058 ms
## >test-setItem
## <test-setItem TIME=14.132 ms
## >test-setItem
## <test-setItem TIME=13.943 ms
...
...
## <test-setItem TIME=77.392 ms
## >test-setItem
## <test-setItem TIME=133.818 ms
## >test-setItem
## <test-setItem TIME=89.083 ms
## >test-setItem
## <test-setItem TIME=60.1529 ms
## >test-setItem
## <test-setItem TIME=61.99 ms
## <test-Filltable TIME=109696 ms
Now, performances are very bad (+25000%) and it seems to be due to setItem. :crying:
Why ? What is the solution to have good performances each time ?
Thank you in advance for your help.