add function to measure battery consumption