I would like to measure the "busyness" of my Event Dispatching Thread. One possible idea is to set up a background thread that does something like:
while(true) {
final long[] end = new long[1]; // Array to get stuff out from Runnable.
long start = System.nanoTime();
EventQueue.invokeAndWait(new Runnable() {
public void run() {
end[0] = System.nanoTime();
}
});
long queueTimeNs = end[0] - start;
// Report the queue time somewhere.
Thread.sleep(100); // Poll the EDT < 10 times/s.
}
The idea is to measure how long it takes from sending an event to the EDT to it getting dispatched. This would give a rough idea about the responsiveness of the UI.
Does this make any sense? Is there some more standard way to do something similar?