Optical pulsewidth measurement using self-phase modulation