I did not expect that its share of CPU usage in my app is 12.15%:
Why does it iterate over some collection? Isn’t there only one sender in a thread?
My code:
void connectElement(ElementModel* p)
{
QObject::connect(p, &ElementModel::elementChanged, this, &TableModel::onElementChanged, Qt::UniqueConnection);
}
void onElementChanged()
{
QObject* p_obj = sender(); //12.15% of CPU usage
onUpdated(dynamic_cast<T*>(p_obj)->shared_from_this());
}
is called from UpdateGuard
constructor:
and a similar code is called from UpdateGuard
destructor
UpdateGuard
total CPU usage is 13.73% + 14.45% = 28.18%. For comparison, QML binding CPU usage share is 18.95% + 8.65% = 27.6%. The total CPU usage of entire MarketModel::setPrice
function is 57.42%.
Another example is WalletModel::savePrice
:
QObject::senderSignalIndex()
also iterates over this collection: