Quantifying degradation in lithium-metal and lithium-ion batteries