Ok, here is the result so far.
1. Small optimisation - using a path object
2. Timing the smaller loop and the paint of the path 

        // get the projection to work with
        Projection pj = view.getProjection();
        
        // get the first position
        geopoint = m_ItinLine.item(0);
        pj.toPixels(geopoint, pt);
        
        Path path = new Path();
        path.moveTo(pt.x, pt.y);
        
        // now walk through the array list
        for(int i = 1; i < m_ItinLine.count(); i++)
        {
            geopoint = m_ItinLine.item(i);
            pj.toPixels(geopoint, pt);
            path.lineTo(pt.x, pt.y);
        }
        cv.drawPath(path, m_paintline);


To answer TreKing's questions 
Here I loop through 11235 GeoPoint objects to create the path - which takes 
17.065 seconds
The call to drawPath takes 0.273 seconds.

The calls to m_ItemLine.item are to a custom array class that I put 
together which does nothing fancy other than create a GeoPoint[] array.


On Friday, 18 May 2012 08:53:47 UTC+2, TreKing wrote:
>
> On Fri, May 18, 2012 at 1:40 AM, Simon Giddings wrote:
>
>> To TreKing : I quite clearly explained that the drawing area was where I 
>> needed to optimise. You can see that I trace the time taken here and this 
>> is where I can say that, on the emulator, it takes 18 seconds.
>>
>
> Your draw method is fairly big. There are a lot of steps there, including 
> a loop where you iterate through a bunch of points (the number of which you 
> didn't specify, which might be your issue). You time nearly the entire 
> method, but more than likely there is one or two lines in there that are 
> eating up the bulk of that time.
>
> My suggestion to you was to profile your code so you can narrow down more 
> precisely which part(s) of that block of code is where most of your time is 
> being spent. If you can come back and say "this line in particular is 
> killing me", or "l'm looping through 6,000 points each frame", then it will 
> be easier to get help with optimizing.
>
>
> -------------------------------------------------------------------------------------------------
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago 
> transit tracking app for Android-powered devices
>
>

-- 
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