[android-developers] Re: How to tame CPU usage?

2009-02-21 Thread JP
On Feb 18, 2:36 pm, Mariano Kamp mariano.k...@gmail.com wrote: That sounds very sophisticated. I will try to see how far I can with the current approach and the latency it brings with it. You approach feels too much like doing the operating systems job, which is probably fine and necessary

[android-developers] Re: How to tame CPU usage?

2009-02-19 Thread Mariano Kamp
I can see that. I just don't know how to proceed from here. I don't wont to water down the problem description with lots of details of my app, but as it is not a problem I know how to describe on an abstract level I will still try do that in the briefest form I see fit. Maybe my measurement is

[android-developers] Re: How to tame CPU usage?

2009-02-19 Thread Jon Colverson
On Feb 19, 8:21 am, Mariano Kamp mariano.k...@gmail.com wrote: Ok, now the guesstimeasurement I do is that I look at the time the background is yellow. This time is very brief, when the background thread is not running and went to 4 seconds when the background thread is running and half of

[android-developers] Re: How to tame CPU usage?

2009-02-19 Thread Mariano Kamp
Jon, that sounds very plausible. Yes the background process is updating the same stuff that is displayed, although it is mostly inserts. That wouldn't explain the problem with finger gesture detection, but this problem is so fuzzy it could be anything. Anyway, how to proceed from here? Do you

[android-developers] Re: How to tame CPU usage?

2009-02-19 Thread Jon Colverson
On Feb 19, 1:36 pm, Mariano Kamp mariano.k...@gmail.com wrote: Anyway, how to proceed from here? Do you know how the actual locking mechanism works? It seems (http://www.sqlite.org/lockingv3.html) that they use page level locking. I assume the list adapter's getCount() uses all records, so

[android-developers] Re: How to tame CPU usage?

2009-02-19 Thread Mariano Kamp
Also changing the prio to THREAD_PRIORITY_LOWESThttp://developer.android.com/reference/android/os/Process.html#THREAD_PRIORITY_LOWESTdidn't help things either. During the part where I use an XML pull parser to get through the input document I added SystemClock.sleep(20) when getting a START_TAG

[android-developers] Re: How to tame CPU usage?

2009-02-19 Thread Dianne Hackborn
Um yeah if you put a sleep and there are no other thread to run, you will reduce CPU usage. This isn't really that useful a thing though. It just means you are going to make your code run more slowly, for possibly no good reason. When you lower the priority of your thread, it allows the kernel

[android-developers] Re: How to tame CPU usage?

2009-02-19 Thread Mariano Kamp
That's a good idea. I will try that. On Thu, Feb 19, 2009 at 9:10 PM, Dianne Hackborn hack...@android.comwrote: Um yeah if you put a sleep and there are no other thread to run, you will reduce CPU usage. This isn't really that useful a thing though. It just means you are going to make your

[android-developers] Re: How to tame CPU usage?

2009-02-19 Thread Greg Krimer
Hi Mariano, have you tried profiling your app? The profiler is the ideal tool to tackle a fuzzy performance problem like this, I would think. You can even upload the trace file here allowing us to analyze it. This is probably nothing new, but when profiling try to exercise the area that's

[android-developers] Re: How to tame CPU usage?

2009-02-18 Thread Romain Guy
The proper way to set your thread priority is to execute the following line *in run() method of the thread*: Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND) On Wed, Feb 18, 2009 at 11:32 AM, Mariano Kamp mariano.k...@gmail.com wrote: Hi, I wrote an app that acts as a Google

[android-developers] Re: How to tame CPU usage?

2009-02-18 Thread Mariano Kamp
Thanks for the quick answer. That helped, a lot. Not quite fantastic yet though. No background activity: 300ms (gesture starts something, until something ends) With background activity, before 3500ms With background activity, after 1500ms (All numbers are just guesstimeasured for illustration

[android-developers] Re: How to tame CPU usage?

2009-02-18 Thread JP
On Feb 18, 11:35 am, Romain Guy romain...@google.com wrote: The proper way to set your thread priority is to execute the following line *in run() method of the thread*: Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND) I am dealing with a similar scenario as Mariano describes.

[android-developers] Re: How to tame CPU usage?

2009-02-18 Thread Mattaku Betsujin
Hi Mariano, Not directly related to your question, but how do you use regexp? Do you use the Java API? I am doing a hobby project that's similar to your app. I use regexp to strip all the ads from web pages and reformat them for better display. I actually use a WebView to run the regexp using

[android-developers] Re: How to tame CPU usage?

2009-02-18 Thread Mariano Kamp
That sounds very sophisticated. I will try to see how far I can with the current approach and the latency it brings with it. You approach feels too much like doing the operating systems job, which is probably fine and necessary for your case. In my case the latency thing is just an annoyance

[android-developers] Re: How to tame CPU usage?

2009-02-18 Thread Mariano Kamp
That sounds interesting. I subscribed to your blog and look forward to the results. I am doing the processing as a background activity and don't feel that WebView is a good fit for me here. I just use the regular Java 1.4+ regexps. And I have to say that I wouldn't recommend that. I will very

[android-developers] Re: How to tame CPU usage?

2009-02-18 Thread Mattaku Betsujin
I am not sure how Java's regexp is implemented. If it's implemented in Java code, that would be quite slow. Regexp in WebView's JavaScript is implemented in native code. I have some complicated regexps to parse 600K ~100K HTML files, and they usually finish in 100ms or less (or at least not long

[android-developers] Re: How to tame CPU usage?

2009-02-18 Thread Tim Bray
On Wed, Feb 18, 2009 at 7:56 PM, Mattaku Betsujin mattaku.betsu...@gmail.com wrote: I am not sure how Java's regexp is implemented. If it's implemented in Java code, that would be quite slow. I'm not sure which java library implementations Android uses. The library that comes with Java SE

[android-developers] Re: How to tame CPU usage?

2009-02-18 Thread Mattaku Betsujin
I saw you were testing 100MB files. Have you done any measurements with smaller input files? Also, in your blog, you said Perl consciously accepted a regex slowdown to route around a pathological case where search time could explode to infinity, which might be related to the bug that Mariano

[android-developers] Re: How to tame CPU usage?

2009-02-18 Thread Dianne Hackborn
I am surprised by that. Note that all of the stuff we do in the background on the system (synchronizing data and updating databases and such) is just done with normal threads, running at background priority, doing nothing fancy, and this has little impact on the UI. You really shouldn't have to