how expensive findViewById ??

by Alexey » Tue, 14 Apr 2009 00:04:39 GMT


Sponsored Links
 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 ?
--~--~---------~--~----~------------~-------~--~----~



how expensive findViewById ??

by Michael Bollmann » Tue, 14 Apr 2009 00:20:39 GMT


 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



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


how expensive findViewById ??

by Alexey » Tue, 14 Apr 2009 00:43:00 GMT


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

On Apr 13, 11:20am, Michael Bollmann



--~--~---------~--~----~------------~-------~--~----~



how expensive findViewById ??

by Michael Bollmann » Tue, 14 Apr 2009 01:09:22 GMT


 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.





--~--~---------~--~----~------------~-------~--~----~



how expensive findViewById ??

by Dianne Hackborn » Tue, 14 Apr 2009 02:53:43 GMT


 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 <








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

--~--~---------~--~----~------------~-------~--~----~



how expensive findViewById ??

by Alexey » Tue, 14 Apr 2009 03:49:23 GMT


 Thanks. that answers my question.







--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Platform Versions Data Updated

Since this is a popular topic around here, I just wanted to point out
that the core Android team has updated the Platform Versions data:

http://developer.android.com/resources/dashboard/platform-versions.html

(thanks to Jason Chen for tweeting this!)

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

_The Busy Coder's Guide to *Advanced* Android Development_
Version 1.4 Available!

-- 

2. LicMax

Given the amount of emails the LicMax guys have put to the list I thought it 
would be worth trying their solution and it took me all of 20 minutes from the 
moment I downloaded their demo to having it falsely report that the demo 
application was permanently authorised (I actually could get it to report 
whatever I wanted, but going from unauthorised to permanently authorised seemed 
a good demo).

I've nothing against competition, but when we're talking about a fundamental 
aspect of developers income (i.e. anti-piracy measures), I have little time for 
badly thought out solutions that aren't hard to break.

If anyone has a LicMax secure application and they'd like to confirm that what 
I've done will unlock their app then please send me the APK (off-list of 
course), and I'll make a video available showing a "before" and "after" video 
showing the normal application state and the post-break application state. I'm 
only going to do 1 app so that it can be independently verified, I'm not going 
to start showing everyone the same thing for different apps.

And no, I'm not going to make public how I did it. I'm not interested in 
helping people crack protection systems, I'm only interested in ensuring 
developers don't start using sub-standard solutions.

And yes, the method I used would work for other platforms they support.

Al.
--

* Looking for Android Apps? - Try http://andappstore.com/ *

======
Funky Android Limited is registered in England & Wales with the company number  
6741909. 

The views expressed in this email are those of the author and not necessarily 
those of Funky Android Limited, it's associates, or it's subsidiaries.

-- 

3. Change text size and color of listview

4. How to send the Email

5. EditText Image changing look when given at runtime.

6. Widget Auto Install

7. Android porting on AM3517