Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!iuvax!cica!tut.cis.ohio-state.edu!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: Quickdraw efficiency question Message-ID: <7988@hoptoad.uucp> Date: 13 Jul 89 19:39:38 GMT References: <1681@neoucom.UUCP> <7943@hoptoad.uucp> <12676@well.UUCP> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Eclectic Software, San Francisco Lines: 36 In article <7943@hoptoad.uucp> tim@hoptoad.UUCP (Tim Maroney) writes: >DrawString. Smaller trap overhead, fewer internal calls to the Font >Manager, some built-in heuristics to speed things up. DrawText is >even better, supposedly. In article <12676@well.UUCP> wdh@well.UUCP (Bill Hofmann) writes: >Only by a few instructions for each call, since what DrawString does >is pop the length byte and jump to the DrawText code. Interesting. I disassembled DrawText and found that it's only about a dozen instructions that check to see if there's a bottleneck, call it if so, and otherwise get the address of StdText from a low memory global and call it. There really didn't seem to be enough code to produce a significant performance difference from DrawText by using StdText. On the other hand, a source at Apple says that StdText is the only waot handle double-height or half-height text, which is required for a complete vt100 emulation. >If efficiency is >the object here, DrawText (or DrawString) is a very good candidate for >doing a GetTrapAddress at the beginning of your application and doing >a direct jump to it. I've clocked ~10% speed improvement in my app's >redraw just from this optimization. Very interesting, but this seems a little unclean to me. I believe there was a tech note or something which said people should stop using this technique. Probably a better approach is to do a SetStdProcs on your grafport and then call through the address there. This should accomplish much the same thing and get you the same trap dispatch savings, while retaining compatibility with future systems. Thanks for the tip. -- Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com "Every institution I've ever been associated with has tried to screw me." -- Stephen Wolfram