September 27th, 2013

How can I determine how responsive my application is to input?

A customer was adding diagnostics to their application and wanted to know if there was a way to detect that the application was being slow in processing its input. These sorts of delays manifest themselves to the end user as a sluggish application which is slow to respond to input events. They already had a watchdog timer that was reset every time their Get­Message call returned a message, so they could capture stack traces if their application stopped processing messages for more than X milliseconds. They wanted to extend this diagnostic information to input delays. Fortunately, there’s an easy way to tell. The Get­Message­Time will tell you the time the message was added to the queue, so by subtracting that time from the current Get­Tick­Count, you can determine how long the input message sat in the queue. (Sent messages are not queued messages, so calling Get­Message­Time for a sent message doesn’t work.) There’s a catch, here, though.

Since mouse messages are generated on demand, the Get­Message­Time for a WM_MOUSE­MOVE message is usually “Just now.” (It could be older if you forced a mouse move message to be generated but left it in the queue.) To get the actual time the mouse moved, you need to use Get­Mouse­Move­Points­Ex.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.