A hardware counter-based energy estimation tool for battery-powered devices