• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Speed of Quartz (was: optimizing compilers)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Speed of Quartz (was: optimizing compilers)


  • Subject: Re: Speed of Quartz (was: optimizing compilers)
  • From: "John C. Randolph" <email@hidden>
  • Date: Mon, 4 Feb 2002 14:01:35 -0800

On Monday, February 4, 2002, at 11:14 AM, Erik M. Buck wrote:
>
> // define a new bezier path for every two points, set attributes, and
> stroke
> for(i = 1; i < MYNUM_POINTS; i++)
> {
> tempPath = [[NSBezierPath alloc] init];
> [tempPath moveToPoint:_myPoints[i - 1]];
> [tempPath lineToPoint:_myPoints[i]];
> [tempPath setLineWidth:1.0];
> [tempPath setLineCapStyle:NSRoundLineCapStyle];
> [tempPath setLineJoinStyle:NSRoundLineJoinStyle];
> [tempPath setMiterLimit:4.0];
> [tempPath stroke];
> [tempPath release];
> }

This is just a guess, but I think that what's killing you here
is memory allocation. Every time you add a point to the path,
you're potentially causing a realloc(), which means a round-trip
to the malloc table (which means a hash insert.) And of course,
creating and destroying paths is far more expensive than
clearing and reusing a single path.

What happens when you change this to:

temPath = [[NSBezierPath alloc] init];
[tempPath setLineWidth:1.0];
[tempPath setLineCapStyle:NSRoundLineCapStyle];
[tempPath setLineJoinStyle:NSRoundLineJoinStyle];
[tempPath setMiterLimit:4.0];

for(i = 1; i < MYNUM_POINTS; i++)
{
[tempPath moveToPoint:_myPoints[i - 1]];
[tempPath lineToPoint:_myPoints[i]];
[tempPath stroke];
[tempPath removeAllPoints];
}

I'd also be interested in seeing what just calling [NSBezierPath
strokeLineFromPoint:toPoint:] gets you.

-jcr


"These kids today don't know the simple joy of saving four bytes
of page-0 memory on a 6502" - unknown


  • Follow-Ups:
    • Re: Speed of Quartz (was: optimizing compilers)
      • From: Max Horn <email@hidden>
    • Re: Speed of Quartz (was: optimizing compilers)
      • From: "Erik M. Buck" <email@hidden>
References: 
 >Re: Speed of Quartz (was: optimizing compilers) (From: "Erik M. Buck" <email@hidden>)

  • Prev by Date: Re: Saving a RTFD-file with NSAttributedString
  • Next by Date: Trouble with dual processor machines
  • Previous by thread: Re: Speed of Quartz (was: optimizing compilers)
  • Next by thread: Re: Speed of Quartz (was: optimizing compilers)
  • Index(es):
    • Date
    • Thread