squidge
23rd October 2009, 09:49
I have a QTableView with custom modal that has upto 1 million rows, with data being added 10 times a second. Old data is removed if the data ever exceeeds 1 million.
This uses a suprising amount of cpu time considering how simple it is. Using a performance analyser, it seems that the entire tableview is read for every single row addition after the model calls endInsertRows(). In particular, QHeaderView::isSectionHidden and a few other methods are called for every single row, so approx 1 million times for each row added, and this seems to be where most of the cpu usage is.
Also the entire QTableView is repainted after every addition, even when the new data isn't visible and there was no changes to existing data.
Is this normal? And if so, why is QHeaderView being so CPU intensive? Column sizes are set manually so it shouldn't need to read the row data at all ? Can I block QHeaderView from receiving signals whilst I add an item to confirm these findings? It seems not as blockSignals only stops them from being transmitted, not received (and I need the signal to be received by the scrollbar), and eventfilter doesn't handle signals...
This uses a suprising amount of cpu time considering how simple it is. Using a performance analyser, it seems that the entire tableview is read for every single row addition after the model calls endInsertRows(). In particular, QHeaderView::isSectionHidden and a few other methods are called for every single row, so approx 1 million times for each row added, and this seems to be where most of the cpu usage is.
Also the entire QTableView is repainted after every addition, even when the new data isn't visible and there was no changes to existing data.
Is this normal? And if so, why is QHeaderView being so CPU intensive? Column sizes are set manually so it shouldn't need to read the row data at all ? Can I block QHeaderView from receiving signals whilst I add an item to confirm these findings? It seems not as blockSignals only stops them from being transmitted, not received (and I need the signal to be received by the scrollbar), and eventfilter doesn't handle signals...