Browse Source

Emit TorrentModel::dataChanged() signal only for specific rows, not for the entire table

In commit b50d733 TorrentModel moved from a periodic refresh, to using
postStatusUpdate(). In this transition I forgot to remove emition of
dataChanged() signal for the entire table.

According to my measurements this commit reduce CPU usage of qbittorrent
by a factor of 3:

Before:
   Total wall clock:                                      97.07s
   CPU time:                                              21.77s
   - Time spent in TransferListDelegate::paint():         14.60s
   - Time spent in TorrentModel::forceModelRefresh():      1.44s
   - Time spent in TorrentModel::stateUpdated():           0.02s

After:
   Total wall clock:                                      96.13s
   CPU time:                                               6.68s
   - Time spent in TransferListDelegate::paint():          2.63s
   - Time spent in TorrentModel::forceModelRefresh():     <0.01s
   - Time spent in TorrentModel::stateUpdated():           1.73s

As it is seen the time spent in painting is reduced by a factor of 6 (14.60->2.63) at
the cost of slightly increased time of notifications that model is
changed (1.44->1.73). The next commits attempt to address this issue.
adaptive-webui-19844
Ivan Sorokin 10 years ago
parent
commit
e5c024967d
  1. 5
      src/qtlibtorrent/torrentmodel.cpp

5
src/qtlibtorrent/torrentmodel.cpp

@ -508,7 +508,6 @@ void TorrentModel::setRefreshInterval(int refreshInterval)
void TorrentModel::forceModelRefresh() void TorrentModel::forceModelRefresh()
{ {
emit dataChanged(index(0, 0), index(rowCount()-1, columnCount()-1));
QBtSession::instance()->postTorrentUpdate(); QBtSession::instance()->postTorrentUpdate();
} }
@ -591,8 +590,10 @@ void TorrentModel::stateUpdated(const std::vector<libtorrent::torrent_status> &s
libtorrent::torrent_status const& status = *i; libtorrent::torrent_status const& status = *i;
const int row = torrentRow(misc::toQString(status.info_hash)); const int row = torrentRow(misc::toQString(status.info_hash));
if (row >= 0) if (row >= 0) {
m_torrents[row]->refreshStatus(status); m_torrents[row]->refreshStatus(status);
notifyTorrentChanged(row);
}
} }
} }

Loading…
Cancel
Save