1. Check out our companion app, Forums for Android! Download from Google Play

CPU consumption of android application

Discussion in 'Application Development' started by @NDROID, Aug 27, 2010.

  1. @NDROID

    @NDROID New Member
    Thread Starter
    5

    Apr 7, 2010
    1
    0
    5
    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..??:thinking:

    Thanks
    :)
     

    Advertisement

  2. Kailas

    Kailas Member
    15

    Aug 25, 2010
    19
    0
    15
    Australia
    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
    16

    Apr 15, 2010
    17
    1
    16
    Student, Developer
    Louisiana
    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
    16

    Jul 19, 2010
    13
    1
    16
    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...