How to monitor GUI event loop busy and idle time length
-
I am working on how to monitor GUI event loop work load. I suppose there is a block of time frame in GUI event loop between which GUI is busy handling event, then there is also a block of time frame that is idle. My question is how to measure the length of busy and idle time? I searched the forum and some one suggests using singleShot, but don't know how. We have override QCoreApplication::notify and handle events.
-
@samuelzeng
there is actually no idle time. You can think of the event loop as a infinite loop which just processes all inserted events in each iteration.
Using the singleShot approach lets you roughly measure the time each iteration takes. A singleShot queues an method-invokation-event for the next iteration. Thus you can measure the time each iteration took to process the posted events.So either use
QTimer::singleShot(0, this, SLOT(measureTime()))
orQMetaObject::invokeMethod(this, "measureTime", Qt::QueuedConnection)
-
@raven-worx said in How to monitor GUI event loop busy and idle time length:
So either use
QTimer::singleShot(0, this, SLOT(measureTime()))
orQMetaObject::invokeMethod(this, "measureTime", Qt::QueuedConnection)
Just to mention it, since Qt 5.10 you can also write:
QMetaObject::invokeMethod(this, &MyClass::measureTime, Qt::QueuedConnection)