Archive for the ‘benchmark’ Category

Debugging the Android Battery

Does android battery suck, or is it usage? In short it does suck compared to other popular alternatives(the i range). However the purpose of this post is not to start a witchhunt or rant but to arm you with tools to debug your battery usage. I will help you track down your battery hog(s) and then suggest some methods to tackle them.

There are 4 main causes of battery hogs:

  1. Cell Phone Usage
  2. Display
  3. CPU usage
  4. Sensors like (GPS, Wifi etc)

Lets start with the easy one:

Cell Phone Usage

Cell tower is the one that provides you connectivity, EDGE and 3G. Unfortunately weak signal can cause this to use exorbitant amount of  battery. If you are experiencing full battery drain in about 2-3 hours then this is most probably the culprit. First thing to do is go Settings -> About Phone -> Battery Use -> Cell Phone standby. Look @ Time spent without signal. Any number other than 0 is very dangerous. There are no practical solutions to this problem. Search for network and fix it. This will prevent phone from searching network when signal is weak. However this may not work when you go on roaming and if you spend most time out of signal this will still consume battery.

Display

The only downside of having a large screen is that it consumes exponential charge. If you using an LCD screen, your phone is only likely to survive 4-5 hrs of screen on time. This is assuming that you are not performing any CPU intensive task during that period like gaming, video etc. It is highly likely that you will consume 4 hrs of usage out of your phone in the entire day hence its unlikely that your phone will survive more than a day. The only aspect to debug here is if some freaky software or buggy ROM is keeping your screen up. Gingerbread provides you clean interface to check your screen on period. You can use Juice Plotter on non gingerbread phones but it has been known to consume a lot of battery itself. Make sure you only use to to debug your screen and not on a regular basis.

Have a look at your Screen ON time and make sure you are getting around 4 hrs of usage. Any thing less than that means that you have issues with your battery. Look through the CPU Usage and Sensor usage area  debug those issues.

Solutions:

  1. Choose an AMOLED screen phone: AMOLED screens consume very little battery in comparison to LCD Screens.
  2. If you have an AMOLED screen then choose darker themes while browsing/surfing/wallpapers. A light color pixel consumes about 5.8 times more energy than dark pixel. This method will not work for LCD phones. You can see the impact of changed wall paper using Current Widget. This will tell you how much charge your phone is consuming(wait for couple of min for it to refresh when you change the wall paper).
  3. Choose  lower screen brightness in general. Rely on Power control widgets to increase screen brightness when required.
  4. Reduce display timeout to 30sec-1min. Adjust that to a time that is comfortable to you.

CPU usage

Today’s CPU are beast. This means not only they are fast and powerful they consumAndroid allows apps to ask for CPU while not using the screen. e millions of amperes of precious juice(okay maybe not millions). CPU usage is a bit tricky to debug in pre-Gingerbread phones. You are mostly led to superstitious advices to control power usage. You can see as much as 10-20% battery usage overnight when you were not using the screen, this is because  Android allows apps to ask for CPU while not using the screen and poorly designed apps continue to update even when they have not been used in a while draining CPU. Enough rant now to function, to debug CPU:
  1. Launch Spare Parts. Fortunately this is bundled in Gingerbread phones, for Froyo you can try out this market app https://market.android.com/details?id=com.androidapps.spare_parts and hope it will work.
  2. Look at Battery history inside Spare Parts. Select “Other Usage” in first drop down.
  3. Check out Running time vs Screen On time.
If these two numbers are widely different then you have a problem on your hands. This means that some app is keeping CPU awake even when your screen is off. To find out which app
  1. Launch Spare Parts
  2. Look at battery history and select “Partial Wake Usage”
  3. Now you will see which app is the culprit and eating up CPU.
Now comes the hard part . You can reduce your running time by disabling this app. If the app manufacturer is good, he would have provided you means to reduce its battery usage(Disabling sync, changing sync from push to hourly, reducing data refresh etc). If not then you should uninstall the app and use something else for that purpose. Keep repeating this exercise till your running time is almost equal to your screen on time.  You will see radical improvements in your standby time with this exercise which in turn can reduce your charge cycles to as much as 2 days.
Other than choosing good apps which use CPU wisely some suggestions:
  1. Use less push sync in general. True push is only available with Blackberry everybody else is doing a very frequent pull to emulate push, so make sure you don’t use push where its not required.
  2. In my opinion disable auto sync all together and do a manual sync when needed. You can put the auto sync button in your power widget and flick it on and off whenever needed
  3. Use Juice Defender it will give you good usage patterns(disabling sync at night etc).
Solution for Advanced Users: if you need all the apps that sync but still want to reduce your battery usage you can try Set CPU to underclock your CPU. You can also use the inbuilt underclocking baked into the CM7 ROM. This solution will only work if you have rooted your phone and your kernel supports underclocking. Default android kernel comes with OnDemand CPU clocking. CPU almost instantly scales to max frequency(like 1Ghz) from its min frequency(like 245Mhz) when required. You will need this kind of speed for gaming/browsing etc however its not required for sync and other background tasks. Set CPU lets you configure so that
  1. Your CPU scales slowly(Conservating  scaling/Power intensive), especially when you have very little battery left
  2. Reduce highest CPU frequency to something like 700 Mhz especially during the night or when the screen is off
Keep in mind however that these solutions can impact your phones performance while rendering pages, gaming etc, so do not reduce cpu frequency or scaling when your screen is on to prevent frustrating experiences.

Sensor usage

If you have reached here then the problem is quite simple shut off all your sensors :). Well Android provides various ways of debugging sensor usage, have a look at your Spare parts => Battery History => Sensor Usage/GPS Usage. If you see a lot of devices are using GPS Sensor you are likely to see a lot of battery loss. Its unfair that android does not let us control which device has access to my location and which does not, I hope they will add that in future versions of android. Meanwhile if you see useless apps tryto access location(mostly to serve relevant ads etc) then you can adopt the following solutions:
  1. Disable both ways to determine your location in Settings => Location and Security. If you really need location then go for “use wireless location” instead of GPS for location. Use GPS only in critical situations where precise location is very necessary
  2.  Change Wifi sleep policy (in Settings => Wireless and Networks => Wifi Settings => Menu key => Advanced => Wifi Sleep policy => When screen is off) This will switch off your wifi and turn on  mobile network when you are not using the screen. This way your background apps can use your slow mobile network to sync while saving wifi juice.
  3. Turn on “Only 2G network” in (Settings => Wireless and Networks =>  Mobile Networks) . This will switch off your 3G network and use only 2G which uses much less battery and is much slower. You can also use 2G/3G switcher in power widget to control this if you rely on 3G for browsing.
Got any other suggestions?? Let me know in comments…
Advertisements

MPEG 4 Part -2 / AVI video codec performance review: Divx vs Xvid which is better?

MPEG-4 Part 2 is a video compression technology developed by MPEG. It belongs to the MPEG-4 ISO/IEC standard (ISO/IEC 14496-2). It is a discrete cosine transform compression standard, similar to previous standards such as MPEG-1 and MPEG-2. Several popular codecs including DivX, Xvid and Nero Digital are implementations of this standard.

If you were looking for MP4/Mpeg4 Part 10  CoreAVC vs FFmpeg video codec performance review then click here

Codecs:

Though there are several codecs that perform the encoding owing to the universal use of this encoding in dvds, common implementations are Nero, Divx, Xvid etc. Among these arguably the most popular codecs are Xvid and Divx. We will be seeing side by side comparison of both in the article. You can find both codecs individual history on their wiki pages. I find the history of Divx quite amusing,They adopted their name Divx to mock a company that used to charge users for viewing by the hour and themselves used spyware in their later version hence becoming a subject of mockery. You might have already noticed that “Xvid” is “Divx” backwards.

I will talk of decoding performance here. Decoding probably makes much more sense to a normal user as encoding is done by few but everybody decodes videos. Decoding is quite a subjective criteria hence besides my own comments I have also attached screenshots that allow the user to make his/her own judgment. The codecs were taken from Final build site.

Xvid
Xvid Logo
There is a very good chance that any video that you come across is encoded with Xvid. Across my search of encoders I found Xvid is the most preferred one for encoding. Its opensource hence free, much more configurable hence lets you draw the last byte’s worth. Though it seems logical that if video is encoded with encoder its respective decoder should also be the best, however I found the results didn’t fare as I expected.

Divx
Divx Logo

The good old closed source version. Divx is costly and costing is on per PC basis hence encoding costly. Decoding can be done for free using their web player. The pro version is not free however there are other ways of using the codec in Media Player classic shipped with Klite Codec as explained below.

Here is the screenshot of Gspot codec analyzation. This provides the codec information with which the file was encoded in:

GSPOT Screenshot of Sherlock Holmes Important things that can be highlighted from the Gspot codec is

1. Video Encoding was done by Divx version 5.1.1

2. Audio Encoding was done by MPEG-1 Layer 3 more popularly known as MP3

3. The default resolution is 352×272 and should be judged at that resolution

Further information can also be seen from the screenshot

PS: you can also use other codec information utils like AVI codec etc.

Following are the screenshots taken from the video with different filters(All the left screenshots are Divx and right ones are Xvid)
Divx Filter with Sherlock Holmes

Xvid filter with Sherlock Holmes

Screenshot with Divx Filter

Screenshot with Xvid Filter

Click the pics and view them at full-size and compare them. As the videos clearly depicted the Divx Filter far outperforms Xvid Filter in visual apeal.

There is a very important decoder that I have not mentioned here, that is the FFmpeg decoder(default decoder in most open players like mplayer, media player classic and vlc). This decoder generally uses libavcodec to decode the media files and even though the performance is not as good as the above decoders but it is good enough but the difference in CPU usage is extreme. Ex for a normal movie where Divx and Xvid take as much as 25-30% CPU usage, FFmpeg will take barely 10-15%. So if its quality you are looking for then look no further than Divx but for performance nobody matches FFmpeg

So overall the results are quite ambigous. If you are looking for quality then Divx, for free encoding/decoding Xvid and for decoding performance FFmpeg . You can download the filters from here, and you can learn how to switch your filter from here. So what are you going to do with your player???

MP4/ HD video codec performance review: CoreAVC vs FFmpeg which is better ?

MPEG-4 is used for AV data for web (streaming media) and CD distribution, voice (telephone, videophone) and broadcast television applications.MPEG-4 adds new features such as (extended) VRML support for 3D rendering, object-oriented composite files (including audio, video and VRML objects), support for externally-specified Digital Rights Management and various types of interactivity. AAC (Advanced Audio Codec) was standardized as an adjunct to MPEG-2 (as Part 7) before MPEG-4 was issued.The key parts to be aware of are MPEG-4 part 2 (MPEG-4 SP/ASP, used by codecs such as DivX, Xvid, Nero Digital and 3ivx and by Quicktime 6) and MPEG-4 part 10 (MPEG-4 AVC/H.264, used by the x264 codec, by Nero Digital AVC, by Quicktime 7, and by next-gen DVD formats like HD DVD and Blu-ray Disc).

If you were looking for MPEG 4 Part 2/ AVI video codec performance review: Divx vs Xvid then click here

Codecs:

As told previously 2 parts of MPEG-4 format are popular. There are several codecs available that implement  MPEG-4 with different level of perfection, popular ones are Quicktime(Part 10), FFmpeg(Part 10), Xvid(Part 2), Divx(Part 2) and CoreAVC(Part 10). After consulting several forums, I found 2 of those very talked about CoreAVC and FFmpeg. I have compared the 2 codecs below.

FFmpeg
FFmpeg Logo
Whether you are a codec geek or not, this is the most probable codec that you have been using since time  immemorial.  Its free, opensource, can allow a lot of tweaking, plays a major number of containers and codecs. I will try not to go beyond H.264 in this article but one thing is for sure, whether you are using CoreAVC or not, you definitely have to use FFmpeg due to its overwhelmingly large number of codec compatibility.

CoreAVC
CoreAVC or Corecodec Logo
Its a closed source alternative for decoding H.264, infact its one of the accepted formats for Blue-ray. When it came out it astonished everyone with the sheer speed and performance outputs. Its known to exceed several hardware implementations (reminds me of John Carmack implementation of square root in Quake 3 which was faster than FPU). Corecodec people call it the fastest codec on earth.(and I am nobody to argue).

Left one is CoreAVC and right is FFmpeg

x264 encoded movie Sunshine decoded with CoreAVC

x264 encoded movie Sunshine decoded with CoreAVC

x264 encoded movie Sunshine decoded with CoreAVC

x264 encoded movie Sunshine decoded with CoreAVC
x264 encoded movie Sunshine decoded with CoreAVC

x264 encoded movie Sunshine decoded with CoreAVC

Doesnt take a rocket scientist to notice that better one. However when I discussed this on outside forums, I faced considerable shouting and screaming so I did more tweaking and testing and found another bit of information that convinced me to use CoreAVC for good.
Left is CoreAVC and right is FFmpeg.
Top is W/O post processing and bottom is with Post Processing

CPU usage between FFmpeg and CoreAVC
Cpu Cycles with CoreAVC
CPU cycles consumption when using FFmpeg codec
Difference between CPU usage when using FFmpeg and CoreAVC is huge. It can be seen from the above CPU usage or by seeing CPU cycles consumption . Considering that I have a Core 2 duo system with 1.8Ghz this difference is a substantial one, infact with preprocessing the player hung at 100% cpu usage in FFmpeg.

I found out to my amazement that Corecodecs are actually the fastest codecs in the world. I used all possible codecs at my disposal(VLC, ffmpeg, quicktime, windows media player and Nero) but CoreAVC not only gave better performance compared to all of them but also astonishingly smooth one at that. I ran it on 1080p trailer of 10000BC on MPC using quicktime alternative(had to rename .mov to .hdmov to use coreAVC) and performance was mind boggling.
Bottomline, I’d suggest you one thing. just go right now to Final build site and download the coreavc format and start using it. You can find out how to do that here.