How do I average a complex waveform?
A method I've used for this kind of measurement is actually one of the simplest.  Put a known value capacitor in parallel with the supply and wait until the capacitor is fully charged to the known voltage \$V_1\$.  Then remove the supply.  After some amount of time, measure the remaining voltage \$V_2\$on the capacitor (this assumes that your circuit is capable of running on a range of voltages).  Because the energy \$E=\frac{1}{2}C(V_1-V_2)\$, you can easily determine how much energy was actually used.  If you use the value of the capacitor in microfarads, and voltage in volts, the energy unit is microJoules.  For best results, the value of the capacitor should be measured -- don't just use the nominal value.