Hello Marc, thanks for quick reply.

I have read this document very carefully, though this is not my
production code,
I try to use some principles described there (local variables instead
of class fields).
Especially in those methods where I have loop: drawAsteroids,
drawBullets,
updateAsteroids, updateBullets.

I will try to use profiler, however I don't think that
System.currentTimeMillis()
is really slow down onDraw method, if we look at this values:
  - Average onDraw: 32 ms (clear canvas: 3, draw game stuff: 26, draw
controls: 1)
then we can see that onDraw methods with many calls to
System.currentTimeMillis()
is take ~30ms to execute, and part of this method that draws "game
stuff" is take
~25ms from that 30ms.

And thanks for advice about eliminating function calls in onDraw, I
will try to do it.

Best Regards, Andre

On 18 янв, 13:41, Marc Reichelt <[email protected]> wrote:
> Hi Andre,
>
> you should definitely read the "Designing for Performance" document
> from:http://developer.android.com/guide/practices/design/performance.html
>
> I think you might speed up your onDraw() method a little bit this way,
> though I think you might not reach more than 30 or 35 FPS.
> At first you should eliminate all function calls in your onDraw()
> method. I know this is bad code style, but it really is faster. I am
> drawing some bitmaps for a project here this way.
> Second, you should create local variables for all attributes you use
> more than once.
> Third and most importantly: Remove unnecessary code. For example, you
> call System.currentTimeMillis() relatively often (I think you used
> this code for performance measuring, but anyway).
>
> And last but not least: Android comes with a profiler. Try to use
> it. :-)
>
> Regards
>
> Marc Reichelt   ||  http://www.marcreichelt.de/
>
> On 18 Jan., 10:16, Andre <[email protected]> wrote:
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to