[android-developers] Re: how expensive findViewById ??

2009-04-13 Thread Alexey

Thanks. that answers my question.

On Apr 13, 1:40 pm, Dianne Hackborn  wrote:
> Actually it's not nearly so smart -- it is just a traversal through the view
> hierarchy until it finds a matching id.
>
> As with all things, you should avoid doing this repeatedly if you don't need
> to (keep the thing you find in a variable so you don't have to look it up
> again).  For more subtle performance questions, the profiler is really what
> you need to use.
>
> On Mon, Apr 13, 2009 at 10:09 AM, Michael Bollmann <
>
>
>
> michael.bollm...@googlemail.com> wrote:
>
> > I guess findViewById uses some kind of map implementation with O(log
> > n)
> > So my guess is that it's about 100-200 compared to 0 when you use
> > member access.
>
> > On Apr 13, 6:40 pm, Alexey  wrote:
> > > yeah, that reference doesn't have number i'm looking for.
>
> > > On Apr 13, 11:20 am, Michael Bollmann
>
> > >  wrote:
> > > > It depends on how often you call it and what your app is doing anyway.
> > > > Now matter how good it's implementation is access to a member variable
> > > > is always much faster than a function call.
> > > > On the other hand you might not notice any improvement in case your
> > > > app does some stuff that takes
> > > > 1000 times longer than a call to findViewById.
>
> > > > Take a look at this:
> >http://developer.android.com/guide/practices/design/performance.html#...
>
> > > > On Apr 13, 6:04 pm, Alexey  wrote:
>
> > > > > Hi all, trying to find some performance numbers for findViewById -
> > > > > need to convince  to change bunch of the findViewById for the same
> > > > > widget to member variable with just one findViewById on create . Or
> > > > > may be i'm wrong and it's fine ?
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: how expensive findViewById ??

2009-04-13 Thread Dianne Hackborn
Actually it's not nearly so smart -- it is just a traversal through the view
hierarchy until it finds a matching id.

As with all things, you should avoid doing this repeatedly if you don't need
to (keep the thing you find in a variable so you don't have to look it up
again).  For more subtle performance questions, the profiler is really what
you need to use.

On Mon, Apr 13, 2009 at 10:09 AM, Michael Bollmann <
michael.bollm...@googlemail.com> wrote:

>
> I guess findViewById uses some kind of map implementation with O(log
> n)
> So my guess is that it's about 100-200 compared to 0 when you use
> member access.
>
> On Apr 13, 6:40 pm, Alexey  wrote:
> > yeah, that reference doesn't have number i'm looking for.
> >
> > On Apr 13, 11:20 am, Michael Bollmann
> >
> >  wrote:
> > > It depends on how often you call it and what your app is doing anyway.
> > > Now matter how good it's implementation is access to a member variable
> > > is always much faster than a function call.
> > > On the other hand you might not notice any improvement in case your
> > > app does some stuff that takes
> > > 1000 times longer than a call to findViewById.
> >
> > > Take a look at this:
> http://developer.android.com/guide/practices/design/performance.html#...
> >
> > > On Apr 13, 6:04 pm, Alexey  wrote:
> >
> > > > Hi all, trying to find some performance numbers for findViewById -
> > > > need to convince  to change bunch of the findViewById for the same
> > > > widget to member variable with just one findViewById on create . Or
> > > > may be i'm wrong and it's fine ?
> >
>


-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: how expensive findViewById ??

2009-04-13 Thread Michael Bollmann

I guess findViewById uses some kind of map implementation with O(log
n)
So my guess is that it's about 100-200 compared to 0 when you use
member access.

On Apr 13, 6:40 pm, Alexey  wrote:
> yeah, that reference doesn't have number i'm looking for.
>
> On Apr 13, 11:20 am, Michael Bollmann
>
>  wrote:
> > It depends on how often you call it and what your app is doing anyway.
> > Now matter how good it's implementation is access to a member variable
> > is always much faster than a function call.
> > On the other hand you might not notice any improvement in case your
> > app does some stuff that takes
> > 1000 times longer than a call to findViewById.
>
> > Take a look at 
> > this:http://developer.android.com/guide/practices/design/performance.html#...
>
> > On Apr 13, 6:04 pm, Alexey  wrote:
>
> > > Hi all, trying to find some performance numbers for findViewById -
> > > need to convince  to change bunch of the findViewById for the same
> > > widget to member variable with just one findViewById on create . Or
> > > may be i'm wrong and it's fine ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: how expensive findViewById ??

2009-04-13 Thread Alexey

yeah, that reference doesn't have number i'm looking for.

On Apr 13, 11:20 am, Michael Bollmann
 wrote:
> It depends on how often you call it and what your app is doing anyway.
> Now matter how good it's implementation is access to a member variable
> is always much faster than a function call.
> On the other hand you might not notice any improvement in case your
> app does some stuff that takes
> 1000 times longer than a call to findViewById.
>
> Take a look at 
> this:http://developer.android.com/guide/practices/design/performance.html#...
>
> On Apr 13, 6:04 pm, Alexey  wrote:
>
> > Hi all, trying to find some performance numbers for findViewById -
> > need to convince  to change bunch of the findViewById for the same
> > widget to member variable with just one findViewById on create . Or
> > may be i'm wrong and it's fine ?
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: how expensive findViewById ??

2009-04-13 Thread Michael Bollmann

It depends on how often you call it and what your app is doing anyway.
Now matter how good it's implementation is access to a member variable
is always much faster than a function call.
On the other hand you might not notice any improvement in case your
app does some stuff that takes
1000 times longer than a call to findViewById.

Take a look at this: 
http://developer.android.com/guide/practices/design/performance.html#samples

On Apr 13, 6:04 pm, Alexey  wrote:
> Hi all, trying to find some performance numbers for findViewById -
> need to convince  to change bunch of the findViewById for the same
> widget to member variable with just one findViewById on create . Or
> may be i'm wrong and it's fine ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---