CPU consumption of android application


Last Updated:

  1. @NDROID

    @NDROID New Member This Topic's Starter

    Joined:
    Apr 7, 2010
    Messages:
    1
    Likes Received:
    0
    Hi All,

    My android application when launched shows 2 buttons for performing two different operations, I want to measure the power or cpu consumption for these two operations.

    Is there any way to calculate saperately how much cpu or power is consumed when each of these buttons are clicked..??:confused:

    Thanks
    :)
     

    Advertisement
  2. Kailas

    Kailas Member

    Joined:
    Aug 25, 2010
    Messages:
    19
    Likes Received:
    0
    What do you mean "how much cpu or power"?

    If you mean "measure how long each operation takes" then you could use System.nanoTime() to get the current cpu time before the operation and subtract it from System.nanoTime() after the operation (do that for both operations to see which one took longer).

    I haven't looked into checking battery levels, if you meant "measure how much battery power each operation uses", I would assume its fairly proportional to the time each operation takes and I'm not sure if the battery level measurements would even be precise enough to show you a difference (and that would be fairly pointless anyway since the device will probably be doing many other things at the same time in other threads that will use up the battery).
     
  3. SWhite

    SWhite Member

    Joined:
    Apr 15, 2010
    Messages:
    17
    Likes Received:
    1
    im not sure how useful either of these calculations will be for you. Each app runs in its own VM and resources are managed by the kernel and allocated to each VM based on need and priority. The time it actually takes for the app to respond, and then complete the operation can vary. As far as the time for the operation itself, id suggest counting flops. Its fairly simple, as basically each new command in the operation is roughly one flop. try googling it to get the specifics on how its counted.

    after you have the flops, you know the system time it will take, as each flop is one millisecond in duration. Battery consumption can also be figured out through this method if you look up how much power is required for the transistors in the processor to flop.

    hope this helps
     
  4. morkon

    morkon Member

    Joined:
    Jul 19, 2010
    Messages:
    13
    Likes Received:
    1
    you should probably look up "Big-O Notation," it should give you the best idea on how to calculate what program/function will require from a CPU.

    Theres no clearcut way of doing it, and Big-O Notation can be tedious if you dont have a basic understanding of infinite series/calculus, but its the most accurate way.
     

Share This Page

Loading...