Archive

Posts Tagged ‘mac’

OSX/Cocoa UI Event Spy

October 11th, 2009 John No comments

I recently had to profile an application, and one of the metrics I wanted to obtain was the performance of the GUI, without (if possible) resorting to GUI testing frameworks. This metric would be the duration of time from when the user commanded a redraw/update, until the render of that redraw actually completed (effectively a complete client-server-client round-trip time).

To cut a long story short, there doesn’t seem to be a developer tool in OS X or XCode to spy on these UI events, but you can enable them on individual applications by supplying the -NSTraceEvents YES flag to the binary, which you must start from Terminal.

For example, here’s how you’d start TextEdit and spy on its events.

/Applications/TextEdit.app/Contents/MacOS/TextEdit -NSTraceEvents YES

In my case, I actually only wanted to have the mouse-up events which would trigger the refresh. Here’s how I did it:

/Applications/TextEdit.app/Contents/MacOS/TextEdit -NSTraceEvents YES 2>&1 | grep "Received event.*LMouseUp"

NSTraceEvents outputs the trace to the stderr stream, which is ignored by grep, so the 2>&1 is there to redirect stderr to stdout. The “Received event.*LMouseUp” regular expression selects the mouse-up events from the complete stream.

Result:

2009-10-11 16:56:13.291 TextEdit[29990:903]
Received event: LMouseUp at: 320.0,243.0 time: 199375872740000 flags: 0x100 win: 1832 ctxt: f0df data: 2531,1

  • Share/Bookmark
Categories: Software Engineering Tags: ,

Reducing Tooltip Time in Eclipse 3.5 (Galileo) on Mac OS X

June 25th, 2009 John No comments

Tooltips in Mac OS X display, by default, after 2 seconds. I find this is ample time in the general operating system, but in Eclipse it’s an eternity. Eclipse uses Tooltips in the Java tooling to display all kinds of useful information, not the least of which is the javadoc for the element and the source.  Waiting for these is frustrating.

The general workaround of using OS X defaulting to change that didn’t work with previous versions of Eclipse because the SWT (IBM’s excellent widget set) was built on Carbon, OS X’s “UI Compatibility Library”, which ignored the default.  Eclipse is now available for Mac in a native Cocoa version, which does take the defaulting into account.

Here’s how to change the global OS X tooltip delay (in Terminal):

defaults write -g NSInitialToolTipDelay -int 100

I personally want to keep the 2-second delay for everything except Eclipse, so I applied the default just to Eclipse using the Eclipse bundle name:

defaults write org.eclipse.eclipse NSInitialToolTipDelay -int 100

The delay time is in milliseconds. You might have to log out and back in again to make the default take, but usually restarting Eclipse does the trick.

Nice work IBM!

  • Share/Bookmark
Categories: Software Engineering Tags: , ,