Thanks Mark, that is a great explanation. Another way one can look at this: your app is probably not nearly that important to most of your users. We are increasingly working on ways to let the users know which apps are doing this kind of stuff, so they can make good decisions about the things running on their device, and uninstall such apps if they don't find them important enough.
On Wed, Sep 9, 2009 at 2:45 PM, Mark Murphy <mmur...@commonsware.com> wrote: > > Lee wrote: > > Following that philosophy to the end, the user should never turn the > > device on. > > How much power cost is depends greatly upon what one is doing. An > every-5-seconds service is pretty likely to be very bad for battery life. > > I really encourage everyone to watch Jeff Sharkey's Google I/O 2009 > presentation: > > http://code.google.com/events/io/sessions/CodingLifeBatteryLife.html > > Quoting from the key slide for this case: > > "* Waking up in the background when the phone would otherwise be sleeping > * App wakes up every 10 minutes to update > * Takes about 8 seconds to update, 350mA > * Cost during a given hour: > * 3600 seconds * 5mA = 5mAh resting > * 6 times * 8 sec * 350 mA = 4.6mAh updating" > > Now, his case was for an app that was updating data over the Internet, > which is why his power usage was 350mA for that period. > > In the case of an every-5-second service, I will make two assumptions: > > 1. Battery usage will be around 20mA, mid-way between totally idle and > typical usage. > > 2. That it will effectively continuously draw that power, as a > combination of its own code and other system-level things that go on as > a result of its code, and the fact that the CPU might effectively stay > awake during the whole time handling all of that. > > That means that, during an hour, it'll draw 20mAh, versus 5mAh for > normal idle. > > So, let's take a user that seriously uses the device for only about an > hour a day (350mA), etc. With a G1, that should result in slightly over > two days runtime between charges (2 hours usage @ 350mA, 46 hours idle @ > 5mA = 930mAh compared to 1150mAh capacity). The every-5-seconds app will > cut that back to slightly over one day (1 hour usage @ 350mAh, 23 hours > idle @ 20mAh = 810mAh). > > In other words, *one app* roughly halves the battery life of the G1. > > Obviously, actual real-world testing would have to be done, because my > estimates may be high or low, as I know neither the code being executed > every 5 seconds nor the specific details on if the device will actually > fall back asleep much in between the 5-second intervals. > > However, this effect, I suspect, is why Ms. Hackborn asked that > developers not do this. > > Now, if you are developing code to go in firmware on some set-top box, > or something else that has a continuous source of power, then this issue > falls away. But for a mobile device, something that effectively runs all > the time is a bad idea. > > -- > Mark Murphy (a Commons Guy) > http://commonsware.com | http://twitter.com/commonsguy > > Android Development Wiki: http://wiki.andmob.org > > > > -- 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 -~----------~----~----~----~------~----~------~--~---