Nonlinear-optical probing of nanosecond ferroelectric switching