Measurement of time dependent optical gain using frequency modulation spectroscopy