setMarkerLocation = 44% CPU?

  • Hi,
    I run my animation at 60 FPS speed.
    During the playback I move a timeMarker along its NSRulerView with

        [hRulerView setNeedsDisplayInRect:[playbackMarker imageRectInRuler]];
        [playbackMarker setMarkerLocation:playbackTime];
        [hRulerView setNeedsDisplayInRect:[playbackMarker imageRectInRuler]];

    Well, I have checked the CPU % with "top" on the Terminal and during the
    playback my app gets 44% of the CPU. If I comment the 3 lines of code here
    above, the CPU % goes down dramatically to 3.6%. Even if I comment the line
    setMarkerLocation only it goes to 3.6%.
    I have verified with "Quartz Debug" that the "yellow" region of the
    NSRulerView I refresh is just the one under the timeMarker. I am sure I am
    making something wrong, because that 44% value is really to much, so please
    where should I look at to catch my bug?

    P.S.
    - I run MacOSX 10.5.1 on a MacBook Pro, C2D 2.4 GHz,
      with NVIDIA 8600M GT 256MB VRAM, 17".
    - I don't subclass the NSRulerView method drawBackgroundInRect
    - No other apps are open. Airport is off.

    Best Regards
    --
    Lorenzo
    email: <archidea...>
  • On Jan 7, 2008, at 10:01 AM, Lorenzo wrote:
    > Well, I have checked the CPU % with "top" on the Terminal and during
    > the
    > playback my app gets 44% of the CPU. If I comment the 3 lines of
    > code here
    > above, the CPU % goes down dramatically to 3.6%. Even if I comment
    > the line
    > setMarkerLocation only it goes to 3.6%.
    > I have verified with "Quartz Debug" that the "yellow" region of the
    > NSRulerView I refresh is just the one under the timeMarker. I am
    > sure I am
    > making something wrong, because that 44% value is really to much, so
    > please
    > where should I look at to catch my bug?

    Top is pretty useless for finding short duration performance
    issues.    At best, top can tell you that an app is consuming way too
    much resources over longer periods.  For shorter intervals, top may
    indicate that there is a problem, but you'll need to use other tools
    to figure out what it is.

    For further analysis, I would suggest using Shark or Instruments to
    determine what is actually using the CPU and for how long in the
    presence of said code.

    b.bum
  • On 7 Jan 2008, at 18:01, Lorenzo wrote:

    > Hi,
    > I run my animation at 60 FPS speed.
    > During the playback I move a timeMarker along its NSRulerView with
    >
    > [hRulerView setNeedsDisplayInRect:[playbackMarker
    > imageRectInRuler]];
    > [playbackMarker setMarkerLocation:playbackTime];
    > [hRulerView setNeedsDisplayInRect:[playbackMarker
    > imageRectInRuler]];
    >
    > Well, I have checked the CPU % with "top" on the Terminal and during
    > the
    > playback my app gets 44% of the CPU. If I comment the 3 lines of
    > code here
    > above, the CPU % goes down dramatically to 3.6%. Even if I comment
    > the line
    > setMarkerLocation only it goes to 3.6%.
    > I have verified with "Quartz Debug" that the "yellow" region of the
    > NSRulerView I refresh is just the one under the timeMarker. I am
    > sure I am
    > making something wrong, because that 44% value is really to much, so
    > please
    > where should I look at to catch my bug?

    Use Shark (or Instruments or Sampler) to find the code that is
    actually eating CPU time.  Make the bit of code that's taking the most
    time more efficient.  Re-run your measurements.  Repeat until bored.

    Kind regards,

    Alastair.

    --
    http://alastairs-place.net
previous month january 2008 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today