Spirometry is a common pulmonary function test that measures lung volume and airflow. It is performed using a spirometer to detect respiratory diseases like asthma and distinguish between obstructive and restrictive lung diseases. The test involves taking deep breaths and forcibly exhaling for 6 seconds to measure volumes like forced vital capacity and forced expiratory volume in 1 second. Spirometry is generally safe but may cause shortness of breath and is not performed following a heart attack or other heart conditions.