[tracing] Improve the runtime complexity of powerSeries.getEnergyConsumed
[tracing] Improve the runtime complexity of powerSeries.getEnergyConsumed

For a given input (start, end) to getEnergyConsumed, instead of iterating
through the whole battor power samples & compute the energy
consumption of the intersection beteween the pair (sample, nextsample) &
(start, end), we only need to iterate from the last sample s which
s.start <= start to the first u which u.start > end.

This speeds up the powerMetric's computation by 1000 times on a typical battor
trace.

BUG=catapult:#2415

Review-Url: https://codereview.chromium.org/2074963002

catapult-project/catapult,catapult-project/catapult-csm,catapult-project/catapult-csm,sahiljain/catapult,benschmaus/catapult,benschmaus/catapult,catapult-project/catapult,catapult-project/catapult-csm,benschmaus/catapult,catapult-project/catapult-csm,sahiljain/catapult,benschmaus/catapult,catapult-project/catapult,sahiljain/catapult,catapult-project/catapult-csm,catapult-project/catapult,sahiljain/catapult,catapult-project/catapult,sahiljain/catapult,sahiljain/catapult,benschmaus/catapult,catapult-project/catapult,catapult-project/catapult-csm,catapult-project/catapult-csm,benschmaus/catapult,benschmaus/catapult,catapult-project/catapult