An electrocardiogram is a test that measures the electrical activity of the heart. This includes the rate and regularity of beats as well as the size and position of the chambers, any damage to the heart, and effects of drugs or devices to regulate the heart.