Get CPU Usage in App - Android Software Development

Hi.
I´m trying to include the actual cpu usage into my app.
But for no, i haven´t found any api within the sdk to get the actual working speed of the cpu.
Can someone please help me, how to get the actual cpu usage within an application?
Thanks a lot

Related

Excessive CPU usage on X10

Hi
I've just recently bought an XPERIA X10 and one issue I have found is its apparent heavy CPU usage. I would go so far as saying that the phone is close to unusable when it has just booted. So here goes my findings...
I've installed a program called CPU Usage (quite logically) which monitors CPU usage for various tasks on the phone. Here is what I get when the phone has just been booted:
PID / Name / CPU Usage
954 / Sync Feeds/Checking Service/Setting Storage/Android System / 39-58% (No, I'm not kidding)
1054 / Download Manager/DRM /23-31% (still not kidding)
1171 / Face Recognition Service / 11-12% (not as bad, but still, why is it even there???)
The worst thing is that these services don't stop using the CPU - no, they keep on running and using CPU in the designated ranges, unless I kill them.
So I go and kill them using another program I installed.
I found out that if I kill the Face Recognition Service, the CPU usage of the DRM service disappears as well. So everytime I start the device, I have to go kill this service so I can actually use the phone.
The Sync Feeds/Checking/Android service I can't kill, but even though CPU usage reports it as using between 40 and 60% CPU, it seems that another task manager do not report this CPU usage. I can also live with this, if it's a kind of background service that doesn't actually use half your CPU all the time.
So I guess my biggest problem with this is that the Face Recognition service that is run on startup takes many CPU resources, and I have to manually kill it so the phone is running at an acceptable speed. I can't explain why I get different reports for CPU usage on the Sync Feed/Android service, but maybe others can explain...
regards, Artur
You don't need to kill the background processes every time you start up, there is a program that lets you customize which programs and services start on boot, it name is startup auditor. It alseo lets you kill moxier services and timescape
If you use TaskManager you'll se that Moxier doesn't use much CPU at all. It's probably the system in general that uses it.

Check you email (exchange) process, it may be misbehaving

Aster installing a CPU profiling app, I noticed that my email app is taking up 50% of cpu most of the time. After some research, turns out that when it can't connect, it falls into an endless sync cycle, devouring cpu.
Amazingly enough, the fix so far was to change the sync interval from 15 min to PUSH. Obviously pushing it will waste way less cpu than running processor at 50% all the time for nothing (even on a fast wifi).
I'm running latest cyan. Anybody else see that problem?
I'm interested in knowing which CPU profiling app you installed
SeePU+ ?
DarkDvr said:
... Anybody else see that problem?
Click to expand...
Click to collapse
Yes, thus I set Twitter, Beautiful Widgets Wheather, etc.,...to Push!
I'm interested in knowing which CPU profiling app you installed
SeePU+ ?
Click to expand...
Click to collapse
Quick system info pro.
I like it the most, but don't leave it running all the time. To kill it, just click on it in it's processes view.

[Q] setcpu not working

I am using an hd2, and i have noticed something that may be causing a lot of battery drain, that is consistent among every build that I have used. When I use setcpu, and give it root access, and whether i select auto detect or manually put in nexus one/snap dragon, it does not listen to the cpu cap that i put. i will exit the app, and go back to it, and the cpu clock speed with almost always exceed the cpu cap that i set, and many times, it will be running at the full 998 mhz. why is this, and how can i fix it?
I uninstalled SetCPU the other day as a little experiment. It makes f-all difference to me. In fact it makes things worse.
no longer needed with the latest kernels
metaltorizo said:
I am using an hd2, and i have noticed something that may be causing a lot of battery drain, that is consistent among every build that I have used. When I use setcpu, and give it root access, and whether i select auto detect or manually put in nexus one/snap dragon, it does not listen to the cpu cap that i put. i will exit the app, and go back to it, and the cpu clock speed with almost always exceed the cpu cap that i set, and many times, it will be running at the full 998 mhz. why is this, and how can i fix it?
Click to expand...
Click to collapse
This problem seems to relate to a kernel feature called perflock .. disabling this in-kernel allows the cpu cap in setcpu to be adhered to .. Unfortunately this is done at compile time and has no userland interface to use. I dont think its relating to all the battery drain you see but for sure if you limit cpu speeds with profiles like screen off it will have an effect.
try updateing super user libraries.
BurekUSvemiru said:
try updateing super user libraries.
Click to expand...
Click to collapse
Whats that then ?
how would i go about updating the su libraries? does anybody have an actual fix to this, because i would think my battery would be a lot better if the set cpu app was actaully working. and no, the latest kernels dont seem to be doing their job, because they all burn through juice like theres no tomorrow.
u have 2.04 installed ? it fc'd for me , now im using 2.02 no problems , try that
metaltorizo said:
how would i go about updating the su libraries? does anybody have an actual fix to this, because i would think my battery would be a lot better if the set cpu app was actaully working. and no, the latest kernels dont seem to be doing their job, because they all burn through juice like theres no tomorrow.
Click to expand...
Click to collapse
You don't update the su libraries .. su is either a static file or a link to busybox .. i cba looking right now .. probably a binary compiled statically ..
To have your issue resolved have a word with your friendly neighborhood kernel builder and ask him to disable perflock .. Its not needed for normal operation.
I'm having the same problem. Does anyone know how to get setcpu to work?! I have an HD2 running darkstone Froyo.

[Q] Non wakelock email client

Gmail & K9mail both use wakelocks. I don't trust them even in manual check mode. Something much more light weight seems appropriate.
It's important to get this right since the main point of a Nook NST for me is saving battery and being able to pick it up and use it straightaway. If an app starts waking up and draining battery even a little then it's no longer going to last for a month.
Using a browser such as Opera can work but it's a little clunky and so is freezing and unfreezing apps even with a widget. Any recommendations for an email app?
Not sure about email apps so this doesn't answer the question you're actually asking, but may have a functionally similar outcome. Using a CPU scaling app with profiles and setting it so the range of frequencies the CPU can use when the screen is off has both the maximum and minimum values at the lowest possible helps a lot for me.
neoman4426 said:
Not sure about email apps so this doesn't answer the question you're actually asking, but may have a functionally similar outcome. Using a CPU scaling app with profiles and setting it so the range of frequencies the CPU can use when the screen is off has both the maximum and minimum values at the lowest possible helps a lot for me.
Click to expand...
Click to collapse
Thanks buddy but I find I get a month as it is just making sure that the phone.apk and related stiff that starts after rooting is removed. I don't think I need CPU scaling because that's already working for me. Main thing is to watch those wakelocks. There are tons of apps that cause them including skype, paypal, facebook, whatsapp. Only fix is to freeze them, avoid or get the progammers to do it properly and program thier app in 2 parts

Minimum Memory App/Settings

Hey guys,
When I had my droid charge, there was an app that could be used to setup the minimum memory of the OS so it's not using all available RAM to keep apps open in the background, which causes the phone to slow down. I can't seem to find that program so I figured I'd ask if anyone has a program like this and, if so, what settings are you using with it and how is it performing?
Any info you can provide would be appreciated. Thanks, guys!
EDIT: The program I used for the droid charge is apparently called MinFreeManager. Not sure if anyone else uses this or a similar program but I'd be interested in the settings someone is using if they do use it. Thanks!
Best to let android do its own memory management. You'll only hinder the performance by limiting the amount of available memory to the apps/system.
The Linux system is great when it comes to memory management and multitasking. Best to avoid all task killers, and the likes. Read more on how android/Linux manages memory and you'll see what I mean. I believe there were a few articles here on xda as well.

Categories

Resources