Is there a way to estimate the energy consumed by a program on an ARM CPU? In embedded systems, energy consumption is one of the most important parameters and I was wondering whether it is possible for a programmer to know approximately how much energy is needed to run the program?
For example, since on the ARM CPU division executed on multiple cycles I imagine that a code using divisions would consume more energy than a code that doesn't. But this reasing is quite intuitive, is there a better way to qulify the energy consumed by a CPU when executing a code?
I don't think there are any ARM-specific tricks here (and 'ARM' covers umpteen different things anyway). You usually look at the current consumption in the various different power states you use (run, sleep, etc) and then estimate what proportion of time is spent in each state. This lets you calculate average current/power.
It doesn't usually make much sense to say 'this instruction uses a lot of power' - what you might instead care about is 'this sequence of instructions take a lot of time to run, hence I can't get back to sleep quickly'.
Closest you'll get with off the shelf tools is something similar to http://ds.arm.com/ds-5/optimize/arm-energy-probe/
Generally battery run systems have fuel gauges which are exposed through sysfs entries and can provide how much current is passing by. Think it like smart phone battery/charge indicator. Those are generally not that reliable and hard to correlate with exact time of application run, but may give you a rough estimate.