From e5c024967d2ccc9ea00aa7350671c2ad8e14e93e Mon Sep 17 00:00:00 2001 From: Ivan Sorokin Date: Wed, 5 Nov 2014 03:05:46 +0300 Subject: [PATCH] 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. --- src/qtlibtorrent/torrentmodel.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qtlibtorrent/torrentmodel.cpp b/src/qtlibtorrent/torrentmodel.cpp index eb819ee03..d28a8b2ef 100644 --- a/src/qtlibtorrent/torrentmodel.cpp +++ b/src/qtlibtorrent/torrentmodel.cpp @@ -508,7 +508,6 @@ void TorrentModel::setRefreshInterval(int refreshInterval) void TorrentModel::forceModelRefresh() { - emit dataChanged(index(0, 0), index(rowCount()-1, columnCount()-1)); QBtSession::instance()->postTorrentUpdate(); } @@ -591,8 +590,10 @@ void TorrentModel::stateUpdated(const std::vector &s libtorrent::torrent_status const& status = *i; const int row = torrentRow(misc::toQString(status.info_hash)); - if (row >= 0) + if (row >= 0) { m_torrents[row]->refreshStatus(status); + notifyTorrentChanged(row); + } } }