The easiest most straight forward method is to simply place a milliameter in
series with Vdd lead and measure Idd, another meter to measure Vdd at chip
Vdd pin. Then P = Vdd x Idd.
Another method is use PSOC to measure Vdd/2 and use a high side current sense
to measure Idd.
I was not paying attention you want to do this while executing code.
PSOC can measure its own Vdd via use of internal reference and
a PGA with gain set to .5. Noite bias cannot be set to high in order
to get common mode in range to Vdd for PGA.
To measure Idd you need a high side sense, an external discrete solution
or a chip, like http://www.maximintegrated.com/app-notes/index.mvp/id/746
Other methods measure T rise in a sense resistor in Vdd lead, light level
of a calibrated emitter in series with Vdd lead.