Reliably measuring the energy consumption of arduino running sketch
programmatic way of measuring t


Not sure what you meant by that but typically you can use a high side current sense amplifier to get a measurement of the current. Then adv a known voltage to get vcc. That known voltage could be the internal reference, if available 

In some cases a resistor on vcc can be used to measure current, together with two dividers.