Measuring power consumption of software

Discussion in 'Mac Programming' started by djslim, Mar 8, 2010.

  1. djslim macrumors newbie

    Joined:
    Mar 8, 2010
    #1
    Hi all,

    I'm new to Mac programming, and I had the following project in mind.

    Goal: visualize how much resources an application uses

    1) let user pick an app
    2) visualize how much memory, hd space, cpu, it is using
    3) visualize how much free space is in RAM and HD
    4) visualize how much power it is using
    5) visualize which cpu instruction is being executed at any moment in time
    6) visualize whether it is going to the harddrive for stuff or the RAM

    are all these possible? I know 2,3 is done by the activity monitor so I assume it is possible, but I wasn't sure about 4,5,6.

    Is there a place I can go for some sample code?

    thanks for all your help!

    slim
     
  2. Catfish_Man macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #2
    4: Not really possible. You would need to do something like measure the current power draw, suspend the app, remeasure, and compare.
    5: That changes 2-3 billion times per second. I don't see how you can visualize that.
    6: You can use dtrace to monitor filesystem activity, but I'm not aware of a way to take into account caching.
     
  3. ehunt123 macrumors newbie

    Joined:
    Dec 7, 2009
    #3
    Since this is a common question, particularally with embedded/mini devices, here is the easiest way without buying expensive equipment and getting a good idea:

    the kill-o-watt meter is a $30 plug that sits between your normal 120v/3prong plug showing you the watts/amps/volts, available at amazon and many other outlets.

    Plug-in, run, get some baseline readings and then perform the same trials running your software.

    Gamers who install high-power cards/lots of mods use this and I've done the same for my carpc/embedded where a device had to be very-low power, even under high load.

    For more sophisticated solutions, there are quite a bit of audrino/specialty usb devices that are the same but provide a reading via a 232/usb port and can be logged.
     
  4. djslim thread starter macrumors newbie

    Joined:
    Mar 8, 2010
    #4
    Awesome! Just got directed to "Instruments", which seems to be a GUI front-end for dtrace.

    thanks!
     
  5. djslim thread starter macrumors newbie

    Joined:
    Mar 8, 2010
    #5
    Just ordered a kill-a-watt! This should be interesting!

    thanks!
     
  6. djslim thread starter macrumors newbie

    Joined:
    Mar 8, 2010
    #6
    Catfish_Man, do you know of any references to sample code that shows you how I can do 2? More specifically I would like to know how much memory the application is allocating and deallocating and also how much it is writing to the filesystem.

    thanks in advance!
     
  7. Catfish_Man macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #7
    The unix command 'top' is open source. So is 'ps'.
     

Share This Page